While the Soviet Union bitterly assails President Carter for mixing politics and sports by threatening to boycott the Moscow Summer Olympics, City Communist Party chief Viktor Grishin has just warned that "spies and provocateurs" posing as tourists plan to "subvert socialism from within" during the games.

Grishin, 65, member of the ruling Politburo for nearly nine years and generally considered a hard-liner, told the Young Communist League this weekend that the "spies" will be dispatched here as "part of massive propaganda attacks by the imperiallists."

The powerful leader's address illustrates the divided position of the leadership here in dealing with the Olympics. After intensive lobbying by the Soviets, the International Olympic Committee in 1974 awarded this year's Summer Games to Moscow.

But Carter's call for a boycott if Soviet troops have not withdrawn from Afghanistan by Feb. 20 brings into stark relief the question of what the Soviets really want out of the Olympics and what they think they can get.

What they wanted from the start was the international prestige as well as the hard currency the games would bring.

The Soviets proved tough bargainers with Western firms bidding to attach their brand names to the games. They held out for almost two years before awarding the American television rights to NBC for a record $85 million and struck similar stiff deals with other Western firms. This ensured a hard-currency profit and strengthened the party in dealing with disgruntled citizens who knew their own long-awaited new homes or work quarters would be delayed while the leadership reassigned scarce civilian resources to preparation for the games.

The Soviets also wanted to improve Moscow's image abroad and hoped it would become known as a premier foreign tourist attraction because of the expansion of hotels, restaurants and other services demanded by cash-paying travelers. That vision, however, seems in direct conflict with Grishin's stern warning that "people of varying political views and convictions will come to the games and there will be some harboring unfriendly intentions."

In the context of Soviet life, however, the fears and aspirations are perfectly consistent. The party glorifies the Soviet Union in the international community and, by inference, glorifies its leaders. At the same time, since its holds power by authoritarian means, the party also must insist upon conformity to its ideology and rejection of any others for fear that others may threaten its power. Pluralistic Western democracies may find this repugnant or paradoxical, but it is a fundamental fact of Soviet life.

In the eyes of veteran foreign sources, there is no reason to believe the party has everdoubted it could have it both ways with the Olympics despite the potential dangers of the influx of tourists with their "contaminating ideas," as Grishin put it last summer. The Soviets long ago accepted the notion that expansion of trade and other contacts with the West would bring potentially troublesome ideological challenges as part of the price. But these have always been severely policed, and in fact the party is using the games to instill new ideological vigor int he cadres, as Grishin's most recent remarks show.

If Carter succeeds in his boycott move, and other nations follow the U.S. lead, their absence will reduce the ideological problems.

But a boycott also would deflate Soviet hopes of showcasing the society to the world. in the view of knowledgeable sources here, who have attentively watched the Soviets' painstaking preparation during the past five years the leadership deeply wants the competition to proceed. Hardline figures, such as Grishin, are seen by these sources as warning the people to keep clear, not as warning their leadership colleagues about the mistake of staging the games in the first place.