There is "a spellcaster level" mentioned in the MM:
A monster with the Spellcasting class feature has a spellcaster level and spell slots
Does "a spellcaster level" means basically "a sorcerer level" or "a wizard level" or any particular class level from the PHB, with all its features and restrictions (like spellbooks)? In this case, how do we define the exact class?
Or does that mean something different applying to monsters, which are not based on player classes? In this case, what does it mean exactly?
A relevant question: Where are the NPC mages' spellbooks in the Lost Mine of Phandelver adventure?
Best Answer
TL;DR
Yes, a monster is considered a member of that class, having that number of levels in that class, but no, that monster does not have any feature from that class not found in its stat block. Caster level number is used for cantrips, and for each and every game rule that calls for level of the caster, however infrequent such rules may be.
From the basic rules [1][2]:
Emphasis mine. Thus, stat block should define what class spells are drawn from. If it does not, you can fall back to looking at particular spells and finding out what class have them on its list or can give them via class features. So that's how we define the exact class.
For the part "with all its features and restrictions (like spellbooks)?" - under the "no secret rules" assumption no, only effects for the monsters are:
The rest is left untold, so a DM may rule as he sees fit.