But Mr. Cotton serves another important function as a bellwether for perhaps the president’s most important focus group: the Republican majority in the Senate, consisting largely of members who still publicly support him but are growing increasingly impatient with the delays and distractions in passing an agenda.

The political math for them is clear: The longer it takes to show tangible results, the greater the electoral peril.

Mr. Cotton was one of the Republicans who grilled the former director of the F.B.I., James B. Comey, during a Senate Intelligence Committee hearing on Thursday. The senator avoided sounding as if he was trying to curry favor with Mr. Trump, asking whether the president’s former national security adviser, Michael T. Flynn, had not been truthful with federal investigators.

Mr. Cotton has had more impact than many other Republicans in getting through to the president, including his recommending General McMaster and suggesting that the Trump team take a look at John F. Kelly, who is now the Department of Homeland Security secretary.

The Arkansas senator was not a Trump supporter during the campaign, but he also was not an opponent — a significant distinction in an administration in which an errant tweet or a bit of cable commentary can ice out prospective allies forever. They spoke occasionally during the campaign, and Mr. Cotton attended a meeting before the election where prospective Supreme Court nominees were discussed.

Since then, his counsel has been sought more frequently.

Mr. Cotton’s foreign policy instincts align more closely with a frequent Trump critic: Senator John McCain, Republican of Arizona. But his immigration views, in particular, are in sync with the president’s.

“The president and I tend to agree on some issues that are not what you’d call Republican orthodoxy,” Mr. Cotton said of their shared impulses. He mentioned an immigration-restricting bill that he and Senator David Perdue, Republican of Georgia, have sponsored as an example.