delete_bucket
Remove a specified storage bucket from MinIO object storage to manage storage resources effectively. Requires the bucket name for precise deletion.
Instructions
删除存储桶
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucketName | Yes | 存储桶名称 |
Implementation Reference
- src/index.ts:363-377 (handler)The MCP tool handler for 'delete_bucket'. It validates the input arguments using Zod, calls the MinIO client's deleteBucket method, and returns a success message.case 'delete_bucket': { const { bucketName } = z.object({ bucketName: z.string() }).parse(args); await this.minioClient.deleteBucket(bucketName); return { content: [ { type: 'text', text: `成功删除存储桶: ${bucketName}` } ] }; }
- src/index.ts:101-110 (schema)The input schema definition for the 'delete_bucket' tool, provided in the ListTools response.name: 'delete_bucket', description: '删除存储桶', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' } }, required: ['bucketName'] } },
- src/index.ts:64-314 (registration)The tool is registered by including it in the static tools list returned by the ListToolsRequestSchema handler.this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'connect_minio', description: '连接到MinIO服务器', inputSchema: { type: 'object', properties: { endPoint: { type: 'string', description: 'MinIO服务器地址' }, port: { type: 'number', description: 'MinIO服务器端口' }, useSSL: { type: 'boolean', description: '是否使用SSL连接', default: false }, accessKey: { type: 'string', description: '访问密钥' }, secretKey: { type: 'string', description: '秘密密钥' }, region: { type: 'string', description: '区域设置(可选)' } }, required: ['endPoint', 'port', 'accessKey', 'secretKey'] } }, { name: 'list_buckets', description: '列出所有存储桶', inputSchema: { type: 'object', properties: {} } }, { name: 'create_bucket', description: '创建存储桶', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, region: { type: 'string', description: '区域设置(可选)' } }, required: ['bucketName'] } }, { name: 'delete_bucket', description: '删除存储桶', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' } }, required: ['bucketName'] } }, { name: 'bucket_exists', description: '检查存储桶是否存在', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' } }, required: ['bucketName'] } }, { name: 'list_objects', description: '列出存储桶中的对象', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, prefix: { type: 'string', description: '对象名前缀(可选)' }, recursive: { type: 'boolean', description: '是否递归列出', default: false } }, required: ['bucketName'] } }, { 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'] } }, { name: 'download_file', description: '从存储桶下载文件', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, objectName: { type: 'string', description: '对象名称' }, filePath: { type: 'string', description: '本地保存路径' } }, required: ['bucketName', 'objectName', 'filePath'] } }, { name: 'delete_object', description: '删除存储桶中的对象', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, objectName: { type: 'string', description: '对象名称' } }, required: ['bucketName', 'objectName'] } }, { name: 'delete_objects', description: '批量删除存储桶中的对象', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, objectNames: { type: 'array', items: { type: 'string' }, description: '对象名称列表' } }, required: ['bucketName', 'objectNames'] } }, { name: 'copy_object', description: '复制对象', inputSchema: { type: 'object', properties: { sourceBucket: { type: 'string', description: '源存储桶名称' }, sourceObject: { type: 'string', description: '源对象名称' }, destBucket: { type: 'string', description: '目标存储桶名称' }, destObject: { type: 'string', description: '目标对象名称' } }, required: ['sourceBucket', 'sourceObject', 'destBucket', 'destObject'] } }, { name: 'get_object_info', description: '获取对象信息', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, objectName: { type: 'string', description: '对象名称' } }, required: ['bucketName', 'objectName'] } }, { name: 'generate_presigned_url', description: '生成预签名URL', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, objectName: { type: 'string', description: '对象名称' }, method: { type: 'string', enum: ['GET', 'PUT', 'DELETE'], description: 'HTTP方法', default: 'GET' }, expires: { type: 'number', description: '过期时间(秒)', default: 3600 } }, required: ['bucketName', 'objectName'] } }, { name: 'get_storage_stats', description: '获取存储统计信息', inputSchema: { type: 'object', properties: {} } }, { 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'] } }, { 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'] } }, { name: 'set_bucket_policy', description: '设置存储桶策略', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, policy: { type: 'string', description: 'JSON格式的策略' } }, required: ['bucketName', 'policy'] } }, { name: 'get_bucket_policy', description: '获取存储桶策略', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' } }, required: ['bucketName'] } }, { name: 'delete_bucket_policy', description: '删除存储桶策略', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' } }, required: ['bucketName'] } } ] }; });
- src/minio-client.ts:65-68 (helper)Helper method in MinIOStorageClient that performs the actual bucket deletion using the MinIO client's removeBucket method.async deleteBucket(bucketName: string): Promise<void> { this.ensureConnected(); await this.client!.removeBucket(bucketName); }