Surface currents provide a general way to model magnetic fields in source-free volumes. To facilitate the use of surface currents in magneto-quasistatic problems, we have implemented a set of computational tools in a Python package named bfieldtools. In this work, we describe the physical and computational principles of this toolset. To be able to work with surface currents of the arbitrary shape, we discretize the currents on triangle meshes using piecewise-linear stream functions. We apply analytical discretizations of integral equations to obtain the magnetic field and potentials associated with the discrete stream function. In addition, we describe the computation of the spherical multipole expansion and a novel surface-harmonic expansion for surface currents, both of which are useful for representing the magnetic field in source-free volumes with a small number of parameters. Lastly, we share examples related to magnetic shielding and the surface-coil design using the presented tools.