UNPKG

@kolbo/mcp

Version:

Kolbo AI MCP Server - Generate images, videos, music, speech, and sound effects from Claude Code

253 lines (239 loc) • 13.9 kB
'use strict'; /** * Public MCP safety contract. * * ChatGPT app review requires every exposed tool to declare all three hints. * Keep this map exact: the submission gate rejects missing, duplicate, stale, * or non-boolean entries whenever the registered tool surface changes. */ const READ_ONLY = [ 'get_video_inspection', 'get_flow_schema', 'list_flow_sessions', 'get_flow_session', 'validate_flow_session', 'estimate_flow_run', 'get_flow_run', 'list_flow_runs', 'list_morphious_styles', 'list_avatars', 'get_avatar', 'list_avatar_scene_presets', 'get_avatar_video', 'list_avatar_stock_voices', 'list_avatar_lipsync_models', 'list_avatar_stock_presenters', 'list_trends', 'get_trend', 'estimate_trend_run', 'get_trend_run', 'list_trend_runs', 'get_download_status', 'get_video_editor_schema', 'list_video_editor_sessions', 'get_video_editor_session', 'list_fonts', 'get_font', 'get_font_upload_status', 'get_creative_director_status', 'get_generation_status', 'list_models', 'list_music_personas', 'check_credits', 'show_plans', 'get_session_usage', 'list_voices', 'chat_list_conversations', 'chat_get_messages', 'list_visual_dnas', 'get_visual_dna', 'list_visual_dna_folders', 'list_moodboards', 'get_moodboard', 'list_color_palettes', 'list_media', 'list_media_folders', 'get_media', 'get_media_stats', 'list_presets', 'list_cinematic_presets', 'list_projects', 'get_project', 'get_project_publication', 'list_sessions', 'list_project_context', 'get_project_profile', 'get_project_brain', 'search_brain_memory', 'list_retired_brain_rules', 'list_brain_playbooks', 'get_brain_playbook', // Returns a draft without saving it. 'get_project_story', 'draft_project_story', 'get_project_page_insights', 'list_project_assets', 'list_project_transfers', 'list_visual_dna_transfers', 'list_session_generations', 'list_agents', 'list_skills', 'list_docs', 'get_doc', 'get_review_storage_usage', 'list_review_assets', 'get_review_asset', 'list_review_collections', 'list_review_comments', 'list_review_share_links', 'get_review_grading', 'get_review_comment_mask', 'get_review_shot_votes', // Free (no credits, no DB write) — returns a scratch composition plan for the caller to edit. 'create_music_composition_plan', // Social Planner reads of our own queue, automations and posts. 'list_social_accounts', 'get_social_capabilities', 'get_social_queue', 'get_social_best_times', 'list_social_automations', 'get_social_automation_hits', 'list_social_posts', 'list_social_automation_templates', 'list_social_contacts', 'get_social_automation_logs', 'get_social_broadcast', ]; const OPEN_WORLD_READ_ONLY = [ // Reads public source media into private ephemeral scratch evidence, no library writes. 'prepare_video_inspection', 'inspect_video', 'blender_list_sessions', 'blender_get_scene', 'blender_search_docs', 'blender_get_command_status', 'adobe_list_sessions', 'adobe_get_project', 'adobe_get_timeline', 'adobe_get_command_status', 'davinci_list_sessions', 'davinci_get_project', 'davinci_get_timeline', 'davinci_get_command_status', // Social Planner reads that call the platform (account health, comments, inbox, metrics). 'check_social_account', 'get_tiktok_creator_info', 'list_social_comments', 'list_social_conversations', 'get_social_conversation', 'get_social_post_metrics', 'get_social_account_metrics', 'list_pinterest_boards', // Call third-party AI models or external catalogs (Pexels, Pixabay, Sketchfab, SYNCI). 'analyze_color_palette', 'quote_avatar_video', 'analyze_script_for_music', 'analyze_script_for_stock', 'search_stock_media', 'get_stock_sources', 'get_stock_categories', 'get_stock_collections', 'get_stock_asset', 'synci_search', 'synci_browse', 'synci_facets', 'synci_track_audio', 'synci_track_related', 'synci_track_lyrics', ]; const PRIVATE_WRITE = [ 'create_flow_session', 'duplicate_flow_session', 'move_flow_session', 'restore_flow_session', 'upload_font', 'rename_font', 'create_font_upload_ticket', 'font_upload_widget', 'create_video_editor_session', 'media_upload_widget', 'create_upload_ticket', 'favorite_media', 'unfavorite_media', 'dislike_media', 'undislike_media', 'rate_media', 'clear_media_rating', 'add_brain_rule', 'learn_from_feedback', 'move_brain_rule', 'restore_brain_rule', 'create_media_folder', 'update_media_folder', 'add_media_to_folder', 'remove_media_from_folder', 'share_media_folder', 'restore_media', 'move_media', 'bulk_restore_media', 'bulk_move_media', 'move_folder_contents', 'create_visual_dna_folder', 'update_visual_dna_folder', 'move_visual_dna_to_folder', 'create_morphious_style', 'create_music_persona', 'create_color_palette', 'activate_color_palette', 'deactivate_color_palette', 'move_session', 'bulk_move_sessions', 'move_generations_to_session', 'split_session', 'undo_session_organization', 'rename_session', 'restore_session', 'create_project', 'duplicate_project', 'archive_project', 'unarchive_project', 'link_project_asset', 'unlink_project_asset', 'create_agent', 'create_skill', 'create_doc', 'create_review_asset', 'update_review_asset', 'add_review_version', 'set_review_status', 'create_review_collection', 'update_review_collection', 'create_review_comment', 'reply_review_comment', 'resolve_review_comment', 'unresolve_review_comment', 'set_review_mark', 'set_review_shot_vote', 'create_review_album', // Social Planner contact tags stay in Kolbo; nothing reaches the platform. 'tag_social_contact', ]; const DESTRUCTIVE_WRITE = [ 'update_flow_session', 'undo_flow_edit', 'trash_flow_session', 'run_flow_session', 'cancel_flow_run', 'retry_flow_run', 'cancel_trend_run', 'cancel_download', // Can cancel (delete) an unfinished large upload. 'finish_large_upload', 'update_video_editor_session', 'delete_font', 'export_video_editor_session', // These actions spend credits, enqueue irreversible work, or cancel it. 'cancel_generation', 'cancel_avatar_video', 'trim_video', 'cancel_video_inspection', // Deletes and whole-value replacement updates are conservatively destructive. 'delete_voice', 'delete_visual_dna', 'delete_visual_dna_folder', 'delete_moodboard', 'delete_morphious_style', 'delete_avatar', 'remove_avatar_scene', 'remove_avatar_look', 'pick_avatar_portrait', 'update_color_palette', 'delete_color_palette', 'delete_media_folder', 'delete_media', 'permanently_delete_media', 'bulk_delete_media', 'bulk_permanently_delete_media', 'unshare_media_folder', 'delete_session', 'delete_project_context', 'regenerate_project_profile', 'delete_brain_rule', 'save_brain_playbook', 'delete_brain_playbook', 'update_project_asset', 'update_brain_rule', // Ownership hand-off: the sender loses the project (and maybe all access) on accept. 'transfer_project', 'respond_project_transfer', // A move (keep_sender_copy:false) trashes the sender's originals on accept. 'transfer_visual_dna', 'respond_visual_dna_transfer', 'update_agent', 'delete_agent', 'update_skill', 'delete_skill', 'update_doc', 'delete_doc', 'delete_review_asset', 'delete_review_collection', 'edit_review_comment', 'delete_review_comment', // Replaces project fields (name, cover, settings) with no undo. 'update_project', ]; const OPEN_WORLD_WRITE = [ 'download_media_from_url', 'import_music_audio', 'publish_html_artifact', 'create_review_share_link', 'blender_capture_viewport', // Public showcase link for a project / catalog submission. 'publish_project', 'submit_project_to_catalog', // Adobe edits add bins, clips, sequences or caption tracks; none delete or overwrite. 'adobe_import_media', 'adobe_place_on_timeline', 'adobe_create_sequence', 'adobe_import_captions', 'adobe_capture_frame', // Resolve imports add Media Pool items; captures add a Kolbo library image. 'davinci_import_media', 'davinci_capture_frame', // Social Planner: posts, replies and messages go out on the user's own accounts. 'connect_social_account', 'publish_social_post', 'cross_post_social', 'retry_social_post', 'reply_social_comment', 'send_social_message', 'create_social_automation', 'update_social_automation', 'update_social_post', // Previews by default; with confirm: true sends DMs to many contacts. 'create_social_broadcast', // Reading a post that is still processing moves it forward on the platform. 'get_social_post', // Send media or prompts to third-party AI providers (avatars, voices, analysis) or fetch external media. 'upload_media', 'import_stock_asset', 'import_elevenlabs_voice', 'create_moodboard', 'add_project_context', 'remove_project_hero_video', 'create_avatar', 'add_avatar_scene', 'create_avatar_video', 'regenerate_avatar_portraits', 'remove_avatar_video_background', 'preview_avatar_scene', 'preview_avatar_speech', 'talking_photo', ]; const OPEN_WORLD_DESTRUCTIVE = [ 'share_doc', 'revoke_review_share_link', 'unpublish_project', // Replaces the whole story; live on the public page when the project is published. 'update_project_story', 'blender_apply_operations', 'blender_import_media', 'blender_render', 'blender_undo', 'blender_file_operation', 'blender_execute_python', // Can delete layers; approved once per batch in the Kolbo panel. 'adobe_edit_composition', 'adobe_run_script', // Can delete timeline clips; approved once per batch in the Kolbo plugin. 'davinci_edit_timeline', 'davinci_run_script', // Social Planner: removes posts, comments, connections or automations. 'revoke_social_calendar_feed', 'disconnect_social_account', 'delete_published_social_post', 'moderate_social_comment', 'delete_social_automation', 'cancel_social_post', 'cancel_social_broadcast', 'stop_social_post_repeat', // Spend credits on third-party AI model providers (OpenAI, Google, Kling, Suno, ElevenLabs...). 'generate_image', 'generate_image_edit', 'generate_creative_director', 'generate_video', 'generate_video_from_image', 'generate_music', 'generate_speech', 'generate_sound', 'create_music_reference_audio', 'edit_music_section', 'extend_music', 'cover_music', 'add_vocals', 'add_instrumental', 'replace_music_section', 'export_music_wav', 'make_music_video', 'generate_music_midi', 'get_timed_lyrics', 'generate_elements', 'generate_first_last_frame', 'generate_lipsync', 'generate_video_from_video', 'transcribe_audio', 'generate_3d', 'image_tools', 'video_tools', 'clone_voice', 'chat_send_message', 'generate_character_sheet', 'synci_acquire_track', 'synci_import_track', 'separate_audio_stems', 'clean_dialogue_leftovers', 'separate_ambience', 'analyze_video', 'analyze_audio', 'change_voice', 'analyze_extracted_clip', 'transcribe_extracted_clip', 'run_trend', 'create_visual_dna', 'update_visual_dna', 'update_moodboard', 'update_avatar', // The feed URL is public and the queue rewrite replaces the posting schedule. 'create_social_calendar_feed', 'set_social_queue', // Makes a paid look sheet; calling again with look_id replaces it. 'add_avatar_look', ]; const SOCIAL_TOOLS = [READ_ONLY, OPEN_WORLD_READ_ONLY, PRIVATE_WRITE, OPEN_WORLD_WRITE, OPEN_WORLD_DESTRUCTIVE] .flat().filter((name) => /social|tiktok_creator|pinterest/.test(name)); const CONTRACT_GROUPS = [ [READ_ONLY, { readOnlyHint: true, openWorldHint: false, destructiveHint: false }], [OPEN_WORLD_READ_ONLY, { readOnlyHint: true, openWorldHint: true, destructiveHint: false }], [PRIVATE_WRITE, { readOnlyHint: false, openWorldHint: false, destructiveHint: false }], [DESTRUCTIVE_WRITE, { readOnlyHint: false, openWorldHint: false, destructiveHint: true }], [OPEN_WORLD_WRITE, { readOnlyHint: false, openWorldHint: true, destructiveHint: false }], [OPEN_WORLD_DESTRUCTIVE, { readOnlyHint: false, openWorldHint: true, destructiveHint: true }], ]; function buildToolAnnotations() { const annotations = Object.create(null); for (const [names, hints] of CONTRACT_GROUPS) { for (const name of names) { if (annotations[name]) throw new Error(`Duplicate safety annotation contract for tool: ${name}`); annotations[name] = Object.freeze({ ...hints }); } } return Object.freeze(annotations); } const TOOL_ANNOTATIONS = buildToolAnnotations(); // Human-readable titles for tools whose names OpenAI's scan found unclear. const TOOL_TITLES = Object.freeze({ generate_creative_director: 'Generate a set of images or videos from one brief', generate_elements: 'Generate a video from reference images, videos or audio', generate_first_last_frame: 'Generate a video between a start frame and an end frame', }); function attachToolAnnotations(server) { const registered = server?._registeredTools || {}; const registeredNames = Object.keys(registered).sort(); const contractNames = Object.keys(TOOL_ANNOTATIONS).sort(); const missing = registeredNames.filter((name) => !TOOL_ANNOTATIONS[name]); // Tools a server PROFILE may legitimately leave unregistered. show_plans is // dropped under `commerce: false` (the ChatGPT app profile — OpenAI forbids // selling digital goods there); its contract row stays for every other host. // The Social Planner tools are dropped under `socialPlanner: false` (accounts with no open platform). const PROFILE_OPTIONAL = new Set(['show_plans', ...SOCIAL_TOOLS]); const stale = contractNames.filter((name) => !registered[name] && !PROFILE_OPTIONAL.has(name)); if (missing.length || stale.length) { throw new Error( `Tool annotation contract mismatch. Missing: ${missing.join(', ') || 'none'}. ` + `Stale: ${stale.join(', ') || 'none'}.` ); } for (const name of registeredNames) { registered[name].annotations = TOOL_ANNOTATIONS[name]; if (TOOL_TITLES[name] && !registered[name].title) registered[name].title = TOOL_TITLES[name]; } } module.exports = { TOOL_ANNOTATIONS, CONTRACT_GROUPS, attachToolAnnotations, };