To a large class of graphs of groups we associate a C⁎-algebra universal for generators and relations. We show that this C⁎-algebra is stably isomorphic to the crossed product induced from the action of the fundamental group of the graph of groups on the boundary of its Bass–Serre tree. We characterise when this action is minimal, and find a sufficient condition under which it is locally contractive. In the case of generalised Baumslag–Solitar graphs of groups (graphs of groups in which every group is infinite cyclic) we also characterise topological freeness of this action. We are then able to establish a dichotomy for simple C⁎-algebras associated to generalised Baumslag–Solitar graphs of groups: they are either a Kirchberg algebra, or a stable Bunce–Deddens algebra.