这是一个使用json2video API进行视频生成的Model Context Protocol (MCP)服务器实现。此服务器提供了强大的视频生成和状态检查工具,适用于LLMs、代理或任何兼容MCP的客户端。
env JSON2VIDEO_API_KEY=your_api_key_here npx -y @omerrgocmen/json2video-mcp
npm install -g @omerrgocmen/json2video-mcp
如果您在Windows上遇到问题,请尝试:
cmd /c "set JSON2VIDEO_API_KEY=your_api_key_here && npx -y @omerrgocmen/json2video-mcp"
env JSON2VIDEO_API_KEY=your_api_key_here npx -y @omerrgocmen/json2video-mcp{
"mcpServers": {
"json2video-mcp": {
"command": "npx",
"args": ["-y", "@omerrgocmen/json2video-mcp"],
"env": {
"JSON2VIDEO_API_KEY": "your_api_key_here"
}
}
}
}
将your_api_key_here替换为您从json2video.com获取的实际API密钥。
添加后,刷新MCP服务器列表以查看新工具。您的代理或LLM将在适当情况下自动使用json2video MCP,或者您可以明确请求它来描述您的视频生成需求。
将以下内容添加到您的mcp.json或其他配置文件中:
{
"mcpServers": {
"json2video-mcp": {
"command": "npx",
"args": ["-y", "@omerrgocmen/json2video-mcp"],
"env": {
"JSON2VIDEO_API_KEY": "your_api_key_here"
}
}
}
}
your_api_key_here替换为您实际的json2video API密钥。generate_video和get_video_status工具供您在工作流程中使用。JSON2VIDEO_API_KEY(必需):您的json2video API密钥。可以设置为环境变量或每次请求时提供。注意: 如果您遇到“客户端已关闭”的错误,请在终端中运行以下命令:
npm i @omerrgocmen/json2video-mcp
generate_video)创建一个具有场景和元素的可定制视频项目。
描述: 使用json2video API创建一个视频项目。每个项目可以包含多个场景,每个场景可以包含各种元素,如文本、图像、视频、音频、组件、HTML、语音、音图和字幕。视频生成是异步的;使用返回的项目ID检查状态。请参阅https://json2video.com/docs/api/了解完整的模式和更多示例。
输入模式:
{
"id": "string (可选,电影的唯一标识符)",
"comment": "string (可选,项目描述)",
"cache": true,
"client_data": {},
"draft": true,
"quality": "high", // 其中之一:low, medium, high
"resolution": "custom", // 其中之一:sd, hd, full-hd, squared, instagram-story, instagram-feed, twitter-landscape, twitter-portrait, custom
"width": 1920, // 如果分辨率是自定义,则需要
"height": 1080, // 如果分辨率是自定义,则需要
"variables": {},
"elements": [ /* 全局元素,见下文示例 */ ],
"scenes": [
{
"id": "string (可选,唯一的场景ID)",
"comment": "string (可选)",
"background_color": "#000000",
"cache": true,
"condition": "string (可选)",
"duration": -1,
"variables": {},
"elements": [ /* 见下文元素示例 */ ]
}
],
"apiKey": "string (可选)"
}
元素类型及示例:
{
"type": "text",
"text": "Hello world",
"duration": 5,
"settings": { "font-size": "60px", "color": "#FF0000" }
}
{
"type": "image",
"src": "https://images.pexels.com/photos/1105666/pexels-photo-1105666.jpeg",
"width": 1620,
"height": 1080,
"x": 0,
"y": 0
}
{
"type": "video",
"src": "https://example.com/path/to/my/video.mp4",
"duration": 7.3
}
{
"type": "component",
"component": "basic/001",
"settings": {
"headline": { "text": "Lorem ipsum", "color": "white" },
"body": { "text": "Dolor sit amet" }
}
}
{
"type": "html",
"html": "<h1>Hello world</h1>",
"width": 800,
"height": 600
}
{
"type": "audio",
"src": "https://example.com/audio.mp3",
"duration": 5
}
{
"type": "voice",
"text": "This is a voiceover.",
"voice": "en-US-Wavenet-D"
}
{
"type": "audiogram",
"color": "#00FF00",
"amplitude": 5
}
{
"type": "subtitles",
"captions": "1\n00:00:00,000 --> 00:00:02,000\nHello world!"
}
示例输入:
{
"comment": "MyProject",
"resolution": "full-hd",
"scenes": [
{
"elements": [
{ "type": "video", "src": "https://example.com/path/to/my/video.mp4" },
{ "type": "text", "text": "Hello world", "duration": 5 },
{ "type": "image", "src": "https://images.pexels.com/photos/1105666/pexels-photo-1105666.jpeg", "width": 1620, "height": 1080, "x": 0, "y": 0 },
{ "type": "component", "component": "basic/001", "settings": { "headline": { "text": "Lorem ipsum" } } },
{ "type": "html", "html": "<h1>Hello world</h1>", "width": 800, "height": 600 },
{ "type": "audio", "src": "https://example.com/audio.mp3", "duration": 5 },
{ "type": "voice", "text": "This is a voiceover.", "voice": "en-US-Wavenet-D" },
{ "type": "audiogram", "color": "#00FF00", "amplitude": 5 },
{ "type": "subtitles", "captions": "1\n00:00:00,000 --> 00:00:02,000\nHello world!" }
]
}
]
}
用户注意事项:
get_video_status检查视频状态。输出:
get_video_status一起使用。get_video_status)检查视频生成作业的状态或结果。
描述: 检索之前开始的视频生成作业的状态或结果。注意:视频渲染是异步的,可能需要一些时间。如果状态不是“完成”,请稍后再试,使用相同的项目ID。
输入模式:
{
"project": "string (必需)",
"apiKey": "string (可选)"
}
示例输入:
{
"project": "q663vmm2"
}
示例输出:
{
"success": true,
"movie": {
"success": true,
"status": "done",
"message": "",
"project": "q663vmm2",
"url": "https://assets.json2video.com/clients/yourclient/renders/yourvideo.mp4",
"created_at": "2025-04-27T10:44:18.880Z",
"ended_at": "2025-04-27T10:44:28.589Z",
"duration": 11,
"size": 359630,
"width": 640,
"height": 360,
"rendering_time": 10
}
}
create_template)在json2video中创建一个新的模板。
描述: 根据给定的名称和可选描述创建一个新的模板。
输入模式:
{
"name": "string (必需,模板的名称)",
"description": "string (可选,模板的描述)",
"apiKey": "string (可选)"
}
示例输入:
{
"name": "MyTemplate",
"description": "一个可重复使用的视频模板。"
}
输出:
get_template)从json2video获取模板详情。
描述: 根据模板名称检索模板详情。
输入模式:
{
"name": "string (必需,模板的名称)",
"apiKey": "string (可选)"
}
示例输入:
{
"name": "MyTemplate"
}
输出:
{
"updated_at": "YYYY-MM-DDTHH:MM:SSZ",
"created_at": "YYYY-MM-DDTHH:MM:SSZ",
"movie": "{\"id\":\"template1\",\"comment\":\"Example template\",\"resolution\":\"full-hd\",\"quality\":\"high\",\"scenes\":[{\"id\":\"scene1\",\"comment\":\"Scene 1\",\"elements\":[]}],\"elements\":[],\"width\":1920,\"height\":1080}",
"name": "MyTemplate",
"id": "MyTemplate_ID"
}
list_templates)列出json2video中所有可用的模板。
描述: 列出用户可用的所有模板。
输入模式:
{
"apiKey": "string (可选)"
}
示例输入:
{
}
输出:
[
{
"updated_at": "YYYY-MM-DDTHH:MM:SSZ",
"created_at": "YYYY-MM-DDTHH:MM:SSZ",
"movie": "{\"id\":\"template1\",\"comment\":\"Example template\",\"resolution\":\"full-hd\",\"quality\":\"high\",\"scenes\":[{\"id\":\"scene1\",\"comment\":\"Scene 1\",\"elements\":[]}],\"elements\":[],\"width\":1920,\"height\":1080}",
"name": "MyTemplate1",
"id": "TEMPLATE_ID_1"
},
{
"updated_at": "YYYY-MM-DDTHH:MM:SSZ",
"created_at": "YYYY-MM-DDTHH:MM:SSZ",
"movie": "{\"id\":\"template2\",\"resolution\":\"instagram-story\",\"quality\":\"medium\",\"scenes\":[{\"id\":\"scene2\",\"comment\":\"Scene 2\",\"elements\":[]}],\"elements\":[],\"comment\":\"Another template\"}",
"name": "MyTemplate2",
"id": "TEMPLATE_ID_2"
}
]