get_storage_stats
Retrieve storage usage statistics and metrics from MinIO object storage to monitor capacity and analyze data distribution.
Instructions
获取存储统计信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:226-229 (registration)Registration of the 'get_storage_stats' tool in the ListTools response, including name, description, and empty input schema.{ name: 'get_storage_stats', description: '获取存储统计信息', inputSchema: { type: 'object', properties: {} }
- src/index.ts:541-551 (handler)MCP CallTool handler case for 'get_storage_stats': calls minioClient.getStorageStats() and returns formatted text response.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/minio-client.ts:235-264 (handler)Core implementation of getStorageStats(): lists all buckets and objects recursively, computes total stats and per-bucket stats.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/types.ts:32-41 (schema)TypeScript interface defining the StorageStats return type used by getStorageStats().export interface StorageStats { totalBuckets: number; totalObjects: number; totalSize: number; bucketStats: Array<{ bucketName: string; objectCount: number; totalSize: number; }>; }