Horntails are fairly large (half an inch to two inches), cylindrically shaped, solitary  wasps found in forested areas. While they might look intimidating with that “spike” on the end, they are harmless. Females use the spike (their ovipositor) to insert their eggs into wood. The emerging larvae are wood borers and develop inside dead and dying trees. Ichneumon wasps in the genus Megarhyssa also lay their eggs deep within trees, but their larvae are not after wood, instead they parasitize the horntail larvae. There are 14 different species found across the Pacific Northwest (including western Montana). It’s hard to say what exact species this is without seeing more detail, but with the smoky / amber-colored wings, a guess is Urocerus californicus
Photo by Nicole Sarrazin on 8/12/20 in Missoula, MT.