We propose a mean-field approximation to a stock-flow consistent agent-based macro- economic model with heterogeneous firms and households. Depending on their investment elasticity to past profits, firms can be either aggressive or conservative. Conversely, households are divided into investor and noninvestor groups, depending on whether or not they invest a portion of their wealth in the stock market. Both firms and households dynamically change their type according to transition probabilities specified exogenously. The mean-field approximation consists of homogenizing the balance-sheet variables for agents (firms or households) of the same type and computing the time evolution of the corresponding average as a combination of the deterministic dynamic, derived from investment and consumption decisions before a change of type, and the probabilistic change in type, with an appropriate rebalancing to take stock-flow consistency into account. The last step of the approximation consists in replacing the underlying Markov chain with a continuous-time diffusive limit. We present numerical experiments showing the accuracy of the approximation and the sensitivity of the model with respect to several discretionary parameters.