Skip to main content
Glama

putString

Upload string content to cloud storage buckets with specified filenames, directories, and content types for data persistence and management.

Instructions

上传字符串内容到存储桶

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes要上传的字符串内容
fileNameYes文件名 (存在存储桶里的名称)
targetDirNo目标目录 (存在存储桶的哪个目录)
contentTypeNo内容类型,如 text/plain, application/json 等,默认为 text/plain

Implementation Reference

  • src/server.ts:114-146 (registration)
    MCP tool registration for 'putString' including description, Zod input schema, and thin async handler that delegates to CosService.uploadString and formats response.
    server.tool(
      'putString',
      '上传字符串内容到存储桶',
      {
        content: z.string().describe('要上传的字符串内容'),
        fileName: z.string().describe('文件名 (存在存储桶里的名称)'),
        targetDir: z
          .string()
          .optional()
          .describe('目标目录 (存在存储桶的哪个目录)'),
        contentType: z
          .string()
          .optional()
          .describe('内容类型,如 text/plain, application/json 等,默认为 text/plain'),
      },
      async ({ content, fileName, targetDir, contentType }) => {
        const res = await COSInstance.uploadString({
          content,
          fileName,
          targetDir,
          contentType,
        });
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(res.data, null, 2),
            },
          ],
          isError: !res.isSuccess,
        };
      },
    );
  • Core implementation of string upload to COS: Zod validation, path construction via buildCosPath, cos.putObject call with Body as string content, and success/error response.
    async uploadString(params: UploadStringParams) {
      const validParams = UploadStringParamsSchema.parse(params);
      const { content, fileName, targetDir = '', contentType = 'text/plain' } = validParams;
      
      try {
        // 构建COS路径
        const cosPath = this.buildCosPath(fileName, targetDir);
    
        // 上传字符串内容
        const cosParams: COS.PutObjectParams = {
          Bucket: this.bucket,
          Region: this.region,
          Key: cosPath,
          Body: content,
          ContentType: contentType,
        };
    
        const result = await this.cos.putObject(cosParams);
    
        return {
          isSuccess: true,
          message: '上传成功',
          data: result,
        };
      } catch (error) {
        return {
          isSuccess: false,
          message: '上传失败',
          data: error,
        };
      }
    }
  • Zod input schema definition for the uploadString method parameters in CosService.
    export const UploadStringParamsSchema = z.object({
      content: z.string(),
      fileName: z.string(),
      targetDir: z.string().optional(),
      contentType: z.string().optional()
    });
    export type UploadStringParams = z.infer<typeof UploadStringParamsSchema>;
  • Helper method to construct the COS object key/path from filename and optional target directory.
    private buildCosPath(fileName: string, targetDir?: string): string {
      if (!targetDir) {
        return fileName;
      }
      
      // 规范化目标目录:移除头尾斜杠
      const normalizedDir = targetDir.replace(/^\/+|\/+$/g, '');
      return normalizedDir ? `${normalizedDir}/${fileName}` : fileName;
    }
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. While '上传' (upload) implies a write/mutation operation, the description doesn't disclose important behavioral aspects: whether this overwrites existing files, what permissions are required, error conditions, rate limits, or what happens on success/failure. For a mutation 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 that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded with the core functionality.

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 mutation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what happens after upload (success response, error handling), doesn't differentiate from similar sibling tools, and provides no behavioral context. The 100% schema coverage helps with parameters, but overall completeness is poor for a write operation.

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 4 parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema - it doesn't explain relationships between parameters, provide examples, or clarify edge cases. 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.

Purpose4/5

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

The description clearly states the action ('上传' meaning 'upload') and resource ('字符串内容到存储桶' meaning 'string content to storage bucket'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like putBase64, putBuffer, putObject, or putObjectSourceUrl which appear to be related upload operations with 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?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling upload tools (putBase64, putBuffer, putObject, putObjectSourceUrl), there's no indication of when this string-specific upload is preferred over other methods, nor any mention of prerequisites or constraints.

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