There is an API to define your own magics. See the source code for the jar: ShowEnvsCustomMagicCommand.java.
In [ ]:
%classpath add jar ../resources/jar/loadMagicJarDemo.jar
In [ ]:
%load_magic com.twosigma.beakerx.custom.magic.command.ShowEnvsCustomMagicCommand
In [ ]:
%showEnvs