[eng] Extensive Langevin dynamics simulations are used to characterize the adsorption transition of a flexible magnetic filament grafted onto an attractive planar surface. Our results identify different structural transitions at different ratios of the thermal energy to the surface attraction strength: filament straightening, adsorption, and the magnetic flux closure. The adsorption temperature of a magnetic filament is found to be higher in comparison to an equivalent nonmagnetic chain. The adsorption has been also investigated under the application of a static homogeneous external magnetic field. We found that the strength and the orientation of the field can be used to control the adsorption process, providing a precise switching mechanism. Interestingly, we have observed that the characteristic field strength and tilt angle at the adsorption point are related by a simple power law.