(Co)Homology of topoi In Moerdijk's Classifying Spaces and Classifying Topoi, he defines the cohomology groups $H^n(\mathcal E, A)$ for each Grothendieck topos $\mathcal E$ and each abelian group object $A$ in $\mathcal E$ (see I.§4).
Then he remarks:

The construction of these groups $H^n(\mathcal E, A)$ is functorial, contravariant in $\mathcal E$ and covariant in $A$, as usual.

If we consider it as a contravariant functor in $\mathcal E$, what type does the functor have? It can't be $H^n(-, A)\colon\mathbf{Topos}\to\mathbf{Ab}$ for some fixed $A$, because the type of $A$ depends on $\mathcal E$ ($A$ has to be an abelian group object in $\mathcal E$).

*

*How can one consider $H^n(\mathcal E, A)$ as a functor in $\mathcal E$?


*For topological spaces there is singular homology. Do Grothendieck topoi have homology in addition to cohomology?
 A: To talk about $\mathrm{H}^n (\mathcal{E}, A)$ for fixed $A$ and all $\mathcal{E}$, $A$ must be an abelian group in the base topos $\mathcal{S}$.
You pull it back along the "inverse image functor" of the structural geometric morphism $\mathcal{E} \to \mathcal{S}$ to get an abelian group in $\mathcal{E}$.
But we can talk about the functoriality of topos cohomology more generally.
Given a geometric morphism $f : \mathcal{E} \to \mathcal{F}$ and an abelian group $B$ in $\mathcal{F}$, we have a homomorphism $\mathrm{H}^n (\mathcal{F}, B) \to \mathrm{H}^n (\mathcal{E}, f^* B)$.
Concretely:

*

*If we have an injective resolution $B \to J$ in $\mathcal{F}$ (i.e. a quasi-isomorphism where $J$ is a cochain complex of injective objects concentrated in degrees $\ge 0$) then $\mathrm{H}^n (\mathcal{F}, B)$ is $\mathrm{H}^n (\Gamma (\mathcal{F}, J))$.


*$f^*$ is exact, so $f^* B \to f^* J$ is still a quasi-isomorphism but $f^* J$ may no longer be a complex of injectives, so choose an injective resolution $f^* J \to I$ in in $\mathcal{F}$; then the composite $f^* B \to f^* J \to I$ is an injective resolution, so $\mathrm{H}^n (\mathcal{E}, f^* B)$ is $\mathrm{H}^n (\Gamma (\mathcal{E}, I))$, and we have $\mathrm{H}^n (\Gamma (\mathcal{E}, f^* J)) \to \mathrm{H}^n (\Gamma (\mathcal{E}, I))$.


*$\Gamma (\mathcal{E}, f^* J)$ is equally $\Gamma (\mathcal{F}, f_* f^* J)$, and by adjointness there is a natural chain map $J \to f_* f^* J$, so we get
$$\mathrm{H}^n (\mathcal{F}, B) \cong \mathrm{H}^n (\Gamma (\mathcal{F}, J)) \to \Gamma (\mathcal{F}, f_* f^* J) \cong \mathrm{H}^n (\Gamma (\mathcal{E}, f^* J)) \to \mathrm{H}^n (\Gamma (\mathcal{E}, I)) \cong \mathrm{H}^n (\mathcal{E}, f^* B)$$
as required.
Unfortunately, at this level of concreteness it is very hard to be precise about how everything is really functorial.
The first difficulty is what you observed: the domain of $\mathrm{H}^n (-, -)$ should be the category of "all abelian groups in all toposes".
This is actually easy to define – it's a straightforward Grothendieck construction – but it turns out to be not quite enough.
The second difficulty is that, as a concrete abelian group, $\mathrm{H}^n (\mathcal{E}, A)$ depends on not just $\mathcal{E}$ and $A$ but also the choice of injective resolution $A \to I$.
Of course, up to isomorphism, the choice doesn't matter, but since we will be trying to compose morphisms we need to remember which isomorphisms are involved, so we should work with categories of "abelian groups with a chosen injective resolution" rather than categories of abelian groups.
The third difficulty already appeared in the above discussion: "inverse image functors" preserve quasi-isomorphisms but not necessarily injectivity of objects, so given $f_* : \mathcal{E} \to \mathcal{F}$ we get a (choice-free) induced functor $\mathrm{R}^n f_*$ from the category of "abelian groups in $\mathcal{E}$ with a chosen injective resolution" to the category of abelian groups in $\mathcal{F}$, but we we don't get a choice-free functor between categories of "abelian groups with a chosen injective resolution".
So if we had hoped to get the domain of $\mathrm{H}^n (-, -)$ by applying the Grothendieck construction the pseudofunctor sending $\mathcal{E}$ to the category of "abelian groups in $\mathcal{E}$ with a chosen injective resolution", we would find ourselves not even having a (choice-free) pseudofunctor to integrate!
Here is the least bad solution I could think of.
Consider the following truncated simplicial set:

