Skip to main content
Glama

getObjectUrl

Generate signed download URLs for files stored in cloud storage buckets to enable secure access and sharing.

Instructions

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

Input Schema

NameRequiredDescriptionDefault
objectKeyYes文件的路径

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "objectKey": { "description": "文件的路径", "type": "string" } }, "required": [ "objectKey" ], "type": "object" }

Implementation Reference

  • src/server.ts:251-269 (registration)
    Registration of the MCP tool 'getObjectUrl' with description, Zod input schema, and inline handler function that invokes the COS service 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, }; }, );
  • Core implementation of getObjectUrl in COSService class, using Tencent COS SDK to generate signed download URL for the object.
    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 for the getObjectUrl tool, defining the objectKey parameter.
    { 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/xiaomizhoubaobei/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server