This type of thing is most easily done from the TinyMCE editor through a plugin. Details of creating one using WordPress filters can be found here:
http://codex.wordpress.org/TinyMCE_Custom_Buttons
function myplugin_addbuttons() {
// Don't bother doing this stuff if the current user lacks permissions
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
return;
// Add only in Rich Editor mode
if ( get_user_option('rich_editing') == 'true') {
add_filter("mce_external_plugins", "add_myplugin_tinymce_plugin");
add_filter('mce_buttons', 'register_myplugin_button');
}
}
function register_myplugin_button($buttons) {
array_push($buttons, "separator", "myplugin");
return $buttons;
}
// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
function add_myplugin_tinymce_plugin($plugin_array) {
$plugin_array['myplugin'] = URLPATH.'tinymce/editor_plugin.js';
return $plugin_array;
}
// init process for button control
add_action('init', 'myplugin_addbuttons');
The documentation on how to write the required editor_plugin.js file to perform your desired insert will be found on the TinyMCE site:
http://www.tinymce.com/wiki.php/TinyMCE3x:Creating_a_plugin
http://www.tinymce.com/wiki.php/API3:tinymce.api.3.x
http://www.tinymce.com/wiki.php/TinyMCE3x:TinyMCE_3.x
If you really must perform the insert by clicking a button in a meta box, then perhaps a close examination of the Zemanta plugin code will be helpful. Comment on this answer with a link to that plugin if you'd like some help with that.