Skip to main content
Glama

add_video_filter

Apply visual filters to video segments in JianYing (CapCut) projects. Specify filter type and intensity to enhance or modify video appearance for professional editing workflows.

Instructions

为视频片段添加滤镜效果

Args: video_segment_id: 视频片段ID,通过add_video_segment获得 filter_type: 滤镜类型名称,可以使用find_effects_by_type工具,资源类型选择filter_type,从而获取滤镜类型有哪些 intensity: 滤镜强度,范围0-100,默认100.0

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
video_segment_idYes
filter_typeYes
intensityNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNo
messageYes
successYes

Implementation Reference

  • MCP tool handler for 'add_video_filter'. Validates parameters, checks filter existence using JianYingResourceManager, retrieves draft_id and track_name from index_manager, and delegates to add_video_filter_service. Registered via @mcp.tool() decorator.
    @mcp.tool()
    def add_video_filter(
            video_segment_id: str,
            filter_type: str,
            intensity: float = 100.0
    ) -> ToolResponse:
        """
        为视频片段添加滤镜效果
    
        Args:
            video_segment_id: 视频片段ID,通过add_video_segment获得
            filter_type: 滤镜类型名称,可以使用find_effects_by_type工具,资源类型选择filter_type,从而获取滤镜类型有哪些
            intensity: 滤镜强度,范围0-100,默认100.0
        """
        # 参数验证
        if not (0.0 <= intensity <= 100.0):
            return ToolResponse(
                success=False,
                message=f"滤镜强度必须在0-100范围内,当前值: {intensity}"
            )
    
        # 滤镜存在性验证
        effects = manager.find_by_type(
            effect_type="filter_type",
            keyword=filter_type,
            limit=1
        )
    
        # 检查是否找到完全匹配的滤镜
        exact_match = False
        if effects:
            for effect in effects:
                if effect.get('name') == filter_type:
                    exact_match = True
                    break
    
        if not effects or not exact_match:
            # 获取建议滤镜
            filter_suggestions = manager.find_by_type("filter_type", keyword=filter_type)
    
            all_suggestions = []
            for effect in filter_suggestions:
                if effect.get('name'):
                    all_suggestions.append(effect.get('name'))
    
            return ToolResponse(
                success=False,
                message=f"未找到滤镜 '{filter_type}',请确认滤镜名称是否正确,或使用建议的滤镜名称。",
                data={
                    "error_type": "filter_not_found",
                    "filter_name": filter_type,
                    "suggestions": all_suggestions
                }
            )
    
        # 通过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_filter_service(
            draft_id=draft_id,
            video_segment_id=video_segment_id,
            filter_type=filter_type,
            intensity=intensity,
            track_name=track_name
        )
    
        return result
  • Helper service function that creates a VideoSegment instance and calls its add_filter method to apply the filter effect to the video segment.
    def add_video_filter_service(
        draft_id: str,
        video_segment_id: str,
        filter_type: str,
        intensity: float = 100.0,
        track_name: Optional[str] = None
    ) -> ToolResponse:
        """
        视频滤镜添加服务 - 为视频片段添加滤镜效果
    
        Args:
            draft_id: 草稿ID
            video_segment_id: 视频片段ID
            filter_type: 滤镜类型名称,如 "亮肤", "复古", "冰雪世界" 等
            intensity: 滤镜强度 (0-100),默认100.0
            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_filter(
                filter_type=filter_type,
                intensity=intensity
            )
    
            # 构建返回数据
            response_data = {
                "video_segment_id": video_segment_id,
                "draft_id": draft_id,
                "filter_type": filter_type,
                "intensity": intensity,
                "add_filter": result_data
            }
    
            # 如果有轨道名称,添加到返回数据中
            if track_name:
                response_data["track_name"] = track_name
    
            return ToolResponse(
                success=True,
                message=f"视频滤镜添加成功: {filter_type} (强度: {intensity})",
                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)}"
            )
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 of behavioral disclosure. The description states it 'adds' filter effects, implying a mutation operation, but doesn't disclose whether this requires specific permissions, whether the operation is reversible, what happens to existing effects, or any rate limits. It mentions parameter sources but lacks behavioral context about the tool's impact or constraints.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded: the first sentence states the purpose clearly, followed by a structured 'Args:' section with bullet points for each parameter. Each sentence earns its place by providing essential information without redundancy. Minor improvement could be made by integrating the purpose more seamlessly with the parameter details.

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

Completeness4/5

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

Given the tool has an output schema (implied by 'Has output schema: true'), the description doesn't need to explain return values. It covers the purpose, parameter semantics, and usage hints adequately. However, as a mutation tool with no annotations, it could benefit from more behavioral context about effects and constraints to reach full completeness.

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 provides meaningful semantics for all three parameters: 'video_segment_id' is explained as obtained from 'add_video_segment', 'filter_type' is linked to 'find_effects_by_type', and 'intensity' specifies a range (0-100) and default (100.0). This adds significant value beyond the bare schema, though it doesn't fully detail format or validation rules.

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 filter effects to video segments). It specifies the verb '添加' (add) and the resource '视频片段' (video segments) with the specific effect type '滤镜效果' (filter effects). However, it doesn't explicitly differentiate from sibling tools like 'add_video_effect' or 'add_video_animation', which reduces it from a perfect score.

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

Usage Guidelines3/5

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

The description provides implied usage guidance by mentioning that 'video_segment_id' should be obtained via 'add_video_segment' and that 'filter_type' can be discovered using 'find_effects_by_type'. However, it doesn't explicitly state when to use this tool versus alternatives like 'add_video_effect' or 'add_video_animation', nor does it provide exclusions or prerequisites beyond parameter sources.

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