get_storage_stats
Retrieve detailed storage statistics from MinIO object storage for monitoring and managing bucket usage, file operations, and resource allocation.
Instructions
获取存储统计信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/minio-client.ts:235-264 (handler)Core handler function that computes storage statistics by listing all buckets, recursively listing objects in each, and aggregating total and per-bucket counts and sizes.async getStorageStats(): Promise<StorageStats> { this.ensureConnected(); const buckets = await this.listBuckets(); const bucketStats = []; let totalObjects = 0; let totalSize = 0; for (const bucket of buckets) { const objects = await this.listObjects(bucket.name, undefined, true); const bucketSize = objects.reduce((sum, obj) => sum + obj.size, 0); const objectCount = objects.length; bucketStats.push({ bucketName: bucket.name, objectCount, totalSize: bucketSize }); totalObjects += objectCount; totalSize += bucketSize; } return { totalBuckets: buckets.length, totalObjects, totalSize, bucketStats }; }
- src/index.ts:541-551 (handler)MCP CallToolRequest handler case that invokes the MinIO client's getStorageStats method and formats the response as text content.case 'get_storage_stats': { const stats = await this.minioClient.getStorageStats(); return { content: [ { type: 'text', text: `存储统计信息:\n- 总存储桶数: ${stats.totalBuckets}\n- 总对象数: ${stats.totalObjects}\n- 总大小: ${(stats.totalSize / 1024 / 1024).toFixed(2)} MB\n\n各存储桶详情:\n${stats.bucketStats.map(b => `- ${b.bucketName}: ${b.objectCount} 个对象, ${(b.totalSize / 1024 / 1024).toFixed(2)} MB`).join('\n')}` } ] }; }
- src/index.ts:226-230 (registration)Tool registration in ListToolsRequest handler, defining name, description, and empty input schema.{ name: 'get_storage_stats', description: '获取存储统计信息', inputSchema: { type: 'object', properties: {} } },
- src/types.ts:32-41 (schema)TypeScript interface defining the structure of StorageStats returned by the handler.export interface StorageStats { totalBuckets: number; totalObjects: number; totalSize: number; bucketStats: Array<{ bucketName: string; objectCount: number; totalSize: number; }>; }