Skip to main content
Glama

waterMarkFont

Add text watermarks to images stored in cloud storage. Specify the image file path and watermark text to create protected visual content.

Instructions

生成带文字水印的图片

Input Schema

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

Implementation Reference

  • The handler function in CIPicService class that implements the watermark font logic using Tencent COS image processing API, including parameter validation, text encoding, and API call.
    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,
        };
      }
    }
  • Zod schema definition for WaterMarkFont parameters used in the handler for input validation.
    export const WaterMarkFontParamsSchema = z.object({
      objectKey: z.string(),
      text: z.string(),
    });
    export type WaterMarkFontParams = z.infer<typeof WaterMarkFontParamsSchema>;
  • src/server.ts:423-444 (registration)
    MCP server tool registration for 'waterMarkFont', defining input schema and delegating to CIPicInstance handler.
    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,
        };
      },
    );
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. It states the tool generates watermarked images but doesn't mention whether this modifies the original file, creates a new file, requires specific permissions, has rate limits, or what the output format is. This leaves significant gaps in understanding the tool's behavior.

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 a single, efficient sentence in Chinese that directly states the tool's function without unnecessary words. It's appropriately sized for a simple tool, though it could be more front-loaded with key details if expanded.

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 complexity of image processing (mutating files) and lack of annotations or output schema, the description is incomplete. It doesn't cover behavioral aspects like file handling, output format, or error conditions, making it inadequate for safe and effective use by an AI agent.

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 clear descriptions for both parameters (objectKey and text). The description adds no additional meaning beyond the schema, such as explaining how the watermark is applied (e.g., position, font size) or format constraints. Baseline 3 is appropriate as the 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 '生成带文字水印的图片' (Generate images with text watermark) clearly states the verb (generate) and resource (images with text watermark), providing a basic purpose. However, it doesn't differentiate from sibling tools like 'putObject' or 'putBase64' which might also handle image processing, making it somewhat vague in context.

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 offers no guidance on when to use this tool versus alternatives. With siblings like 'putObject' for uploading and 'imageInfo' for analysis, there's no indication of prerequisites, specific use cases, or exclusions, leaving the agent to infer usage from the tool name alone.

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/xiaomizhoubaobei/MCP'

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