We formulate a linear response theory of the chiral magnetic effect in a finite Weyl semimetal, expressing the electrical current density j induced by a slowly oscillating magnetic field B or chiral chemical potential mu in terms of the scattering matrix of Weyl fermions at the Fermi level. Surface conduction can be neglected in the infinite-system limit for delta j/delta mu, but not for delta j/delta B: the chirally circulating surface Fermi arcs give a comparable contribution to the bulk Weyl cones no matter how large the system is, because their smaller number is compensated by an increased flux sensitivity. The Fermi arc contribution to mu(-1)delta j/delta B has the universal value (e/h)(2), protected by chirality against impurity scattering-unlike the bulk contribution of opposite sign.