*

*A vertex is a tuple $(\mathcal{E}, A, I, \alpha)$ where $\mathcal{E}$ is a topos, $A$ is an abelian group in $\mathcal{E}$, and $\alpha : A \to I$ is an injective resolution in $\mathcal{E}$.


*An edge $(\mathcal{F}, B, J, \beta) \to (\mathcal{E}, A, I, \alpha)$ is a tuple $(f, \phi, I', \beta', \zeta)$ where $f : \mathcal{E} \to \mathcal{F}$ is a geometric morphism (where the adjunction is fully specified), $\phi : f^* B \to A$ is a homomorphism of abelian groups in $\mathcal{E}$, $\beta' : f^* J \to I'$ is an injective resolution in $\mathcal{E}$, and $\zeta : I' \to I$ is a chain map in $\mathcal{E}$ such that $\zeta \circ \beta' \circ f^* \beta = \alpha \circ \phi$.
Diagrammatically:
$$\require{AMScd}
\begin{CD}
f^* B @>{f^* \beta}>> f^* J @>{\beta'}>> I' \\
@V{\phi}VV && @VV{\zeta}V \\
A @= A @>>{\alpha}> I
\end{CD}$$


*The degenerate edge from $(\mathcal{E}, A, I, \alpha)$ to itself is $(\mathrm{id}_\mathcal{E}, \mathrm{id}_A, I, \mathrm{id}_I, \mathrm{id}_I)$.


*A 2-simplex consists of the following data:

*

*Vertices $(\mathcal{G}, C, K, \gamma)$, $(\mathcal{F}, B, J, \beta)$, and $(\mathcal{E}, A, I, \alpha)$.

*An edge $(f, \phi, I', \beta', \zeta) : (\mathcal{F}, B, J, \beta) \to (\mathcal{E}, A, I, \alpha)$ and an edge $(g, \psi, J', \gamma', \theta) : (\mathcal{G}, C, K, \gamma) \to (\mathcal{F}, B, J, \beta)$.

*An injective resolution $\gamma'' : f^* J' \to I''$ in $\mathcal{E}$ and a chain map $\theta' : I'' \to I'$ in $\mathcal{E}$ such that $\beta' \circ f^* \theta = \theta' \circ \gamma''$.

The edge $(\mathcal{G}, C, K, \gamma) \to (\mathcal{E}, A, I, \alpha)$ is then $(g f, \phi \circ f^* \psi, I'', \gamma'' \circ f^* \gamma', \zeta \circ \theta')$.
It may help to consider the following commutative diagram in $\mathcal{E}$:
$$\begin{CD}
f^* g^* C @>{f^* g^* \gamma}>> f^* g^* K @>{f^* \gamma'}>> f^* J' @>{\gamma''}>> I'' \\
@V{f^* \psi}VV && @V{f^* \theta}VV @VV{\theta'}V \\
f^* B @= f^* B @>{f^* \beta}>> f^* J @>{\beta'}>> I'  \\
@V{\phi}VV @V{\phi}VV && @VV{\zeta}V \\
A @= A @= A @>>{\alpha}> I
\end{CD}$$


*The two degenerate 2-simplices associated with an edge $(f, \phi, I', \beta', \zeta)$ are given by $(\beta', \textrm{id}_{I'})$ and $(\textrm{id}_{I'}, \zeta)$:
$$\begin{CD}
f^* B @>{f^* \beta}>> f^* J @= f^* J @>{\beta'}>> I' \\
@| && @| @| \\
f^* B @= f^* B @>{f^* \beta}>> f^* J @>{\beta'}>> I'  \\
@V{\phi}VV @V{\phi}VV && @VV{\zeta}V \\
A @= A @= A @>>{\alpha}> I
\end{CD}$$
$$\begin{CD}
f^* B @>{f^* \beta}>> f^* J @>{\beta'}>> I' @= I' \\
@V{\phi}VV && @V{\zeta}VV @VV{\zeta}V \\
A @= A @>{\alpha}>> I @= I  \\
@| @| && @| \\
A @= A @= A @>>{\alpha}> I
\end{CD}$$
In principle, we could go on to define higher simplices and get a quasicategory, but for our purposes it is enough to stop at level 2, because:

*

*Given a vertex $(\mathcal{E}, A, I, \alpha)$, there is a choice-free construction of $\mathrm{H}^n (\mathcal{E}, A)$, namely $\mathrm{H}^n (\Gamma (\mathcal{E}, I))$.


*Given an edge $(f^*, \phi, I', \beta', \zeta)$, there is a choice-free construction of $\mathrm{H}^n (\Gamma (\mathcal{F}, J)) \to \mathrm{H}^n (\Gamma (\mathcal{E}, I))$, namely:
$$\mathrm{H}^n (\Gamma (\mathcal{F}, J)) \overset{\eta}{\to} \mathrm{H}^n (\Gamma (\mathcal{F}, f_* f^* J)) \cong \mathrm{H}^n (\Gamma (\mathcal{E}, f^* J)) \overset{\beta'}{\to} \mathrm{H}^n (\Gamma (\mathcal{E}, I')) \overset{\zeta}{\to} \mathrm{H}^n (\Gamma (\mathcal{E}, I))$$


*Given a 2-simplex (notation as above), there is a choice-free proof that the composite of the result of mapping two edges, i.e.
$$\mathrm{H}^n (\Gamma (\mathcal{G}, K)) \to \mathrm{H}^n (\Gamma (\mathcal{F}, J)) \to \mathrm{H}^n (\Gamma (\mathcal{E}, I))$$
is equal to the result of mapping the composed edge.
It may help to draw a commutative diagram, but it will be quite big.
Thus we have a functor from the not-quite-category of "all abelian groups, with a chosen injective resolution, in all toposes" to the category of abelian groups.
There is a forgetful functor from the not-quite-category to the actual category of "all abelian groups in all toposes" and picking an inverse not-quite-functor – i.e. choosing injective resolutions for all abelian groups in all toposes, and then choosing compatible injective resolutions for all homomorphisms as well, and then choosing compatible injective resolutions for all composable pairs of homomorphisms – gives you an actual functor from the category of "all abelian groups in all toposes" to the category of abelian groups, if that is what you wish for.
A: The contravariance of the cohomology functors in the topos variable isn't too bad once you unwind all the various definitions at hand. Consider the category $\mathbf{GrTopos}$ of Grothendieck toposes. Let's make some key observations/recollections:

*

*The category $\mathbf{GrTopos}$ is a subcategory of the $1$-category of elementary toposes $\mathbf{Topos}$. In particular, morphisms of Grothendieck toposes are geometric morphisms $f:\mathcal{E} \to \mathcal{F}$.

*The category $\mathbf{GrTopos}$ has a terminal object, and it is $\mathbf{Set} \cong \mathbf{Sh}(\ast)$. In books like SGA4 you'll see this referred to as the punctual topos.

*For any geometric morphism $f:\mathcal{E} \to \mathcal{F}$ the pullback functor $f^{\ast}:\mathcal{F} \to \mathcal{E}$ is cocontinuous (preserves all colimits) and finitely continuous (preserves finite limits). Because $f^{\ast}$ preserves finite limits, it also restricts to a functor $f^{\ast}:\mathbf{Ab}(\mathcal{F}) \to \mathbf{Ab}(\mathcal{E})$.

*The functors $H^n(\mathcal{E},-)$ are defined as the right derived functors of the global sections functor $\Gamma:\mathbf{Ab}(\mathcal{E}) \to \mathbf{Ab} = \mathbf{Ab}(\mathbf{Set})$, i.e., $H^n(\mathcal{E},-) := R^n\Gamma(-)$.

*The global sections functor $\Gamma:\mathbf{Ab}(\mathcal{E}) \to \mathbf{Ab}$ is the restriction of the global sections functor $\Gamma:\mathcal{E} \to \mathbf{Set}$: It is given on all objects by $A \mapsto \mathcal{E}(\top,A)$ where $\top$ is the terminal object in $\mathcal{E}$.

*The diagram
$$
\require{AMScd}
\begin{CD}
\mathcal{E} @>{f}>> \mathcal{F} \\
@V{\Gamma_{\mathcal{E}}}VV  @V{\Gamma_{\mathcal{F}}}VV \\
\mathbf{Set} @= \mathbf{Set}\end{CD}
$$ commutes in $\mathbf{GrTopos}$ (up to natural isomorphism) by virtue of $\mathbf{Set}$ being a terminal object in $\mathbf{GrTopos}.$ As such, from the natural isomorphism of left adjoints in the diagram, you can deduce the existence of a natural transformation $(\Gamma_{\mathcal{F}})_{\ast} \Rightarrow (\Gamma_{\mathcal{E}})_{\ast} \circ f^{\ast}$. In particular, this is a natural transformation
$$
\mathcal{F}(\top_{\mathcal{F}},A) \Rightarrow \mathcal{E}(\top_{\mathcal{E}},f^{\ast}A)
$$

*The formalism of derived functors extends this to a natural transformation
$$
R^n\Gamma(A) \Rightarrow R^n\Gamma(f^{\ast}A)
$$
for all $n \in \mathbb{N}$. These are exactly the maps $H^n(\mathcal{F},A) \Rightarrow H^n(\mathcal{E},f^{\ast}A)$ you're looking for that are contravariant in the direction of geometric morphisms $\mathcal{E} \to \mathcal{F}$.

