There are spies with official cover and non-official cover[0]--the latter of which is normally to what "undercover spy" refers.
I mean if you break it down in the simplest way possible (for example what the public see on TV and call a spy), what they are seeing is various people who are:
-Handler
-Agent
-Agent of influence
-Analyst
-Mobile Surveillance Officer
-Tech officer
etc etc etc