get_slot_stats
Analyze Valkey database slots to identify hot slots by CPU usage or find most populated slots by key count for performance optimization.
Instructions
Get per-slot key counts and CPU usage (Valkey 8.0+ only). Use orderBy='cpu-usec' to find hot slots, or 'key-count' to find the most populated slots. Returns an error message if not supported.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orderBy | No | Sort order: 'key-count' or 'cpu-usec' (default 'key-count') | |
| limit | No | Max slots to return (default 20) | |
| instanceId | No | Optional instance ID override |
Implementation Reference
- packages/mcp/src/index.ts:621-628 (handler)The handler for the 'get_slot_stats' tool, which fetches data from the '/mcp/instance/${id}/cluster/slot-stats' endpoint.
async ({ orderBy, limit, instanceId }) => { const id = resolveInstanceId(instanceId); const qs = buildQuery({ orderBy, limit }); const data = await apiFetch(`/mcp/instance/${id}/cluster/slot-stats${qs}`); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, - packages/mcp/src/index.ts:613-620 (registration)Registration of the 'get_slot_stats' tool within the MCP server, defining its schema and description.
server.tool( 'get_slot_stats', "Get per-slot key counts and CPU usage (Valkey 8.0+ only). Use orderBy='cpu-usec' to find hot slots, or 'key-count' to find the most populated slots. Returns an error message if not supported.", { orderBy: z.enum(['key-count', 'cpu-usec']).optional().describe("Sort order: 'key-count' or 'cpu-usec' (default 'key-count')"), limit: z.number().optional().describe('Max slots to return (default 20)'), instanceId: z.string().optional().describe('Optional instance ID override'), },