Skip to main content
Glama
Tencent

Tencent Cloud COS MCP Server

Official
by Tencent

getObjectUrl

Generate a signed download URL for files stored in a bucket using the Tencent Cloud COS MCP Server, enabling secure access without manual coding.

Instructions

获取存储桶内的文件的带签名的下载链接

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectKeyYes文件的路径

Implementation Reference

  • src/server.ts:251-269 (registration)
    Registers the MCP tool 'getObjectUrl' with description, Zod input schema for objectKey, and handler that delegates to CosService.getObjectUrl and returns formatted response.
    server.tool(
      'getObjectUrl',
      '获取存储桶内的文件的带签名的下载链接',
      {
        objectKey: z.string().describe('文件的路径'),
      },
      async ({ objectKey = '/' }) => {
        const res = await COSInstance.getObjectUrl(objectKey);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(res.data, null, 2),
              },
            ],
            isError: !res.isSuccess,
          };
      },
    );
  • The core handler logic in CosService that generates a signed download URL for the specified objectKey using the COS SDK.
    async getObjectUrl(ObjectKey: string) {
      try {
        const result = await new Promise((resolve, reject) => {
          this.cos.getObjectUrl(
            {
              Bucket: this.bucket,
              Region: this.region,
              Key: ObjectKey,
            },
            (error, data) => (error ? reject(error) : resolve(data)),
          );
        });
    
        return {
          isSuccess: true,
          message: '获取带签名 ObjectUrl 成功',
          data: result,
        };
      } catch (error) {
        return {
          isSuccess: false,
          message: '获取带签名 ObjectUrl 失败',
          data: error,
        };
      }
    }
  • Zod input schema defining the objectKey parameter for the getObjectUrl tool.
    {
      objectKey: z.string().describe('文件的路径'),
    },

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