An agreement for the United States to arm Somalia in return for use of military and port facilities by American forces has come under sharp criticism in 'kenya, one of Washington's staunchest allies in black Africa.

This is despite Kenyan support for the global purpose of the U. S. policy -- to provide for rapid military deployment in the Indian Ocean region in the event of crises such as the Iranian-Iraqi war.

Like Somalia, Kenya has signed an agreement allowing U.S. forces to use Kenyan air bases and seaports. In return, Kenya is to receive doubled American economic and food aid amounting to about $50 million.

The problem for President Daniel arap Moi is that application of the U.S. policy in East Africa will result in $40 million worth of American arms during the next two years going to Somalia, which lays claim to Kenya's vast northern frontier district. Kenyan officials fear this could lead to a resumption of warfare in the area, which comprises about a third of the Texas-sized country.

From the U.S. point of view, the overall strategy of containing possible Soviet encroachment in the region outweighs the contentious local issue in the Horn of Africa.

Washington has sought to build safeguards into the agreement with Somalia by prohibiting use of the weapons in neighboring countries, but that gives scant reassurance to Kenya.

"We don't trust them," a well-informed Kenyan source said. "We know our neighbors. As soon as the weapons are delivered, they'll be in the Ogaden," the southeastern third of Ethiopia that is also claimed by Somalia. o

Ethiopia, supported by about 13,000 Cuban soldiers, drove the Somalis out of the Ogaden in 1978, but the conflict in the barren desert resumed again this year. Somalia and Kenya also engaged in a sporadic four-year war in the mid-1960s and there have been continued outbursts despite a 1967 peace accord.

Kenya fears that Somali military failures against the Ethiopians, who have received between $1 billion and $2 billion in Soviet arms during the last three years, will cause the Somalis to turn their attention westward to Kenya.

Kenya, a bastion of capitalism in a continent leaning toward socialism, has concentrated on development and done little until recent years to expand its military forces since gaining independence from Britain 17 years ago.

Three years ago, at the peak of the Ogaden war, Kenya turned to the United States to buy 12 5 fighter-bombers. It is also buying 32 attack helicopters.

Informed that the U. S. deal with Somalia includes antiaircraft missiles, a Kenyan source said sardonically:

"That makes it very interesting. You supply us with the planes and the Somalis with equipment to shoot them down."

Unlike Ethiopia, which has launched a diplomatic offensive against the U. S. deal with Somalia, Kenya has not criticized the United States publicly, but officials say Washington is well aware of Kenya's unhappiness.

Kasanga Mulwa, chairman of parliament's defense and foreign relations committee, said last month that he was "alarmed by the continued sale of arms to Somalia. We do not think it is really practical that such a country, which on many occasions has claimed part of our land, can abstain from using these arms for aggression."

A government statement last month expressed "great concern" about the Ogaden fighting and said peace and good-neighborly relations "have been rendered impracticable by the continued state of war forced upon the region by Somalia's policy of 'greater Somalia.'"

This is a reference to Mogadishu's longstanding policy that all Somali-speaking people should be united under one government, meaning it claims hundreds of thousands of square miles in Ethiopia, Kenya and Djibouti, a former French colony at the mouth of the Red Sea. Kenyan officials say Somalia would not need weapons if it abandoned its territorial claims.

The American military aid to Somalia could alienate much of Africa, which generally has agreed that the nations of the continent must accept the old, admittedly imperfect, colonial boundaries to avoid widespread border wars. o

The agreement could also pose a more serious dilemma for the United States since American personnel to be stationed at the Soviet-built Somali port of Berbera on the Gulf of Aden could become embroiled if Ethiopia invaded Somalia.

One difficulty in evaluating the impact of the U.S. agreements to use facilities in Kenya and Somalia, as well as another with Oman near the entrance to the Persian Gulf, is that few details have been made public.

The U.S. Embassy here emphasizes that the agreements do not provide for the establishment of U.S. bases, such as in Europe, but simply for use of air and port facilities.

In Kenya this means use of Mombasa, 2,700 miles from the Persian Gulf, by the expanded U.S. fleet in the Indian Ocean for resupply and as a liberty port for sailors. In addition, U.S. cargo and troop-carrying planes will be allowed to land at Kenyan air bases.

The United States has gained similar rights at Mogadishu and Berbera, 300 miles west of the gulf, where the Soviets established an air and port facility before they abandoned Somalia for Ethiopia in 1977. Berbera is 117 miles from the Ethiopian border. The United States reportedly plans to improve the facilities in this country and Somalia.

It is likely that the United States eventually will seek to station mobile forces in the area.

"What else can a rapid deployment force mean?" a prominent Kenyan journalist asked. "You need to have some presence to make it credible."

He added that the United States was making the same mistake the Soviets did in the 1970s -- thinking they could arm the Somalis but keep them from using the weapons for territorial expansion. The Soviets provided more than $500 million in weapons to Somalia after President Mohammed Said Barre took power in 1969.

Somalia, however, maintains that none of its regular military forces have crossed the Ethiopian or Kenyan borders and that the fighting is carried out by guerrillas of the Somali-supported Western Somalia Liberation Forces.

It would be a rare Kenyan or Ethiopian who would believe that, however.

A House of Representatives subcommittee, approving the first $20 million in arms sales to Somalia, laid down the condition that no equipment would be delivered before "verified assurance" was given that no Somali regular forces remained in the Ogaden.

Kenyan sources say it is impossible to give such an assurance since Somalis not wearing uniforms could not be identified as soldiers. Likewise, they say it would be impossible to prevent the arms from being used outside Somalia.

For Kenya, there is another dimension to the problem of U.S. arms assistance to Somalia. It can hardly afford to move more of its 12,000-member Army to its eastern border to face Somalia -- a country with five times as many soldiers and a wider range of military equipment.

Only Kenya's short border with Sudan is peaceful. Raiders are increasingly coming across the Tanzanian, Ugandan and Ethiopian borders. President Moi recently moved a battalion to the west to guard the Ugandan frontier.

Kenya also has ideological difficulties with Marxist Ethiopia and socialist Tanzania, which wields great influence in Uganda because of the presence there of 10,000 Tanzanian troops.

"We are surrounded by hostile neighbors," a Kenyan said. "Somalia is just the most hostile."