json2video MCP服务器
一种模型上下文协议(MCP)服务器实现,用于使用 json2视频 API此服务器提供强大的视频生成和状态检查工具,供LLM、代理或任何兼容MCP的客户端使用。
______________________________________________________________________
特性
- 生成具有丰富场景和元素支持(文本、图像、视频、音频、组件、字幕等)的视频
- 带有状态轮询的异步视频渲染
- 用于视频项目的灵活、可扩展的JSON模式
- 设计用于与LLM、自动化代理和MCP兼容工具轻松集成
- API密钥身份验证(env或per-request)
- 全面的错误处理和记录
______________________________________________________________________
安装
使用npx运行
env JSON2VIDEO_API_KEY=your_api_key_here npx -y @omerrgocmen/json2video-mcp手动安装
npm install -g @omerrgocmen/json2video-mcpwindows用户
如果您在Windows上遇到问题,请尝试:
cmd /c "set JSON2VIDEO_API_KEY=your_api_key_here && npx -y @omerrgocmen/json2video-mcp"______________________________________________________________________
在游标上运行
光标v0.48.6+
- 打开光标设置
- 转到功能>MCP服务器
- 点击“+添加新MCP服务器”
- 输入以下内容:
- 名称:“json2video-mcp”(或您的首选名称) - 类型:“命令” - 命令: env JSON2VIDEO_API_KEY=your_api_key_here npx -y @omerrgocmen/json2video-mcp
光标v0.48.6+
- 打开光标设置
- 转到功能>MCP服务器
- 点击“+添加新的全局MCP服务器”
- 输入以下代码:
{
"mcpServers": {
"json2video-mcp": {
"command": "npx",
"args": ["-y", "@omerrgocmen/json2video-mcp"],
"env": {
"JSON2VIDEO_API_KEY": "your_api_key_here"
}
}
}
}替换 your_api_key_here 使用您的json2video API密钥。您可以从获取API密钥 jsonvideo.com.
添加后,刷新MCP服务器列表以查看新工具。您的代理或LLM将在适当的时候自动使用json2video MCP,或者您可以通过描述您的视频生成需求来明确请求它。
______________________________________________________________________
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密钥。 - 此配置允许您的代理或LLM自动启动json2video MCP服务器并与之通信。
- 服务器将公开
generate_video和get_video_status工作流程中使用的工具。
______________________________________________________________________
配置
环境变量
JSON2VIDEO_API_KEY(必需):您的json2video API密钥。可以设置为环境变量或根据请求提供。
______________________________________________________________________
注: 如果你遇到client closed错误,请在终端中运行以下命令: ``bash npm i @omerrgocmen/json2video-mcp``
______________________________________________________________________
用法
可用工具
1.生成视频(generate_video)
使用场景和元素创建可定制的视频项目。
说明: 使用json2video API创建视频项目。每个项目可以包含多个场景,每个场景可以包含各种元素,如文本、图像、视频、音频、组件、HTML、语音、音频图和字幕。视频生成是异步的;使用返回的项目ID检查状态。看https://json2video.com/docs/api/查看完整模式和更多示例。
输入架构:
{
"id": "string (optional, unique identifier for the movie)",
"comment": "string (optional, project description)",
"cache": true,
"client_data": {},
"draft": true,
"quality": "high", // one of: low, medium, high
"resolution": "custom", // one of: sd, hd, full-hd, squared, instagram-story, instagram-feed, twitter-landscape, twitter-portrait, custom
"width": 1920, // required if resolution is custom
"height": 1080, // required if resolution is custom
"variables": {},
"elements": [ /* global elements, see below for examples */ ],
"scenes": [
{
"id": "string (optional, unique scene id)",
"comment": "string (optional)",
"background_color": "#000000",
"cache": true,
"condition": "string (optional)",
"duration": -1,
"variables": {},
"elements": [ /* see element examples below */ ]
}
],
"apiKey": "string (optional)"
}元素类型和示例:
- 文本元素:
{
"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" }
}
}- HTML元素:
{
"type": "html",
"html": "
Hello world
",
"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": "
Hello world
", "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!" }
]
}
]
}用户须知:
- 每种元素类型都有自己的必需和可选属性。看https://json2video.com/docs/api/了解全部细节。
- 您可以在场景和全局范围内混合和匹配元素类型。
- 对于自定义分辨率,请同时设置
width和height. - 使用返回的项目ID检查视频状态
get_video_status.
输出:
- 返回要使用的项目ID
get_video_status.
2.获取视频状态(get_video_status)
检查状态或检索视频生成作业的结果。
说明: 检索以前启动的视频生成作业的状态或结果。注意:视频渲染是异步的,可能需要一些时间。如果状态不是“完成”,请稍后使用相同的项目ID重试。
输入架构:
{
"project": "string (required)",
"apiKey": "string (optional)"
}输入示例:
{
"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
}
}3.创建模板(create_template)
在json2video中创建新模板。
说明: 使用给定名称和可选描述创建新模板。
输入架构:
{
"name": "string (required, name of the template)",
"description": "string (optional, description of the template)",
"apiKey": "string (optional)"
}输入示例:
{
"name": "MyTemplate",
"description": "A reusable video template."
}输出:
- 如果成功,则返回模板ID。
4.获取模板(get_template)
从json2video获取模板详细信息。
说明: 按模板名称检索模板的详细信息。
输入架构:
{
"name": "string (required, name of the template)",
"apiKey": "string (optional)"
}输入示例:
{
"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"
}5.列出模板(list_templates)
列出json2video中的所有可用模板。
说明: 列出用户可用的所有模板。
输入架构:
{
"apiKey": "string (optional)"
}输入示例:
{
}输出:
[
{
"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"
}
]