Skip to main content
Glama
jneless
by jneless

tos_video_snapshot

Extract frames from videos stored in TOS at specific timestamps and save them as images in designated buckets for analysis or processing.

Instructions

视频截帧(支持持久化)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes存储桶名称
formatNo输出格式jpg
object_keyYes视频对象键名
save_bucketYes保存截帧图片的存储桶名称
save_keyYes保存截帧图片的对象键名
timeNo截帧时间点(毫秒),如300表示第300毫秒

Implementation Reference

  • The core handler function `video_snapshot` that implements the `tos_video_snapshot` tool logic. It constructs a video processing parameter, performs the snapshot using TOS SDK's get_object with process and save parameters, waits for completion, generates a presigned URL for the resulting image, and returns the result.
    async def video_snapshot(args: Dict[str, Any]) -> List[TextContent]:
        """视频截帧(支持持久化)"""
        bucket_name = args["bucket_name"]
        object_key = args["object_key"]
        time = args.get("time", 300)
        format = args.get("format", "jpg")
        save_bucket = args["save_bucket"]
        save_key = args["save_key"]
        
        try:
            # 构建视频截帧处理参数,时间单位为毫秒
            process = f"video/snapshot,t_{int(time)},f_{format}"
            
            # 使用官方SDK写法,通过save_bucket和save_object参数执行视频截帧和持久化
            resp = tos_client.get_object(
                bucket=bucket_name,
                key=object_key,
                process=process,
                save_bucket=base64.b64encode(save_bucket.encode("utf-8")).decode("utf-8"),
                save_object=base64.b64encode(save_key.encode("utf-8")).decode("utf-8")
            )
            
            # 读取处理结果以确保截帧完成
            processed_data = resp.read()
            
            # 等待一下确保回写完成
            import time as time_module
            time_module.sleep(1.0)
            
            # 生成截帧图片的预签名 URL
            download_url = tos_client.pre_signed_url(tos.HttpMethodType.Http_Method_Get, save_bucket, save_key, 3600)
            
            result = {
                "presigned_url": download_url.signed_url,
                "source_bucket": bucket_name,
                "source_key": object_key,
                "save_bucket": save_bucket,
                "save_key": save_key,
                "time": time,
                "format": format,
                "processed_size": len(processed_data),
                "expires_in": 3600,
                "status": "processed"
            }
            return [TextContent(type="text", text=json.dumps(result, indent=2, ensure_ascii=False))]
        except Exception as e:
            return [TextContent(type="text", text=f"视频截帧失败: {str(e)}")]
  • The input schema definition for the `tos_video_snapshot` tool, registered in the `list_tools()` handler. Defines parameters like bucket_name, object_key, time, format, save_bucket, save_key.
    Tool(
        name="tos_video_snapshot",
        description="视频截帧(支持持久化)",
        inputSchema={
            "type": "object",
            "properties": {
                "bucket_name": {
                    "type": "string",
                    "description": "存储桶名称"
                },
                "object_key": {
                    "type": "string",
                    "description": "视频对象键名"
                },
                "time": {
                    "type": "number",
                    "description": "截帧时间点(毫秒),如300表示第300毫秒",
                    "default": 300
                },
                "format": {
                    "type": "string",
                    "description": "输出格式",
                    "enum": ["jpg", "png"],
                    "default": "jpg"
                },
                "save_bucket": {
                    "type": "string",
                    "description": "保存截帧图片的存储桶名称"
                },
                "save_key": {
                    "type": "string",
                    "description": "保存截帧图片的对象键名"
                }
            },
            "required": ["bucket_name", "object_key", "save_bucket", "save_key"]
        }
    ),
  • Tool dispatch/registration in the `call_tool()` function, which routes calls to `tos_video_snapshot` to the `video_snapshot` handler.
    elif name == "tos_video_snapshot":
        return await video_snapshot(arguments)
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. While it mentions 'supports persistence' (implying the captured frame can be saved), it doesn't describe what happens during execution (e.g., whether it overwrites existing files, requires specific permissions, has rate limits, or returns any output). This is inadequate for a tool with 6 parameters and no output schema.

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 extremely concise (one phrase) and front-loaded with the core functionality. There's no wasted text, but it may be too brief given the tool's complexity. Every word earns its place, though more detail would improve completeness.

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

Completeness2/5

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

Given the tool's complexity (6 parameters, no output schema, and no annotations), the description is incomplete. It doesn't explain what the tool returns, how errors are handled, or behavioral aspects like whether it's idempotent. The high schema coverage helps, but the description alone is insufficient for safe and effective use.

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?

The schema description coverage is 100%, with all parameters clearly documented in the input schema. The description adds no additional parameter semantics beyond what's already in the schema (e.g., it doesn't explain relationships between parameters like 'bucket_name' and 'save_bucket'). With high schema coverage, the baseline score of 3 is appropriate.

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

Purpose3/5

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

The description '视频截帧(支持持久化)' translates to 'Video frame capture (supports persistence)', which clearly states the core function (capturing frames from videos) and mentions persistence capability. However, it doesn't specify what resource it operates on (video objects in storage) or differentiate it from sibling tools like 'tos_video_info' or 'tos_image_process'.

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 when this tool is appropriate compared to other video or image processing tools in the sibling list, nor does it specify prerequisites or exclusions for its use.

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/jneless/tos-mcp'

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