Automorphic form encoding the orders of $N$ modulo $p$. Let $N$ be a nonzero rational number. For every prime number $p$ with $v_p(N)=0$, let $a_p$ denote the index in $\mathbb Z/p\mathbb Z$ of the subgroup generated by $N$ modulo $p$. So we have $a_p=1$ if and only if $N$ is a primitive root mod $p$.

Is there an automorphic form which encodes the numbers $a_p$?

Let me explain: To give $N$ is the same thing as to give a group homomorphism $\mathbb Z \to \mathbb G_m$ over $\mathrm{spec}\mathbb Q$. Such a morphism is also the same as an extension 
$$0\to \mathbb Q(1) \to M \to \mathbb Q \to 0$$
of motives over $\mathrm{spec}\mathbb Q$. The motive $M$ is an example of a "mixed Tate motive", and also an example of a 1--motive. Its weights are $0$ and $-2$. The condition $v_p(N)=0$ means then that $M$ has good reduction at the prime $p$, i.e. extends to a 1--motive over the local ring at $p$. The number $a_p$ is then given by
$$a_p = H^0(\mathbb F_p,M)$$
where we interpret $M = [\mathbb Z \to \mathbb G_m]$ as a complex concentrated in degrees $-1$ and $0$. With $M$ are associated "realisations", in particular $M$ comes with integral $\ell$--adic representations. So to restate the question:

Is there an automorphic form corresponding to $M$? 

We could look at the L-function associated with the $\ell$--adic representation of $M$ to get a hint. The problem with this is that the L-function does not see the extension structure, it only depends on the semisimplification of the representation. This is clear because it is constructed by taking traces of Frobenius elements -- the L-function is in fact $\zeta(s)\zeta(s-1)$, independently of $N$.
I don't know if morally the association Motives $\to$ Automorphic forms which is classically conjectured for pure motives should extend to mixed motives... also, I don't know what a mixed automorphic form is. Maybe these are simply automorphic forms for nonreductive groups? There is a theory of "mixed modular forms" by Min Ho Lee, but I don't think this is what I am looking for.
 A: $\newcommand{\F}{\mathbf F}\newcommand{\Q}{\mathbf Q}$
I want to say two things about this question. First is that I don't understand some of it: I don't know what you mean by "$a_p=H^0(\F_p,M)$" (number = group). Do you mean the number is the order of the group? If so, or indeed whatever you mean, I am a bit confused as to why this is the right idea. Consider for example an $\ell$-adic representation attached to a motive. Then $a_p$ is the trace of a Frobenius element at $p$ rather than the order of an $H^0$. So I'm missing something here.
But here is what I think the answer to a related question is. Toby Gee and I recently spent some time trying to fathom out as general a conjecture as we could, relating automorphic forms to Galois representations. The results of our labour are here:
http://arxiv.org/abs/1009.0785
and the conjecture for $GL(2)$ boils down to something that was presumably in the literature long before us: we conjecture that to an algebraic automorphic representation on $GL(2)$ there should be an associated semi-simple Galois representation. In particular, we could not fathom out how to get automorphic gadgets corresponding to non-semisimple representations. I still vividly remember the train of thought, so let me explain it now.
Say we're looking for Galois representations of $Gal(\overline{\Q}/\Q)$ which are extensions of the trivial character by the cyclotomic character. Then on the automorphic side we are looking for automorphic representations on $GL(2)$ with certain Satake parameters which contradict the Weil bounds, so they can't be cuspidal. So we seek them in the Eisenstein series. And they exist! But here's the catch: they are parametrised by finite subsets of the places of $\Q$. Explicitly, if $S$ is a finite subset of the places, then construct $\pi$ as a tensor product of $\pi_v$ with $\pi_v=|\det|^{1/2}$ for $v$ not in $S$, and $\pi_v$ an appropriate twist of the Steinberg for $v\in S$ (the one with the same infinitesimal char as $|\det|^{1/2}$). These are what show up on the automorphic side. If $S$ is non-empty then $\pi$ does not show up discretely in the space of automorphic forms, and $\pi$ is not isobaric either (so in Clozel's work on Galois representations and automorphic forms he ignores these $\pi$s completely).
However, as you have observed, on the Galois side, more representations seem to show up. We couldn't fathom out how to match things up. So we decided to send every one of these automorphic reps to the direct sum of the trivial rep and the cyclo char. In other words, we had the same, or at least a very similar, problem to yours, and couldn't resolve it.
A: The Mellin transform of the Whittaker function of an Eisenstein series on GL(2) (with trivial central character) is 
$${L(s+s_1,\chi)L(s+1-s_1,\bar\chi)\over L(2s_1,\chi^2)}$$ 
where s$_1$ and $\chi$ are the data in the Eisenstein series. If we could use s$_1$=1 and $\chi=1$, we'd have your L-function (replacing s with s-1 and getting rid of the denominator). This is exactly where the Eisenstein series has a pole, though. I think you can finesse this issue by using the 0-th coefficient in the Laurent expansion of the Eisenstein series around $s_1=1$ (i.e. ${\rm lim}_{s_1\rightarrow 1} \big(E_{s_1}-{1\over s_1-1}\big)$). I'm pretty sure this works, since the Whittaker function of the residual representation is identically zero, so subtracting it won't change the calculation.
If you had a (nontrivial) Dirichlet L-function, the Eisenstein series doesn't have a pole (well, $\chi^2$ can't be trivial), so it would work fine (if you wanted $L(s-1,\chi)L(s,\bar\chi)$). I am somewhat surprised that the calculation of your L-function is independent of N, though I'm ignorant of such things, I defer to your calculation, but I'd suggest that you double-check. 
