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
| Name | Required | Description | Default |
|---|---|---|---|
| objectKey | Yes | 文件的路径 |
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, }; }, );
- src/services/cos/cos.service.ts:381-406 (handler)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, }; } }
- src/server.ts:254-256 (schema)Zod input schema defining the objectKey parameter for the getObjectUrl tool.{ objectKey: z.string().describe('文件的路径'), },