Skip to main content
Glama
Tencent

Tencent Cloud COS MCP Server

Official
by Tencent

getObject

Download files from specified buckets in Tencent Cloud COS MCP Server by providing the file path as input, enabling direct access to stored objects for processing or retrieval.

Instructions

下载存储桶内的文件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectKeyYes文件的路径

Implementation Reference

  • src/server.ts:272-296 (registration)
    Registration of the 'getObject' MCP tool using server.tool, including inline schema and handler.
    server.tool(
      'getObject',
      '下载存储桶内的文件',
      {
        objectKey: z.string().describe('文件的路径'),
      },
      async ({ objectKey = '/' }) => {
        const res = await COSInstance.getObject(objectKey);
        if (!res.isSuccess) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(res.data, null, 2),
              },
            ],
            isError: true
          };
        }
        return {
          content: [res.data] as any,
          isError: false,
        };
      },
    );
  • Zod input schema for the 'getObject' tool defining the objectKey parameter.
    {
      objectKey: z.string().describe('文件的路径'),
    },
  • Inline handler function for 'getObject' tool: calls COSInstance.getObject, handles errors, and returns MCP-formatted content.
    async ({ objectKey = '/' }) => {
      const res = await COSInstance.getObject(objectKey);
      if (!res.isSuccess) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(res.data, null, 2),
            },
          ],
          isError: true
        };
      }
      return {
        content: [res.data] as any,
        isError: false,
      };
    },
  • CosService.getObject method: core logic for fetching object from COS bucket, processing buffer into MCP-compatible content (image/audio/text/base64), handling errors.
    async getObject(objectKey = '/') {
      try {
        // 下载文件
        const cosParams: COS.GetObjectParams = {
          Bucket: this.bucket,
          Region: this.region,
          Key: objectKey,
        };
        const result = await this.cos.getObject(cosParams);
    
        // 统一处理 buffer
        const buffer = Buffer.isBuffer(result.Body) ? result.Body : Buffer.from(result.Body ?? '');
    
        // 获取 Content-Type,统一小写
        let contentType = result.headers && (result.headers['content-type'] || result.headers['Content-Type']);
        contentType = typeof contentType === 'string' ? contentType.toLowerCase() : '';
    
        let mcpData;
        if (contentType.startsWith('image/')) {
          mcpData = { type: 'image', data: buffer.toString('base64'), mimeType: contentType };
        } else if (contentType.startsWith('audio/')) {
          mcpData = { type: 'audio', data: buffer.toString('base64'), mimeType: contentType };
        } else if (contentType.startsWith('text/') || TEXT_TYPES.includes(contentType)) {
          mcpData = { type: 'text', text: buffer.toString('utf-8') };
        } else {
          mcpData = { type: 'text', text: buffer.toString('base64') };
        }
        
        return {
          isSuccess: true,
          message: '下载文件成功',
          data: mcpData,
        };
      } catch (error) {
        return {
          isSuccess: false,
          message: '下载文件失败',
          data: error instanceof Error ? error.message : 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. It states 'download' which implies a read operation, but doesn't disclose behavioral traits like authentication requirements, rate limits, error conditions, or what happens if the file doesn't exist. For a tool with zero annotation coverage, this is a significant gap.

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 sentence in Chinese that directly states the tool's purpose. It's front-loaded with no wasted words, making it highly concise and well-structured.

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 no annotations, no output schema, and a single parameter with full schema coverage, the description is incomplete. It doesn't explain what the tool returns (e.g., file content, metadata), error handling, or usage context, leaving significant gaps for 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 the parameter 'objectKey' documented as '文件的路径' (file path). The description adds no additional parameter semantics beyond what the schema provides, so the baseline score of 3 is appropriate.

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 (download) and target (file in bucket). It distinguishes from siblings like 'getBucket' (list bucket) and 'putObject' (upload), but doesn't explicitly differentiate from 'getObjectUrl' which might return a URL instead of the file content.

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 on when to use this tool versus alternatives like 'getObjectUrl' or 'putObject'. The description implies it's for downloading files, but doesn't specify prerequisites (e.g., file must exist) or compare with sibling tools.

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