Yes, It's Both Possible and Efficient
The Leadership feat is one of the game's best feats. Attracting a spellcaster as a cohort is boon to any character.
Any Class Can Have a Little Buddy
Any class can have a cohort--a specific NPC follower, often with class levels in player-character classes (rather than NPC classes) and usually acquired via the feat Leadership--with the DM's permission via many different character options. Acquiring that permission can be challenging because, according to the rules, the DM manages the cohort yet the cohort's loyal to the PC who expended the resources aquiring it. This requires the DM to play an NPC who might be expected to be a near-constant PC companion while trying to inconvenience the PCs and all of their near-constant companions.
The PC who gains a cohort attracts one; such a creature does not come into being spontaneously with all the options the player desires merely because the PC takes the feat Leadership. As the DM builds and controls NPCs--and the cohort is an NPC--the usual process I've experienced is the player tells the DM what kind of cohort his PC is trying to attract and the DM builds the cohort.
A DM who allows players to build their characters' cohorts exhibits vast trust in his players.
The Standard Class Choices
An easily managed cohort is a blessing to the DM, but a cohort who casts spells usually isn't easily managed. I suggest a sorcerer, with its limited spells known, but what you probably want--and having either is far harder on the DM--is a cleric or wizard because of the cohort's versatility. It's one thing having a cohort who casts greater named bullet 3/day but another thing entirely having a cohort who casts find the path, heal, and heroes' feast, especially when no one else can. While you'll find the latter qualitatively better than the former, the former is more likely to meet with your DM's approval, especially if designed in the way you describe.
Pathfinder currently lacks an official character class specializing in item creation and modification, but third party classes that do so include a different, not D&D 3.5 artificer, and the artisan, gearhead, machinesmith, and tinker. Some are steampunk style inventors but often also possess at least some spellcasting.
Getting a Tiny Cohort
What would be awesome is if the game supported a shoulder dragon, winged mini-demon, or little tornado with arms that would cast spells to make your guns better and reload your guns when he's not busy spellcasting. Yeah, but the game doesn't support those.
The easiest option is a halfling or gnome sorcerer who has been the target of the spell reduce person followed by a high-level casting of the spell permanency. Such a creature is Tiny and can sit on a PC's shoulder. Alternately, a monkey who's been the target of the spell awaken and subsequently gained sorcerer levels could serve the same purpose, but will likely be a lower-level spellcaster due to the increased HD from the spell awaken.
The Monster Cohorts page lists Young Dragon as an option, so your DM could house rule a faerie dragon (which doesn't have an age category) as a 10th-level cohort when your Leadership score hits 14, but the Leadership feat really, really hates letting monsters follow around PCs and the list encourages bigger monsters rather than smaller ones.
Another way to get a shoulder buddy is to use the rules for Monsters as PCs, which produces far superior and more playable results than the above CR 2 critter when you're level 12. Using those rules would allow for a shoulder dragon, winged mini-demon, or little tornado with arms cohort, but using those requires house rules as the cohort isn't a PC. Another house rule can be made to allow building a race that meets your needs from scratch using the rules for Creating New Races. I don't know enough about Pathfinder's vast supply creatures to tell you if there's the perfect creature for your needs in an obscure sourcebook, however.