Eddy currents are generated in MR by the use of rapidly switched electromagnets, resulting in time varying and spatially varying magnetic fields that must be either minimized or corrected. This problem is further complicated when non-cylindrical insert magnets are used for specialized applications. Interruption of the coupling between an insert coil and the MR system is typically accomplished using active magnetic shielding. A new method of actively shielding insert gradient and shim coils of any surface geometry by use of the boundary element method for coil design with a minimum energy constraint is presented. This method was applied to shield x- and z-gradient coils for two separate cases: a traditional cylindrical primary gradient with cylindrical shield and, to demonstrate its versatility in surface geometry, the same cylindrical primary gradients with a rectangular box-shaped shield. For the cylindrical case this method produced shields that agreed with analytic solutions. For the second case, the rectangular box-shaped shields demonstrated very good shielding characteristics despite having a different geometry than the primary coils.