Shanahan will meet Afghan President Ashraf Ghani, whose government was not part of major talks between the US and Taliban officials last month that officials hope could bring a breakthrough in the 17-year conflict.
“It is important that the Afghan government is involved in discussions regarding Afghanistan,” Shanahan told a small group of reporters travelling with him on the surprise trip on Monday.
The acting Pentagon chief said Washington has important security interests in the region and wanted to hear from the commanders on the ground.
Shanahan replaced Jim Mattis, who quit in December over policy differences with US President Donald Trump.
The Taliban has refused to negotiate directly with Ghani’s government, calling it a “puppet” of the West. But Ghani’s allies in Washington insist Afghans should lead the peace process.
Kabul is also concerned that a sharp withdrawal of the nearly 14,000 US troops in Afghanistan could lead to chaos in the region.
The Taliban wants all American troops withdrawn, and officials say that is at the top of the armed group’s list of demands in exploratory talks.
Shanahan, who will also meet US commanders, told reporters he had so far not received any direction to reduce troops in Afghanistan.
Al Jazeera’s Tony Birtley, reporting from Kabul, said Shanahan’s trip was “a fact-finding mission”.
“His views on Afghanistan are not widely known, and he is expected to make them known after this visit,” Birtley added. “His comments on Afghan government’s involvement in peace talks is important for the government because they feel sidelined by the US-led talks.”
Zalmay Khalilzad, the Trump administration’s special envoy for Afghan peace talks, said on Friday that although peace talks with the Taliban are in an early stage, he hopes a deal can be made by July.
That is when Afghanistan is scheduled to hold a presidential election.
Since being appointed last September as the US special representative for Afghan reconciliation, Khalilzad has carried out a number of rounds of talks with the Taliban and other regional representatives in Afghanistan, Pakistan, the United Arab Emirates, India, Russia, Uzbekistan, Turkmenistan, Saudi Arabia, and Qatar.
The US envoy’s most recent talks were in Doha late last month where the two sides met for six days.
Washington wants assurances that Afghanistan will not harbour groups that would use the country as a base to launch attacks on the US.
The next round of talks is due in Qatar on February 25.
In December, there were numerous reports that Trump planned to halve the number of US forces in Afghanistan. In his State of the Union address last week, the US president said any troop pullout would be linked to progress in peace talks.
General Joseph Votel, the commander of US Central Command, appearing before Congress last week, offered a largely optimistic view of Afghanistan, saying the current manoeuvring between the US and Taliban negotiators is “our first real opportunity for peace and reconciliation since the war began”.
Votel noted that the Taliban are still capable of inflicting significant casualties on Afghan government forces.
Just last week, Taliban fighters killed some two dozen Afghan troops in an attack on an army base in northern Kunduz province.
In addition to battling the Taliban, the US and coalition forces in Afghanistan are focussed on an affiliate of the Islamic State of Iraq and the Levant (ISIL, or ISIS), known as ISIS-Khorasan, comprised of foreign fighters largely from Pakistan.