upload_file
Upload files to MinIO storage buckets with specified metadata. This tool transfers local files to cloud storage for organized data management and accessibility.
Instructions
上传文件到存储桶
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"bucketName": "<bucketName>",
"objectName": "<objectName>",
"filePath": "<filePath>"
},
"name": "upload_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucketName | Yes | 存储桶名称 | |
| objectName | Yes | 对象名称 | |
| filePath | Yes | 本地文件路径 | |
| metadata | No | 文件元数据(可选) |
Implementation Reference
- src/index.ts:415-432 (handler)MCP CallTool handler case for 'upload_file': validates arguments with Zod schema matching the tool inputSchema, calls minioClient.uploadFile, and returns success message.
case 'upload_file': { const { bucketName, objectName, filePath, metadata } = z.object({ bucketName: z.string(), objectName: z.string(), filePath: z.string(), metadata: z.record(z.string()).optional() }).parse(args); await this.minioClient.uploadFile(bucketName, objectName, filePath, metadata); return { content: [ { type: 'text', text: `成功上传文件 ${filePath} 到 ${bucketName}/${objectName}` } ] }; } - src/index.ts:136-148 (schema)Tool schema definition in ListTools response, specifying name, description, and inputSchema for 'upload_file'.
name: 'upload_file', description: '上传文件到存储桶', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, objectName: { type: 'string', description: '对象名称' }, filePath: { type: 'string', description: '本地文件路径' }, metadata: { type: 'object', description: '文件元数据(可选)' } }, required: ['bucketName', 'objectName', 'filePath'] } }, - src/minio-client.ts:106-118 (helper)Core implementation of file upload using MinIO client's putObject method, called by the MCP handler.
async uploadFile(bucketName: string, objectName: string, filePath: string, metadata?: Record<string, string>): Promise<void> { this.ensureConnected(); if (!fs.existsSync(filePath)) { throw new Error(`文件不存在: ${filePath}`); } const stats = fs.statSync(filePath); const stream = fs.createReadStream(filePath); await this.client!.putObject(bucketName, objectName, stream, stats.size, metadata); }