Skip to main content
Glama
Tencent

Tencent Cloud COS MCP Server

Official
by Tencent

waterMarkFont

Add custom text watermarks to images stored in Tencent Cloud COS, enabling branding or copyright protection without manual editing.

Instructions

生成带文字水印的图片

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectKeyYesCOS对象键(完整路径)示例: images/photo.jpg
textNo水印文字内容(支持中文)test

Implementation Reference

  • The core handler function `waterMarkFont` in `CIPicService` that applies a text-based watermark to an image using Tencent Cloud COS image processing API. It validates params, encodes text, constructs image process params, and sends POST request to COS.
    async waterMarkFont(params: WaterMarkFontParams) {
      // 验证并解析参数
      const validParams = WaterMarkFontParamsSchema.parse(params);
      const { objectKey, text } = validParams;
      const encodedText = Buffer.from(text)
        .toString('base64')
        .replace(/\+/g, '-')
        .replace(/\//g, '_')
        .replace(/=+$/, '');
    
      try {
        const imageProcessParams = [
          'watermark/2', // 水印类型2表示文字水印
          `text/${encodedText}`, // 使用动态文本
          'scatype/3',
          'spcent/20',
        ].join('/');
    
        const outPutFileid = generateOutPutFileId(objectKey);
    
        const result = await new Promise((resolve, reject) => {
          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: imageProcessParams }],
                }),
              },
            },
            function (error, data) {
              if (error) {
                // 处理请求失败
                reject(error);
              } else {
                // 处理请求成功
                resolve(data);
              }
            },
          );
        });
        return {
          isSuccess: true,
          message: '添加水印成功',
          data: result,
        };
      } catch (error) {
        return {
          isSuccess: false,
          message: '添加水印失败',
          data: error,
        };
      }
    }
  • src/server.ts:423-444 (registration)
    Registration of the MCP tool 'waterMarkFont' using server.tool(), providing description, Zod input schema for objectKey and text, and async handler that delegates to CIPicInstance.waterMarkFont.
    server.tool(
      'waterMarkFont',
      '生成带文字水印的图片',
      {
        objectKey: z
          .string()
          .describe('COS对象键(完整路径)示例: images/photo.jpg'),
        text: z.string().describe('水印文字内容(支持中文)').default('test'),
      },
      async ({ objectKey, text }) => {
        const res = await CIPicInstance.waterMarkFont({ objectKey, text });
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(res.data, null, 2),
            },
          ],
          isError: !res.isSuccess,
        };
      },
    );
  • Zod schema definition `WaterMarkFontParamsSchema` and inferred TypeScript type `WaterMarkFontParams` for input validation within the handler.
    export const WaterMarkFontParamsSchema = z.object({
      objectKey: z.string(),
      text: z.string(),
    });
    export type WaterMarkFontParams = z.infer<typeof WaterMarkFontParamsSchema>;
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 indicates the tool generates watermarked images (implying a write/mutation operation), it doesn't specify whether this modifies the original image, creates a new file, requires authentication, has rate limits, or what the output format/behavior is. For a tool with no annotations, this leaves significant gaps in understanding its effects.

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

Conciseness5/5

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

The description is extremely concise (one sentence: '生成带文字水印的图片') and front-loaded with the core purpose. There's no wasted language or unnecessary elaboration, making it efficient for quick understanding.

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 (image processing with mutation), lack of annotations, and no output schema, the description is insufficiently complete. It doesn't explain what happens to the original image, where the output is stored, error conditions, or any behavioral constraints. For a tool that likely modifies or creates files, more context is needed 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 both parameters ('objectKey' and 'text') clearly documented in the schema. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain how the watermark is applied, font/size options, or positioning). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

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 '生成带文字水印的图片' (Generate images with text watermarks) clearly states the tool's purpose with a specific verb ('生成' - generate) and resource ('图片' - images). However, it doesn't distinguish this tool from potential sibling tools that might also manipulate images, though none of the listed siblings appear to be direct alternatives for watermarking.

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. There's no mention of prerequisites, limitations, or comparison with other tools in the server (like 'putObject' for uploading or 'imageInfo' for analysis). The agent must infer usage context solely from the tool name and description.

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