upload_files
Upload multiple files to MinIO object storage buckets with metadata options. This tool enables batch file transfers to cloud storage for efficient data management.
Instructions
批量上传文件
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucketName | Yes | 存储桶名称 | |
| files | Yes | 文件列表 |
Implementation Reference
- src/minio-client.ts:269-294 (handler)Core implementation of the upload_files tool: batch uploads files to MinIO bucket by iterating and calling uploadFile for each, returns BatchOperationResult with success/failure counts and errors.async uploadFiles(bucketName: string, files: Array<{ localPath: string; objectName: string; metadata?: Record<string, string> }>): Promise<BatchOperationResult> { this.ensureConnected(); const result: BatchOperationResult = { success: true, successCount: 0, failureCount: 0, errors: [] }; for (const file of files) { try { await this.uploadFile(bucketName, file.objectName, file.localPath, file.metadata); result.successCount++; } catch (error) { result.success = false; result.failureCount++; result.errors.push({ item: file.localPath, error: error instanceof Error ? error.message : String(error) }); } } return result; }
- src/index.ts:234-253 (schema)Input JSON schema for upload_files tool defining bucketName (string) and files array of objects with localPath, objectName, optional metadata.inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, files: { type: 'array', items: { type: 'object', properties: { localPath: { type: 'string', description: '本地文件路径' }, objectName: { type: 'string', description: '对象名称' }, metadata: { type: 'object', description: '文件元数据(可选)' } }, required: ['localPath', 'objectName'] }, description: '文件列表' } }, required: ['bucketName', 'files'] }
- src/index.ts:231-254 (registration)Registration of the upload_files tool in the ListTools response, including name, description, and inputSchema.{ name: 'upload_files', description: '批量上传文件', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, files: { type: 'array', items: { type: 'object', properties: { localPath: { type: 'string', description: '本地文件路径' }, objectName: { type: 'string', description: '对象名称' }, metadata: { type: 'object', description: '文件元数据(可选)' } }, required: ['localPath', 'objectName'] }, description: '文件列表' } }, required: ['bucketName', 'files'] } },
- src/index.ts:553-572 (helper)MCP server handler case for upload_files: validates arguments with Zod, calls minioClient.uploadFiles, formats response text.case 'upload_files': { const { bucketName, files } = z.object({ bucketName: z.string(), files: z.array(z.object({ localPath: z.string(), objectName: z.string(), metadata: z.record(z.string()).optional() })) }).parse(args); const result = await this.minioClient.uploadFiles(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') : ''}` } ] }; }