My favorite literary spy is Ashenden. He is the creation of W. Somerset Maugham who served as a British spy during the First World War.
Since Maugham was not eligible to fight in the First World War, due to a physical deformity, his clubfoot, he joined the army ambulance corps. In 1915, he was recruited by the British secret service. Earlier that year, his first novel, Of Human Bondage, had been published, so he had the advantage of a good cover of a novelist. He was fluent in German and French, which made it easier for him to develop connections with informers across Europe. The British secret service sent Maugham on spying missions to Russia, Germany, France, and several other countries.
In 1927, Maugham published the book Ashenden: Or the British Agent, which contains a series of linked short stories based on his experiences as a spy. Ashenden is not glamorous and violent like James Bond; he is sensitive, thoughtful, and he often questions the moral aspects of espionage. But he manages to execute several missions. Ian Fleming, Graham Greene, and John le Carré have said that Ashenden was an influence on their work.