set_bucket_policy
Configure access permissions for a MinIO storage bucket by defining a JSON policy. Manage and enforce security rules for bucket-level operations.
Instructions
设置存储桶策略
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucketName | Yes | 存储桶名称 | |
| policy | Yes | JSON格式的策略 |
Implementation Reference
- src/index.ts:594-608 (handler)Handler for 'set_bucket_policy' tool: validates input with Zod, calls MinIO client to set policy, returns success message.case 'set_bucket_policy': { const { bucketName, policy } = z.object({ bucketName: z.string(), policy: z.string() }).parse(args); await this.minioClient.setBucketPolicy(bucketName, policy); return { content: [ { type: 'text', text: `成功设置存储桶 ${bucketName} 的策略` } ] };
- src/index.ts:278-289 (registration)Tool registration in list_tools response, including name, description, and JSON schema for input validation.{ name: 'set_bucket_policy', description: '设置存储桶策略', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, policy: { type: 'string', description: 'JSON格式的策略' } }, required: ['bucketName', 'policy'] } },
- src/index.ts:595-598 (schema)Zod schema validation for tool arguments in the handler.const { bucketName, policy } = z.object({ bucketName: z.string(), policy: z.string() }).parse(args);
- src/minio-client.ts:329-332 (helper)MinIOStorageClient helper method that ensures connection and delegates to underlying MinIO Client's setBucketPolicy.async setBucketPolicy(bucketName: string, policy: string): Promise<void> { this.ensureConnected(); await this.client!.setBucketPolicy(bucketName, policy); }