Reprogramming a chip over JTAG/SWD from another mbed board?

Is there an existing mbed API or library to reprogram another board over jtag or swd, from another mcu running mbed?

Can I use SPI to sorta emulate JTAG?