Both officials spoke on condition of anonymity.
ISAF, the international force in Afghanistan, said the attack took place at a British military training academy in the capital. It said one ISAF service member was killed, without giving details, and the incident was under investigation.
The German military said 14 coalition troops had been wounded, including a German general.
"The wounded German general, whose life is no longer in danger, is being given medical treatment," it said.
Seven other Americans and five British troops were among the wounded, according to the Afghan official.
The Afghan president was quick to condemn the attack, saying the delegation had been visiting the facility to help build Afghanistan's security forces.
"Today at 12pm, a terrorist in army uniform opened fire on international partners and other Afghan officers, wounding several," an Afghan Ministry of Defence statement said.
The gunman was using a light machinegun, according to a US official.
Such attacks have eroded trust between the allies and complicated efforts to train Afghanistan's 350,000-strong security force.
The Taliban says insider attacks reflect their ability to infiltrate the enemy, while ISAF officials say the incidents often arise over misunderstandings or altercations between troops.
In 2012, dozens of incidents forced international troops to take measures to reduce interaction with their Afghan partners and since then, the number of insider attacks has fallen sharply.