Skip to main content
Glama

putBuffer

Upload buffer content to cloud storage buckets with configurable encoding and content types for file management.

Instructions

上传buffer内容到存储桶

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesbuffer内容字符串
fileNameYes文件名 (存在存储桶里的名称)
targetDirNo目标目录 (存在存储桶的哪个目录)
contentTypeNo内容类型,如 image/png, application/pdf 等,默认为 application/octet-stream
encodingNo字符串编码格式,默认为utf8。hex=十六进制,base64=Base64编码,utf8=UTF-8文本,ascii=ASCII文本,binary=二进制

Implementation Reference

  • src/server.ts:182-219 (registration)
    Registration of the 'putBuffer' MCP tool, including inline input schema, description, and handler function that calls CosService.uploadBuffer and returns formatted response.
    server.tool(
      'putBuffer',
      '上传buffer内容到存储桶',
      {
        content: z.string().describe('buffer内容字符串'),
        fileName: z.string().describe('文件名 (存在存储桶里的名称)'),
        targetDir: z
          .string()
          .optional()
          .describe('目标目录 (存在存储桶的哪个目录)'),
        contentType: z
          .string()
          .optional()
          .describe('内容类型,如 image/png, application/pdf 等,默认为 application/octet-stream'),
        encoding: z
          .enum(['hex', 'base64', 'utf8', 'ascii', 'binary'])
          .optional()
          .describe('字符串编码格式,默认为utf8。hex=十六进制,base64=Base64编码,utf8=UTF-8文本,ascii=ASCII文本,binary=二进制'),
      },
      async ({ content, fileName, targetDir, contentType, encoding }) => {
        const res = await COSInstance.uploadBuffer({
          content,
          fileName,
          targetDir,
          contentType,
          encoding,
        });
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(res.data, null, 2),
            },
          ],
          isError: !res.isSuccess,
        };
      },
    );
  • Zod schema for the uploadBuffer method parameters, matching the tool's input schema.
    export const UploadBufferParamsSchema = z.object({
      content: z.string(),
      fileName: z.string(),
      targetDir: z.string().optional(),
      contentType: z.string().optional(),
      encoding: z.enum(['hex', 'base64', 'utf8', 'ascii', 'binary']).optional()
    });
    export type UploadBufferParams = z.infer<typeof UploadBufferParamsSchema>;
  • Implementation of uploadBuffer in CosService: validates params, builds object key, converts content string to Buffer (with optional encoding), uploads to COS via putObject, handles errors.
    async uploadBuffer(params: UploadBufferParams) {
      const validParams = UploadBufferParamsSchema.parse(params);
      const { content, fileName, targetDir = '', contentType = 'application/octet-stream', encoding } = validParams;
      
      try {
        // 构建COS路径
        const cosPath = this.buildCosPath(fileName, targetDir);
    
        // 根据编码类型转换为Buffer
        const buffer = encoding ? Buffer.from(content, encoding) : Buffer.from(content);
    
        // 上传buffer内容
        const cosParams: COS.PutObjectParams = {
          Bucket: this.bucket,
          Region: this.region,
          Key: cosPath,
          Body: buffer,
          ContentType: contentType,
        };
    
        const result = await this.cos.putObject(cosParams);
    
        return {
          isSuccess: true,
          message: '上传成功',
          data: result,
        };
      } catch (error) {
        return {
          isSuccess: false,
          message: '上传失败',
          data: error,
        };
      }
    }
Behavior2/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 only states the upload action without mentioning any behavioral aspects like authentication requirements, rate limits, error conditions, whether this overwrites existing files, or what happens after upload. For a write operation tool with zero annotation coverage, this is insufficient.

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 a single, efficient Chinese phrase ('上传buffer内容到存储桶') that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded with the essential information.

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?

For a write operation tool with 5 parameters and no annotations or output schema, the description is incomplete. It doesn't address important contextual aspects like what happens after upload (success/failure responses), whether this is idempotent, what permissions are required, or how it differs from similar sibling tools. The description alone doesn't provide enough information for confident tool selection and invocation.

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 no additional parameter information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

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

Purpose4/5

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

The description '上传buffer内容到存储桶' clearly states the action (upload) and target (storage bucket) in Chinese, making the purpose understandable. However, it doesn't differentiate from sibling tools like putBase64, putObject, putObjectSourceUrl, or putString, which all seem to upload content to storage buckets using different input formats.

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?

No guidance is provided on when to use this tool versus alternatives. With multiple sibling upload tools (putBase64, putObject, putObjectSourceUrl, putString), the description offers no indication of what makes this tool distinct or when it should be preferred over those other options.

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