list_objects
List objects stored in Tencent Cloud Object Storage (COS) with optional prefix filtering for efficient cloud storage management.
Instructions
列出COS中的对象
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prefix | No | 对象键的过滤前缀,默认列出所有对象 |
Implementation Reference
- src/cosService.js:716-737 (handler)Core implementation of listObjects: lists objects in Tencent COS bucket using SDK's getBucket with optional prefix filter, returns formatted list.async listObjects(prefix = '') { this._checkConfig(); try { const params = { Bucket: this.config.Bucket, Region: this.config.Region, Prefix: prefix, MaxKeys: 1000 }; const response = await this.cos.getBucket(params); return { success: true, files: response.Contents || [], prefix, total: response.Contents?.length || 0 }; } catch (error) { throw new Error(`列举文件失败: ${error.message}`); } }
- index.js:536-545 (handler)MCP CallToolRequestSchema handler case for list_objects: calls cosService.listObjects and returns JSON-formatted response.case 'list_objects': const listResult = await cosService.listObjects(args.prefix || ''); return { content: [ { type: 'text', text: JSON.stringify({ success: true, data: listResult }, null, 2) } ] };
- index.js:213-225 (schema)Input schema definition for list_objects tool: object with optional 'prefix' string parameter.list_objects: { name: 'list_objects', description: '列出COS中的对象', inputSchema: { type: 'object', properties: { prefix: { type: 'string', description: '对象键的过滤前缀,默认列出所有对象' } } } },
- index.js:393-395 (registration)Registers ListToolsRequestSchema handler returning all tools including list_objects.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.values(tools), }));