We construct a matrix model that reproduces the topological string partition function on arbitrary toric Calabi–Yau threefolds. This demonstrates, in accord with the BKMP “remodeling the B-model” conjecture, that Gromov–Witten invariants of any toric Calabi–Yau threefold can be computed in terms of the spectral invariants of a spectral curve. Moreover, it proves that the generating function of Gromov–Witten invariants is a tau function for an integrable hierarchy. In a follow-up paper, we will explicitly construct the spectral curve of our matrix model and argue that it equals the mirror curve of the toric Calabi–Yau manifold.