download_files
Download multiple files from MinIO storage buckets to specified local paths for batch file retrieval and storage management.
Instructions
批量下载文件
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucketName | Yes | 存储桶名称 | |
| files | Yes | 文件列表 |
Implementation Reference
- src/index.ts:574-592 (handler)Main handler for the 'download_files' MCP tool. Validates input parameters using Zod, invokes the MinIO client's downloadFiles method, and returns a formatted text response with batch operation results.case 'download_files': { const { bucketName, files } = z.object({ bucketName: z.string(), files: z.array(z.object({ objectName: z.string(), localPath: z.string() })) }).parse(args); const result = await this.minioClient.downloadFiles(bucketName, files); return { content: [ { type: 'text', text: `批量下载完成: 成功 ${result.successCount} 个, 失败 ${result.failureCount} 个${result.errors.length > 0 ? '\n错误:\n' + result.errors.map(e => `- ${e.item}: ${e.error}`).join('\n') : ''}` } ] }; }
- src/index.ts:255-277 (registration)Registration of the 'download_files' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.{ name: 'download_files', description: '批量下载文件', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, files: { type: 'array', items: { type: 'object', properties: { objectName: { type: 'string', description: '对象名称' }, localPath: { type: 'string', description: '本地保存路径' } }, required: ['objectName', 'localPath'] }, description: '文件列表' } }, required: ['bucketName', 'files'] } },
- src/minio-client.ts:299-324 (helper)Core implementation of batch file downloads from MinIO bucket. Iterates over file list, calls individual downloadFile for each, tracks successes and failures using BatchOperationResult.async downloadFiles(bucketName: string, files: Array<{ objectName: string; localPath: string }>): Promise<BatchOperationResult> { this.ensureConnected(); const result: BatchOperationResult = { success: true, successCount: 0, failureCount: 0, errors: [] }; for (const file of files) { try { await this.downloadFile(bucketName, file.objectName, file.localPath); result.successCount++; } catch (error) { result.success = false; result.failureCount++; result.errors.push({ item: file.objectName, error: error instanceof Error ? error.message : String(error) }); } } return result; }
- src/types.ts:44-52 (schema)Type definition for BatchOperationResult used in download_files response.export interface BatchOperationResult { success: boolean; successCount: number; failureCount: number; errors: Array<{ item: string; error: string; }>; }