download_file
Download files from MinIO storage buckets to local systems by specifying bucket name, object name, and save path for data retrieval and storage management.
Instructions
从存储桶下载文件
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucketName | Yes | 存储桶名称 | |
| objectName | Yes | 对象名称 | |
| filePath | Yes | 本地保存路径 |
Implementation Reference
- src/minio-client.ts:130-139 (handler)Core handler function that performs the file download from MinIO bucket to local path using fGetObject.async downloadFile(bucketName: string, objectName: string, filePath: string): Promise<void> { this.ensureConnected(); const dir = path.dirname(filePath); if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); } await this.client!.fGetObject(bucketName, objectName, filePath); }
- src/index.ts:149-161 (registration)Tool registration in ListToolsRequestHandler, defining name, description, and input schema.{ name: 'download_file', description: '从存储桶下载文件', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, objectName: { type: 'string', description: '对象名称' }, filePath: { type: 'string', description: '本地保存路径' } }, required: ['bucketName', 'objectName', 'filePath'] } },
- src/index.ts:435-439 (schema)Zod schema validation for download_file tool arguments in the CallTool handler.const { bucketName, objectName, filePath } = z.object({ bucketName: z.string(), objectName: z.string(), filePath: z.string() }).parse(args);
- src/index.ts:434-450 (handler)Dispatch handler in CallToolRequestHandler that invokes the MinIO client's downloadFile method and formats response.case 'download_file': { const { bucketName, objectName, filePath } = z.object({ bucketName: z.string(), objectName: z.string(), filePath: z.string() }).parse(args); await this.minioClient.downloadFile(bucketName, objectName, filePath); return { content: [ { type: 'text', text: `成功下载文件 ${bucketName}/${objectName} 到 ${filePath}` } ] }; }