Skip to main content
Glama

create_draft

Create a new video editing project draft in JianYing (CapCut) with customizable resolution and frame rate settings for professional video production workflows.

Instructions

创建草稿

Args: draft_name: str 草稿名称 width: int,视频宽度,默认1920 height: int,视频高度,默认1080 fps: int,帧率,默认30

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
draft_nameYes
widthNo
heightNo
fpsNo

Implementation Reference

  • The core handler function for the 'create_draft' MCP tool. Decorated with @mcp.tool(), it creates a unique draft ID, sets up the draft directory and JSON file with metadata (name, dimensions, FPS), and registers the draft in the index_manager.
    def create_draft(draft_name: str, width: int = 1920, height: int = 1080, fps: int = 30): """ 创建草稿 Args: draft_name: str 草稿名称 width: int,视频宽度,默认1920 height: int,视频高度,默认1080 fps: int,帧率,默认30 """ # 验证SAVE_PATH是否存在 if not os.path.exists(SAVE_PATH): raise FileNotFoundError(f"草稿存储路径不存在: {SAVE_PATH}") # 生成草稿ID draft_id = str(uuid.uuid4()) # 构建完整的草稿路径 draft_path = os.path.join(SAVE_PATH, draft_id) # 创建草稿数据 draft_data = { "draft_id": draft_id, "draft_name": draft_name, "width": width, "height": height, "fps": fps } # 在SAVE_PATH下创建以草稿ID命名的文件夹 os.makedirs(draft_path, exist_ok=True) # 保存draft.json文件 draft_json_path = os.path.join(draft_path, "draft.json") with open(draft_json_path, "w", encoding="utf-8") as f: json.dump(draft_data, f, ensure_ascii=False, indent=4) # 添加草稿索引记录 draft_info = { "draft_name": draft_name, "created_time": datetime.datetime.now().isoformat(), "width": width, "height": height, "fps": fps } index_manager.add_draft_mapping(draft_id, draft_info) return draft_data
  • Registers the draft_tools (which includes create_draft) by calling draft_tools(mcp) in the main server entrypoint.
    def main(): # 注册所有工具 draft_tools(mcp) track_tools(mcp) video_tools(mcp) text_tools(mcp) audio_tools(mcp) utility_tools(mcp)
  • The draft_tools function that registers multiple draft-related tools, including create_draft, to the FastMCP instance.
    def draft_tools(mcp: FastMCP):
  • The 'rules' tool provides guidelines for using create_draft as the first step in the video creation workflow.
    """制作视频的规范,这一步必须执行,方便了解如何规范的使用工具制作视频""" prompt = """ 核心工作原则 1.询问用户应当怎么制作视频,有什么建议,你可以使用parse_media_info(了解素材信息),然后不断地向用户询问制作视频的细节,在制作前,你应该向用户说明你准备怎么制作视频,用户没有意见后才开始制作视频 2. 严格遵循操作流程 必须按照以下顺序执行,不可跳步骤: 创建草稿 → create_draft 创建轨道 → create_track(根据需要创建video、audio、text轨道) 添加素材 → add_*_segment(添加视频、音频、文本片段) 查询特效 → find_effects_by_type(查找可用特效) 应用特效 → add_*_effect/animation(添加各种特效和动画) 导出草稿 → export_draft 3. ID管理规则 draft_id:创建草稿后获得,用于所有后续操作 track_id:创建轨道后获得,用于添加对应类型的素材 segment_id:添加素材后获得,用于添加特效和动画 严格保存和传递这些ID,它们是工具链的关键纽带 4.轨道规则 一般情况下同类型的轨道只需要一个就可以,除非需要画中画等复杂情况才会创建多个同类型的轨道 5.时长规则 在规划视频、音频时长时,必须从素材本身时长出发,使用本身的时长,切记不能超出素材本身时长 注意素材的总时长,在传入target_timerange参数时,所占的轨道时长不能超过素材总时长,不能因为其他原因使得轨道时长超过素材时长,例如当视频总时长5s,音频时长为4.2s,不能因为视频比音频时间长,就改变音频轨道时长,即音频可传入的最大时长为4.2s 添加素材的add_audio_segment和add_video_segment工具中,target_timerange参数描述的是轨道上的时间范围,同一轨道中不可有重复时间段,即0s-4.2s和4s-5s,第一段素材最后0.2s与第二段素材重叠了,只能是0s-4.2s和4.ss-5s 添加素材的add_audio_segment和add_video_segment工具中,source_timerange参数描述的是素材本身取的时长,默认取全部时长,一般情况下不设置,除非用户说明,若素材时长为5s,用户需要取其中1s-5s的内容,才配置 6.其他 add_text_segment工具其中的参数clip_settings的transform_y,强烈建议修改为-0.7(这样字幕是在正下方,不影响视频观感) 特效不存在:查看建议列表,选择相似特效 时间冲突:调整时间范围,查看素材时间以及工具参数 添加转场:若三个视频间需要添加转场,那转场应该添加在第一个和第二个视频后添加转场,而非第二个和第三个视频里 """

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hey-jian-wei/jianying-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server