According to military officials, Sergeant Melgar was part of a small team in Bamako assigned to help provide intelligence about Islamic militancies in Mali to the United States ambassador there, Paul A. Folmsbee, to protect American personnel against attacks.