Skip to main content
Glama

create_track

Add video, audio, or text tracks to JianYing (CapCut) video drafts for organizing media segments in professional editing workflows.

Instructions

创建轨道 Args: draft_id: 草稿ID track_type: 轨道类型,支持 "video", "audio", "text", 一个轨道可以有多个素材,如video轨道想添加两个视频,使用同一个track_id就可以 track_name: 轨道名称,同类型轨道名不能相同

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
draft_idYes
track_typeYes
track_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNo
messageYes
successYes

Implementation Reference

  • MCP tool handler 'create_track' that calls the service layer to create the track and updates the index manager.
    @mcp.tool()
    def create_track(draft_id: str, track_type: str, track_name: str)-> ToolResponse:
        """
        创建轨道
        Args:
            draft_id: 草稿ID
            track_type: 轨道类型,支持 "video", "audio", "text",
                    一个轨道可以有多个素材,如video轨道想添加两个视频,使用同一个track_id就可以
            track_name: 轨道名称,同类型轨道名不能相同
        """
        # 调用服务层处理业务逻辑
        result = create_track_service(draft_id, track_type, track_name)
    
        # 如果轨道创建成功,添加索引记录
        if result.success and result.data and "track_id" in result.data:
            track_id = result.data["track_id"]
            index_manager.add_track_mapping(track_id, draft_id, track_name, track_type)
    
        return result
  • Registers the track tools module containing the create_track tool.
    track_tools(mcp)
  • Service layer function that creates the Track instance and calls add_track, handling errors and returning ToolResponse.
    def create_track_service(draft_id: str, track_type: str, track_name: Optional[str] = None) -> ToolResponse:
        """
        轨道创建服务 - 封装复杂的轨道创建逻辑
        
        Args:
            draft_id: 草稿ID
            track_type: 轨道类型 ("video", "audio", "text")
            track_name: 轨道名称(可选)
        
        Returns:
            ToolResponse: 包含操作结果的响应对象
        """
        try:
            # 创建Track实例
            track = Track(draft_id)
            
            # 调用轨道创建方法
            track_id = track.add_track(track_type, track_name)
            
            # 构建返回数据
            result_data = {
                "track_id": track_id,
                "draft_id": draft_id,
                "track_type": track_type
            }
            
            # 如果有轨道名称,添加到返回数据中
            if track_name:
                result_data["track_name"] = track_name
            
            return ToolResponse(
                success=True, 
                message="轨道创建成功", 
                data=result_data
            )
            
        except ValueError as e:
            # 处理轨道类型无效或轨道名称格式错误
            return ToolResponse(
                success=False, 
                message=f"参数错误: {str(e)}"
            )
            
        except NameError as e:
            # 处理轨道名称已存在或同类型轨道需要指定名称
            return ToolResponse(
                success=False, 
                message=f"轨道冲突: {str(e)}"
            )
            
        except Exception as e:
            # 处理其他未预期的错误
            return ToolResponse(
                success=False, 
                message=f"轨道创建失败: {str(e)}"
            )
  • Core Track class method add_track that validates inputs, generates track_id, builds JSON data, and persists to file.
    def add_track(self, track_type: str, track_name: Optional[str] = None) -> str:
        """
        添加轨道
    
        Args:
            track_type: 轨道类型,如 "video", "audio", "text"
            track_name: 轨道名称(可选)
    
        Returns:
            str: 轨道ID
    
        Raises:
            ValueError: 轨道类型无效或轨道名称格式错误
            NameError: 轨道名称已存在或同类型轨道需要指定名称
        """
        # 1. 验证轨道类型
        self._validate_track_type(track_type)
    
        # 2. 验证轨道唯一性
        self._validate_track_uniqueness(track_type, track_name)
    
        track_id = str(uuid.uuid4())
    
        # 构建轨道数据
        add_track_params = {
            "track_type": track_type
        }
    
        # 只添加用户明确传入的可选参数
        if track_name:
            add_track_params["track_name"] = track_name
    
        # 构建完整的轨道数据
        track_data = {
            "track_id": track_id,
            "operation": "add_track",
            "add_track": add_track_params,
            "created_at": datetime.now().isoformat()
        }
    
        # 保存参数
        self.add_json_to_file(track_data)
        self.track_id = track_id
        return track_id
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states that a track can have multiple materials using the same track_id, which adds useful context about behavior. However, it lacks critical details: whether this is a mutation (implied by 'create'), what permissions are needed, what happens on failure, or what the output contains. For a creation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief and structured with an 'Args:' section, which is helpful. However, it includes an extra sentence about multiple materials that, while informative, could be more integrated. It's front-loaded with the purpose but could be more streamlined.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 3 parameters with 0% schema coverage and no annotations, the description adds basic semantics but lacks depth. An output schema exists, so return values needn't be explained. However, for a creation tool in a media editing context, more behavioral context (e.g., error handling, dependencies) would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter descriptions. The description adds meaningful semantics: draft_id is a '草稿ID' (draft ID), track_type supports specific values ('video', 'audio', 'text') and explains that multiple materials can use the same track_id, and track_name must be unique within the same type. This compensates partially but doesn't cover all aspects (e.g., format of draft_id, constraints on track_name).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('创建轨道' means 'create track') and identifies the resource (a track within a draft). It distinguishes from siblings by focusing on track creation rather than effects, segments, or other operations. However, it doesn't explicitly differentiate from potential similar tools like 'create_draft' beyond the resource scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives is provided. The description mentions that track names must be unique within the same type, which is a constraint but not usage guidance. There's no mention of prerequisites (e.g., needing an existing draft) or comparisons to sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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