For 5th edition all you need to do what you describe is the feat War Caster:
You can perform the somatic components of spells even when you have
weapons or a shield in one or both hands.
So you can hold your staff in one hand, your tome or whatever in your left. The staff is a weapon and rules as written, you can cast spells with somatic components, with or without material components if your other hand is holding a focus, as long as at least ONE hand is holding a weapon.
- I am assuming that you are trying to cast a spell with somatic components, which requires at least one free hand, rather than a spell that requires a free hand as a part of its description.
Mage Hand, Action Economy, and other errata
Holding a weapon in one hand while holding your focus in the other, means you have no free hands and cannot cast a spell with a somatic component. The same hand that “Accesses” a focus in place of material components can be used to cast somatic components, but that assumes the spell requires a material component, if not it takes up a hand slot and prohibits casting.
What is often overlooked is that a caster is assumed to either be using a spell component pouch (Which is not required to be held) or they are automatically stowing their weapon as part of their action to cast their spell, effectively freeing up a hand and using their focus / pouch. (See use an object rule in the PHB). On their next round, if needed, as part of their attack action they redraw the object as part of the attack action to make their attack.
Fighters can stow two handed great swords into their inventory as part of their attack action; meaning there are no rules against you stowing your staff (a two handed weapon) directly into your inventory as part of your action.
In order to both stow and draw an object on the same round requires the a full use of your Action. You may however drop an object, draw an object and take an attack or cast a spell, but the dropped item is no longer in your inventory.
It takes your action to make a mage hand pick up an object for you or release an item, preventing you from using your action to cast a spell. If you “Drop” your staff while your mage hand is holding in order to free up a hand, its posession transfers to the hand’s inventory. It is the only thing holding the object and by “Dropping” the staff you are explicitly ejecting it from your own invintory.
Mage hand and familiars are considered separate entities. Their “inventories” bonuses received and enchantments are not conferred to the caster who owns them. They also do not have class levels and cannot perform somatic actions on behalf of their owners. In order to use a magical device one must either meet the prerequisites to use that item or have an ability to emulate their use (Thief’s Use Magic Item). And even if they did meet the requirements, they are the ones considered using the magical item, not the caster.
There are no explicit rules covering the idea of using an item in another entities inventory. The game does assume that any item you do use is either unattended or explicitly within your inventory (worn, or wielded).
The game assumes that you can only use magical items you have control over such as being worn or wielded, and an object can only be used by one person at a time. Meaning you cannot use an item being held by another entity, even if you can put your hands on it. To use an item being held by your mage hand, you would need to transfer it to your inventory first, then use the item.
The two examples of this concept of assumed ownership and what your allowed to do is the disarm rule (Whomever is holding the object at the start of the round, retains ownership at the end of the round if the disarm failed), and slight of hand (Which only allows you to pilfer unattended objects, not held ones.)
From the section regarding wearing and wielding magic items:
Using a magic item’s properties might mean wearing or wielding it… A magic item meant to be worn must be donned in the intended fashion..
This evidence does not explicitly state – but rather assumes you have objects in your inventory before you use them appropriately. Object held by others must be disarmed or dropped before being placed in your inventory, and unattended objects must be transferred to your possession / control before you can use them (since slight of hand only allows you take unattended objects).