download_files
Download multiple files from MinIO storage buckets simultaneously by specifying file objects and local save paths. Streamlines batch file retrieval for efficient storage management.
Instructions
批量下载文件
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucketName | Yes | 存储桶名称 | |
| files | Yes | 文件列表 |
Implementation Reference
- src/index.ts:574-592 (handler)MCP request handler for the 'download_files' tool. Validates input arguments using Zod, delegates to MinIO client for execution, and formats a response with success/failure counts and errors.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 MCP server tools list, 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/index.ts:258-275 (schema)Input schema definition for the 'download_files' tool, specifying bucketName and array of files with objectName and localPath.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 download in MinIO client. Loops through files, calls single downloadFile for each, tracks successes and failures, returns 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; }