getBucket
Lists files in a cloud storage bucket to view contents and manage stored data. Specify a path prefix to filter results.
Instructions
查询存储桶内的文件列表
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Prefix | No | 文件列表的路径前缀,默认根路径 |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"Prefix": {
"description": "文件列表的路径前缀,默认根路径",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/services/cos/cos.service.ts:358-378 (handler)The handler function in CosService that executes the getBucket tool by querying the COS bucket contents using the Tencent COS SDK.async getBucket(Prefix = '') { try { const result = await this.cos.getBucket({ Bucket: this.bucket, Region: this.region, Prefix, Delimiter: '', }); return { isSuccess: true, message: '获取列表成功', data: result, }; } catch (error) { return { isSuccess: false, message: '获取列表失败', data: error, }; } }
- src/server.ts:297-315 (registration)Registers the 'getBucket' tool with the MCP server, including input schema (Prefix parameter) and a thin wrapper handler that delegates to CosService.getBucket.server.tool( 'getBucket', '查询存储桶内的文件列表', { Prefix: z.string().optional().describe('文件列表的路径前缀,默认根路径'), }, async ({ Prefix = '' }) => { const res = await COSInstance.getBucket(Prefix); return { content: [ { type: 'text', text: JSON.stringify(res.data, null, 2), }, ], isError: !res.isSuccess, }; }, );
- src/server.ts:300-302 (schema)Zod schema definition for the getBucket tool input: optional Prefix string.{ Prefix: z.string().optional().describe('文件列表的路径前缀,默认根路径'), },