Skip to main content
Glama
Tencent

Tencent Cloud COS MCP Server

Official
by Tencent

aiPicMatting

Remove backgrounds from images stored in Tencent Cloud COS using AI-based matting, enabling precise isolation of subjects without coding.

Instructions

图片处理-抠图

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
heightNo高度
objectKeyYes图片在存储桶里的路径
widthNo宽度

Implementation Reference

  • The aiPicMatting method in CIAIService class that handles image matting/cropping using Tencent COS image_process API with AIImageCrop rule, taking objectKey, width, height as parameters.
    async aiPicMatting(objectKey: string, width: string, height: string) {
      try {
        const result = await new Promise((resolve, reject) => {
          const outPutFileid = generateOutPutFileId(objectKey);
          this.cos.request(
            {
              Bucket: this.bucket, // 存储桶,必须字段
              Region: this.region, // 存储桶所在地域,必须字段 如 ap-beijing
              Key: objectKey, // 对象文件名,例如:folder/document.jpg。
              Method: 'POST', // 固定值
              Action: 'image_process', // 固定值
              Headers: {
                'Pic-Operations': JSON.stringify({
                  rules: [
                    {
                      fileid: `${outPutFileid}`,
                      rule:
                        'ci-process=AIImageCrop&width=' +
                        width +
                        '&height=' +
                        height,
                    },
                  ],
                }),
              },
            },
            function (error, data) {
              if (error) {
                // 处理请求失败
                reject(error);
              } else {
                // 处理请求成功
                resolve(data);
              }
            },
          );
        });
    
        // const localPath = "结果.png"; // 填写要写入的本地文件路径
        // if (result.Body) {
        //   fs.writeFileSync(localPath, result.Body); // 将图片内容保存本地路径
        // } else {
        //   throw new Error("Result body is undefined");
        // }
        // if (!result.Body) {
        //   throw new Error("Result body is undefined");
        // }
        // const base64Image = `data:image/jpeg;base64,${typeof result.Body === "string" ? Buffer.from(result.Body).toString("base64") : result.Body.toString("base64")}`;
    
        return {
          isSuccess: true,
          message: '图片处理成功',
          data: result,
        };
      } catch (error) {
        return {
          isSuccess: false,
          message: '图片处理失败',
          data: error,
        };
      }
    }
  • src/server.ts:379-399 (registration)
    Registers the MCP tool 'aiPicMatting' using server.tool, including input schema with zod validators for objectKey, optional width and height, and delegates execution to CIAIInstance.aiPicMatting.
    server.tool(
      'aiPicMatting',
      '图片处理-抠图',
      {
        objectKey: z.string().describe('图片在存储桶里的路径'),
        width: z.string().optional().describe('宽度'),
        height: z.string().optional().describe('高度'),
      },
      async ({ objectKey, width = '5', height = '5' }) => {
        const res = await CIAIInstance.aiPicMatting(objectKey, width, height);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(res.data, null, 2),
            },
          ],
          isError: !res.isSuccess,
        };
      },
    );
Behavior1/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. The description '图片处理-抠图' gives no information about what the tool actually does behaviorally - whether it modifies images, returns processed results, requires authentication, has rate limits, or what format the output takes. It's completely inadequate for understanding tool behavior.

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

Conciseness2/5

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

While technically concise with just two Chinese characters and a dash, this is under-specification rather than effective conciseness. The description fails to communicate essential information about the tool's purpose and usage. Every sentence should earn its place, but here the single phrase fails to provide meaningful content.

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

Completeness1/5

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

Given a tool with 3 parameters, no annotations, and no output schema, the description '图片处理-抠图' is completely inadequate. It doesn't explain what the tool returns, how it processes images, what 'matting' means in this context, or any behavioral characteristics. For a potentially complex image processing tool, this minimal description leaves critical 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%, with all three parameters (objectKey, height, width) having descriptions in Chinese. The tool description adds no additional parameter information beyond what's already in the schema. With complete schema coverage, the baseline score of 3 is appropriate since the schema does the documentation work.

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

Purpose2/5

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

The description '图片处理-抠图' translates to 'Image processing - matting' which restates the tool name 'aiPicMatting' (AI picture matting) in slightly different words. It's a tautology that doesn't specify what the tool actually does beyond the name. No specific verb or resource distinction from siblings is provided.

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

Usage Guidelines1/5

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

The description provides absolutely no guidance on when to use this tool versus alternatives. There's no mention of context, prerequisites, or comparison to sibling tools like aiQrcode, aiSuperResolution, or other image processing tools. The agent receives zero usage direction.

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

Related 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/Tencent/cos-mcp'

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