The witness, known as Mr D, was once in charge of running the agency's counter-terrorism agents in Northern Ireland .
He was answering questions from Mr Shayler, 36, who denies three charges of breaching the Official Secrets Act.
Mr Shayler, who is defending himself at the Old Bailey, asked his former boss if spy fiction could damage Britain's national interest.
Mr D said it could create "reactions which would be damaging, based on something that was untrue".
Telephone tapping
Mr Shayler pressed the witness to answer whether the works of writer John Le Carre fitted into that category.
But Mr D said he was not familiar with Le Carre's work.
Mr Shayler asked whether he had ever see a James Bond film as author Ian Fleming, a former member of the service, had included operational techniques in the Bond books.
Mr D replied: "I don't think there's much in a James Bond film that's very close to my experience."
Mr Shayler pointed out that the 007 films did contain incidents of telephone tapping.
Among the charges he faces is that he disclosed information from a telephone tap to a Sunday newspaper in 1997.
Mr D replied: "I don't recall it specifically but I'm sure that might come into it."
Secret carpets
The court has heard that telephone tapping was a "very sensitive technique", but because the jury had already been told about such activities "it is not a sensitive technique at all", said Mr Shayler.
Mr D replied: "Its sensitivity is around its specific use."
On Wednesday the trial heard that Mr Shayler had received a telephone call after leaving MI5 in 1996 from another manager, Mr B, to remind him of his duty of confidentiality.
Mr Shayler also asked Mr D if he was aware that MI5 staff rules prohibited anyone from commenting on its operations "whether it's fact or fiction".
He added: "That would make it an offence to name the colour of the carpets, would it not?"
Mr D, giving evidence from behind a screen, replied: "I don't believe that anyone would take that view."
IRA links
The defendant asked Mr D how long a document marked Secret would remain secret.
The witness said: "It remains secret for as long as it's deemed the material within it is secret."
Prosecutor Nigel Sweeney QC asked Mr D to confirm that he had been responsible for recruiting and running agents to gather information on republican and loyalist terrorist groups.
Asked about the significance of information obtained from these agents, Mr D said: "In some instances intelligence derived from these sorts of sources is unique."
Some of the 28 documents the prosecution claim Mr Shayler copied and handed to the Mail on Sunday dealt with the Provisional IRA's links with Libya, the court heard.
The trial continues.