How to calculate price function from demand curve when marginal cost is given? This example is in a oligopoly market with two firms. The demand curve is given and also two firms' MC is given. How would one calculate price function in this scenario?

I found the slope using the demand curve and then found the y intercept to the get the price function. However, I also know that MC is the derivative of the price function. If I take the derivative of the price function I got, it's not the same as the MC.. Any thoughts on this?
Let $y_1$ and $y_2$ denote the output of firms $1$ and $2$. I suspect by price function you mean the inverse demand function. So if
$$
y_1 + y_2 = Y = D(p)
$$
then
$$
D^{-1}(Y) = p(Y) = p(y_1 + y_2).
$$
Let us introduce the notation
$$
MR_i(y_1,y_2) = \frac{\partial p(y_1 + y_2)}{\partial y_i}.
$$
Generally
$$
MR_i(y_1,y_2) \neq MC_i(y_i),
$$
that is the functions are not the same. But if the outputs $y_1^*,y_2^*$ constitute an equilibrium, the functions take the same value.
$$
\forall i: \ MR_i(y_1^*,y_2^*) = MC_i(y_i^*)
$$

Another example:
 The function $x^2$ is not the same as the constant function 4. But if $x=2$ they take the same value.