Skip to main content
Glama

add_video_background_filling

Apply background fill effects to video segments by adding blur or solid color backgrounds to enhance visual composition in video editing workflows.

Instructions

为视频片段添加背景填充效果

Args: video_segment_id: 视频片段ID,通过add_video_segment获得 fill_type: 填充类型,"blur"表示模糊,"color"表示颜色 blur: 模糊程度,范围0.0-1.0,仅在fill_type为"blur"时有效,默认0.0625 剪映中的四档模糊数值分别为0.0625, 0.375, 0.75和1.0 color: 填充颜色,格式为'#RRGGBBAA',仅在fill_type为"color"时有效,默认"#00000000"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
video_segment_idYes
fill_typeYes
blurNo
colorNo#00000000

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNo
messageYes
successYes

Implementation Reference

  • Main tool handler decorated with @mcp.tool(). Handles input validation, retrieves draft/track info, calls service, returns ToolResponse.
    @mcp.tool()
    def add_video_background_filling(
            video_segment_id: str,
            fill_type: str,
            blur: float = 0.0625,
            color: str = "#00000000"
    ) -> ToolResponse:
        """
        为视频片段添加背景填充效果
    
        Args:
            video_segment_id: 视频片段ID,通过add_video_segment获得
            fill_type: 填充类型,"blur"表示模糊,"color"表示颜色
            blur: 模糊程度,范围0.0-1.0,仅在fill_type为"blur"时有效,默认0.0625
                  剪映中的四档模糊数值分别为0.0625, 0.375, 0.75和1.0
            color: 填充颜色,格式为'#RRGGBBAA',仅在fill_type为"color"时有效,默认"#00000000"
        """
        # 参数验证
        if fill_type not in ["blur", "color"]:
            return ToolResponse(
                success=False,
                message=f"无效的填充类型 '{fill_type}',支持的类型: blur, color"
            )
    
        if not (0.0 <= blur <= 1.0):
            return ToolResponse(
                success=False,
                message=f"模糊程度必须在0.0-1.0范围内,当前值: {blur}"
            )
    
        # 通过video_segment_id获取相关信息
        draft_id = index_manager.get_draft_id_by_video_segment_id(video_segment_id)
        track_info = index_manager.get_track_info_by_video_segment_id(video_segment_id)
    
        if not draft_id:
            return ToolResponse(
                success=False,
                message=f"未找到视频片段ID对应的草稿: {video_segment_id}"
            )
    
        if not track_info:
            return ToolResponse(
                success=False,
                message=f"未找到视频片段ID对应的轨道信息: {video_segment_id}"
            )
    
        track_name = track_info.get("track_name")
    
        # 调用服务层处理业务逻辑
        result = add_video_background_filling_service(
            draft_id=draft_id,
            video_segment_id=video_segment_id,
            fill_type=fill_type,
            blur=blur,
            color=color,
            track_name=track_name
        )
    
        return result
  • Service layer function that instantiates VideoSegment and invokes its add_background_filling method to perform the actual background filling operation.
    def add_video_background_filling_service(
        draft_id: str,
        video_segment_id: str,
        fill_type: str,
        blur: float = 0.0625,
        color: str = "#00000000",
        track_name: Optional[str] = None
    ) -> ToolResponse:
        """
        视频背景填充添加服务 - 为视频片段添加背景填充效果
    
        Args:
            draft_id: 草稿ID
            video_segment_id: 视频片段ID
            fill_type: 填充类型,"blur"表示模糊,"color"表示颜色
            blur: 模糊程度,0.0-1.0,仅在fill_type为"blur"时有效,默认0.0625
            color: 填充颜色,格式为'#RRGGBBAA',仅在fill_type为"color"时有效,默认"#00000000"
            track_name: 轨道名称(可选)
    
        Returns:
            ToolResponse: 包含操作结果的响应对象
        """
        try:
            # 创建VideoSegment实例,传入video_segment_id
            video_segment = VideoSegment(draft_id, video_segment_id=video_segment_id, track_name=track_name)
    
            # 调用视频背景填充添加方法
            result_data = video_segment.add_background_filling(
                fill_type=fill_type,
                blur=blur,
                color=color
            )
    
            # 构建返回数据
            response_data = {
                "video_segment_id": video_segment_id,
                "draft_id": draft_id,
                "fill_type": fill_type,
                "blur": blur,
                "color": color,
                "add_background_filling": result_data
            }
    
            # 如果有轨道名称,添加到返回数据中
            if track_name:
                response_data["track_name"] = track_name
    
            return ToolResponse(
                success=True,
                message=f"视频背景填充添加成功: {fill_type}",
                data=response_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)}"
            )
  • The server.py file imports and calls video_tools(mcp), which registers the add_video_background_filling tool along with other video tools via @mcp.tool() decorators.
    from jianyingdraft.tool.video_tool import video_tools
    from jianyingdraft.tool.text_tool import text_tools
    from jianyingdraft.tool.audio_tool import audio_tools
    from jianyingdraft.tool.utility_tool import utility_tools
    
    
    def main():
        # 注册所有工具
        draft_tools(mcp)
        track_tools(mcp)
        video_tools(mcp)
        text_tools(mcp)
        audio_tools(mcp)
        utility_tools(mcp)
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool '添加' (adds) effects, implying mutation, but doesn't clarify permissions, side effects, or what happens to existing background settings. It mentions default values but not rate limits, error conditions, or output format. For a mutation 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 appropriately sized but not optimally structured. The purpose statement is clear, but the parameter explanations are listed without grouping or prioritization. It includes useful details (e.g., Jianying blur values) but could be more front-loaded with critical usage information.

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 4 parameters with 0% schema coverage, no annotations, but an output schema exists, the description partially compensates. It explains parameters well but lacks behavioral context for a mutation tool. The output schema likely covers return values, so description needn't explain those, but it should address permissions, side effects, or error handling more explicitly.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It adds significant semantic value: it explains video_segment_id comes from add_video_segment, defines fill_type options ('blur' and 'color'), specifies blur range (0.0-1.0) with practical examples from Jianying app, and clarifies color format (#RRGGBBAA). However, it doesn't fully cover all 4 parameters' interdependencies beyond conditional validity.

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 tool's purpose: '为视频片段添加背景填充效果' (add background filling effect to video segments). It specifies the verb '添加' (add) and resource '视频片段背景填充效果' (video segment background filling effect). However, it doesn't explicitly differentiate from sibling tools like add_video_filter or add_video_effect, which might also modify video appearance.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a video segment from add_video_segment first), nor does it compare with similar tools like add_video_filter. The only implicit context is the parameter reference to video_segment_id from add_video_segment.

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