Soviet authorities have assembled a massive force of uniformed police and plainclothes agents to impose thorough control over the Moscow Olympic Games and eliminate the possibility of anti-Soviet demonstrations or any significant chance contact between Soviets and foreigners.

The security measures, carefully planned over five years, encompass overt control, such as closing Moscow's roads and rails to most non-residents, and intensified pyschological preparation of the populace to look upon foreigners in general and Americans in particular as potential saboteurs and terrorists.

Sources say the Moscow militia, or police, has been quadrupled in the past 10 days, from a normal force of about 50,000 to more than 200,000. More than half are said to be assigned to plainclothes surveillance. This total is more than twice as high as any previous estimate published in the West.

The sources, who cannot be named, are considered knowledgeable and to know with exactitude the methods and minds of the Soviet police apparatus.

The sources said the authorities are intent upon eliminating any conditions under which Olympic athletes and foreign tourists could coalesce into unified national groups not under direct supervision and surveilance. Although the goal of keeping foreigners separated was fundamental from the beginning of security planning, this has assumed crucial importance to the Soviets in the aftermath of the Afghanistan invasion and severe internal human rights repressions, which have brought on world condemnation.

The United States-led Olympics boycott has added new bitterness to the political atmosphere surrounding the Games, raising the stakes yet higher for the Soviets that no demonstration mar their attempts to portray the Games as tacit acceptance of their actions. The Games are scheduled for July 19 to Aug. 3.

In view of the painstaking and massive security precautions, sources here consider it unlikely there will be successful major demonstrations. One scoffed at the avowed intentions of some members of the French Olympic team to show their opposition by staging a protest. "They will be surrounded by 500 'citizens' wherever they go," one source said.

The Soviets have vast resources of control to ensure that a chance or planned political episode does not occur. In addition to the huge militia force, run by the Moscow city authorities as well as the Interior Ministry, the state can draw upon the KGB, whose estimated 500,000 agents pursue both internal security and external intelligence functions. Virtually nothing can be reliably said about how many KGB agents may have been assigned to help out handling the Games.

But the visible police and military presence here has increased since late June. As law enforcement authorities around the world know, one of the secrets of control is to establish a credible or intimidating presence with a mass show of force.With its zeal for mastery, the Kremlin is bringing this about.

The Olympic Village, where about 500 athletes already have taken up residence, is ringed by soldiers carrying AK47 assault rifles. At major downtown hotels, such as the Rossiya and Cosmos, where the foreign press will be quartered, guests must pass through metal detectors and their baggage through X-ray machines each time they enter the hotel. Their documents are scrutinized by armed police, and police control the corridors of every floor. Guests are not allowed to receive visitors unless permission is granted previously. The same strict procedures have been clamped onto the Ostankino Television Center and the new press center for journalists near the Foreign Ministry.

The police and the supervisors have a polite but firm manner, uncompromising in their requirement that documents be shown, briefcases looked into and literature checked. There is a distinct likelihood that forgetful or ornery guests who do not have their hotel cards are going to have trouble with this rigid system. Soviet citizens without special house staff passes or official business will be automatically excluded from most of these facilities. o

Beyond the visible show of force, the Kremlin has stepped up its attempts at armoring citizens' attitudes against open contacts with foreigners. Moscow residents report that in recent weeks, staffs at restaurants, shops, movie theaters and Moscow's famous public baths have been lectured on the dangers of foreign provocateurs depositing timebombs in hidden-away corners or leaving anti-Soviet literature behind when they leave.

As were Moscow's schoolchildren last spring, these employes also are now being warned against accepting chewing gum and candy from tourists because the are likely to be poisoned or infected.

This campaign was supplemented yesterday with a nationally televised program purporting to show how American and Israeli agents, posing as tourists, diplomats and correspondents, smuggle anti-Soviet literature into the U.S.S.R. and seek to gather military secrets.

One insider said the polices themselves are amused by this campaign, confident that their own preparations are more than adequate to handle the Olympic control problem. They are said to view the lectures and programs as a way to create apprehension among the populace, making their own job easier.

Moscow normally has what may be one of the highest police-to-population ratios of any major world capital: 1 to 60. By contrast, the Washington ratio is about 1 to 166, counting only metropolitan police.

The extra militia are said to be living in military-style barracks on the city's outskirts. Patrolmen, wearing the summer uniforms of slate gray trousers and lighter blue-gray blouses with red-trimmed white caps, usually earn about 120 rubles ($180) a month, 60 rubles below the average national wage. They are said to be receiving a daily food allowance of 2.10 rubies, while their officers get 2.20.

The security planners have arranged diversions for this vast new force, said to include cultural tours, athletic programs, films and other entertainment to ensure the men take good impressions of the capital with them when they return to the provinces, where living standards are far lower.

So detailed is this planning said to be that it includes one trip a week to a public bath.