LONDON, JULY 20 -- Prime Minister Margaret Thatcher, although rarely given to levity on the floor of the House of Commons, provoked a laugh from her fellow members of Parliament last week when she invited them to compare Britain's ability to keep secrets to that of the United States.

Legislators on both sides of the aisle clearly took Thatcher's remark as a joke. For while Britain has been astonished at the number of U.S. secrets pouring out of the Iran-contra hearings, Thatcher has been unable to cut off the flow of restricted information in her own national security uproar.

By latest count, her government is involved in legal action against six leading newspapers because they published details from a spy-and-tell book.

The book, called "Spycatcher," has not been published in Britain. But even as the censorship and security debate rages in the Commons and the courts, "Spycatcher" is openly for sale as nearby as the public square across from Parliament. There, an enterprising Briton has been offering, at nearly a 10-fold markup, copies of the book purchased in the United States, where it was published last week with "banned in Britain" advertisements by Viking Penguin.

This morning, another entrepreneur was spotted selling copies along the highway leading into the city from London's Heathrow Airport. According to a spokeswoman at Viking Press, the first 50,000 copies of the book have been distributed and a second printing of 35,000 copies has already been ordered.

In a court appeal today to lift injunctions against newspaper publication of information from the book, lawyers for The Guardian, the Observer and The Sunday Times said that the fact that many of those copies have been freely brought into Britain has made a mockery of the government's argument that the public interest is served by restraints on publication here. Guardian lawyer Desmond Browne compared the race to hand-carry books across the Atlantic to the annual "Beaujolais run," when British liquor-store owners race to France to be the first to sell the new wine vintage.

Even The Daily Telegraph, which has not published book excerpts and is normally sympathetic to the Conservative government, has called for the court proceedings to be officially "written off" as "more or less absurd."

The saga of "Spycatcher" has been underway for more than a year. It gained prominence a year ago, when The Guardian and the Observer ran stories indicating that former intelligence agent Peter Wright had written a manuscript detailing two decades worth of misdeeds by MI5, Britain's domestic counter-intelligence agency.

Wright's revelations include descriptions of how he and his colleagues "bugged and burgled" their way through foreign embassies and domestic political headquarters in London in the late 1950s. He also describes at some length the often strained relations between British and American intelligence services during the 1960s.

Wright's most serious allegation is that a group of right-wing MI5 officers conspired to discredit the Labor governments of Harold Wilson during the 1960s and 1970s.

The government quickly obtained injunctions against both newspapers, prohibiting them from publishing any information about Wright's allegations on grounds of national security.

Meanwhile, the government was embarking on a separate attempt to prohibit publication of the book itself in Australia, where Wright has lived for the past several years.

Wright, 76, is by all accounts a crotchety and bitter man whose book makes clear his resentment toward the British government over what he thinks is an inadequate pension paid him since he retired in 1976. Britain argued that Wright was bound by a secrecy oath and could not reveal under his own name any information drawn from his years of official service.

Britain lost the case last winter, although an appeal scheduled to be heard on July 27 has still prevented publication of "Spycatcher" there.

In the meantime, another British newspaper, The Independent, published substantial extracts from Wright's manuscript last April. Two evening newspapers, The London Daily News and The Evening Standard, followed suit the same day with stories drawn from the Independent's account. A detailed account of Wright's manuscript appeared in The Washington Post in May. The government sought contempt findings against all three papers based on the year-old injunctions against The Guardian and The Observer.

Although one judge initially denied the contempt citation on grounds that one paper could not be bound by an injunction against another, that decision was overturned last week by an appeals panel in favor of the government and contempt proceedings are now expected to continue.

The sixth newspaper, The Sunday Times, entered the legal wrangle on July 12, when it published the first installment of a serialization of "Spycatcher" for which it reportedly paid Wright at least $160,000. The government obtained yet another injunction.

Today, The Sunday Times and the original enjoinees, The Guardian and The Observer, went to court together to argue that the government's national security argument -- the basis for the original injunctions -- had been rendered meaningless by the book's availability here.

Despite misgivings in some government circles, Thatcher is believed to be determined to continue efforts to restrict the newspapers on grounds of principle and to set an example to other security service employes who might be tempted to reminisce in print.