Skip to main content
Glama
jneless
by jneless

tos_image_process

Process images stored in TOS buckets by applying operations like resize, format conversion, crop, rotate, and quality adjustment with specified parameters.

Instructions

图片处理(组合操作,支持多种处理参数)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes存储桶名称
object_keyYes图片对象键名
processYes图片处理参数。参数格式通常为 'image/操作,参数',如: 'image/resize,h_100' 或 'image/format,jpg'。常用操作包括:resize(缩放),format(格式转换),quality(质量),crop(裁剪),rotate(旋转)等。
save_bucketYes保存的存储桶名称
save_keyYes保存的对象键名

Implementation Reference

  • Core handler function that executes the image processing using TOS SDK's get_object method with process, save_bucket, and save_object parameters for persistent processing.
    async def image_process(args: Dict[str, Any]) -> List[TextContent]:
        """图片处理(支持持久化)"""
        bucket_name = args["bucket_name"]
        object_key = args["object_key"]
        process = args["process"]
        save_bucket = args["save_bucket"]
        save_key = args["save_key"]
        
        try:
            # 使用官方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
            time.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,
                "process": process,
                "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)}")]
  • Tool registration in list_tools() including name, description, and input schema definition.
    Tool(
        name="tos_image_process",
        description="图片处理(组合操作,支持多种处理参数)",
        inputSchema={
            "type": "object",
            "properties": {
                "bucket_name": {
                    "type": "string",
                    "description": "存储桶名称"
                },
                "object_key": {
                    "type": "string",
                    "description": "图片对象键名"
                },
                "process": {
                    "type": "string",
                    "description": "图片处理参数。参数格式通常为 'image/操作,参数',如: 'image/resize,h_100' 或 'image/format,jpg'。常用操作包括:resize(缩放),format(格式转换),quality(质量),crop(裁剪),rotate(旋转)等。"
                },
                "save_bucket": {
                    "type": "string",
                    "description": "保存的存储桶名称"
                },
                "save_key": {
                    "type": "string",
                    "description": "保存的对象键名"
                }
            },
            "required": ["bucket_name", "object_key", "process", "save_bucket", "save_key"]
        }
    ),
  • Dispatch logic in call_tool() that routes tos_image_process calls to the image_process handler.
    elif name == "tos_image_process":
        return await image_process(arguments)
  • Import of the image_process handler function from handlers module.
        create_bucket, list_buckets, get_bucket_meta, delete_bucket,
        put_object, get_object, list_objects, delete_object,
        presigned_url, image_process, image_info,
        video_snapshot, video_info
    )
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 mentions '组合操作' (combined operations) which suggests multiple processing steps, but doesn't disclose whether this creates new files, modifies existing ones, requires specific permissions, has rate limits, or what the output looks like. For a tool with 5 required parameters and no annotations, this is a significant gap in behavioral information.

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 with just one Chinese phrase containing 11 characters. It's front-loaded with the core purpose. However, this brevity comes at the cost of completeness - while technically concise, it may be under-specified for a tool with 5 required parameters and no annotations.

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 has 5 required parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool actually produces (a new processed image file? a modified original?), doesn't mention error conditions, and doesn't provide context about the processing operations beyond what's in the parameter schema. For an image processing tool with multiple parameters, this leaves significant gaps.

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 100%, so the schema already documents all 5 parameters thoroughly. The description adds minimal value beyond the schema - it mentions '支持多种处理参数' (supports multiple processing parameters) which aligns with the 'process' parameter documentation, but doesn't provide additional semantic context about parameter interactions or usage patterns. Baseline 3 is appropriate when schema does the heavy lifting.

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 states '图片处理(组合操作,支持多种处理参数)' which translates to 'Image processing (combined operations, supports multiple processing parameters)'. This indicates the tool processes images with combined operations, but it's vague about the specific action - it doesn't specify whether it transforms, modifies, or creates new images. It doesn't clearly distinguish from sibling tools like 'tos_image_info' (which presumably reads image metadata) or 'tos_video_snapshot' (which extracts video frames).

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 any prerequisites, when-not-to-use scenarios, or comparisons to sibling tools like 'tos_image_info' (for metadata) or 'tos_put_object' (for uploading). There's no indication of whether this tool is for batch processing, real-time transformation, or specific use cases.

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