Skip to main content
Glama

upload_file

Transfer files from local storage to a specified bucket in MinIO object storage using bucket name, object name, and file path. Optional metadata can be added during the upload process.

Instructions

上传文件到存储桶

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketNameYes存储桶名称
filePathYes本地文件路径
metadataNo文件元数据(可选)
objectNameYes对象名称

Implementation Reference

  • MCP CallToolRequestSchema handler for 'upload_file' tool: validates input parameters using Zod schema matching the tool's inputSchema, calls MinIOStorageClient.uploadFile method, and returns a success text response.
    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:135-148 (registration)
    Registration of the 'upload_file' tool in the ListToolsRequestSchema handler response, including name, description, and JSON schema for input validation.
    { 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'] } },
  • Core implementation of file upload in MinIOStorageClient: checks file existence, creates read stream, and uses MinIO client's putObject to upload to the specified bucket and object name.
    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); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pickstar-2002/minio-storage-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server