get_hot_keys
Retrieve top frequently accessed keys from Valkey/Redis to identify cache-busting patterns, uneven access distribution, and throughput-dominant keys using LFU scores or idle-time tracking.
Instructions
Get hot key tracking data from persisted storage. BetterDB periodically scans keys using LFU frequency scores (when maxmemory-policy is an LFU variant) or OBJECT IDLETIME / COMMANDLOG-derived frequency. Each snapshot captures the top keys ranked by access frequency. Use this to find cache-busting keys, uneven access patterns, or keys that dominate throughput. The signalType field in each entry indicates which detection mode was active (lfu or idletime).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| startTime | No | Start time (Unix timestamp ms) | |
| endTime | No | End time (Unix timestamp ms) | |
| limit | No | Max entries to return (default 50, max 200) | |
| instanceId | No | Optional instance ID override |
Implementation Reference
- packages/mcp/src/index.ts:546-566 (handler)The 'get_hot_keys' tool is registered and implemented directly in the MCP server setup within packages/mcp/src/index.ts. It executes a network request to the API via 'apiFetch' to fetch the hot key data.
server.tool( 'get_hot_keys', 'Get hot key tracking data from persisted storage. BetterDB periodically scans keys using LFU frequency scores (when maxmemory-policy is an LFU variant) or OBJECT IDLETIME / COMMANDLOG-derived frequency. Each snapshot captures the top keys ranked by access frequency. Use this to find cache-busting keys, uneven access patterns, or keys that dominate throughput. The signalType field in each entry indicates which detection mode was active (lfu or idletime).', { startTime: z.number().optional().describe('Start time (Unix timestamp ms)'), endTime: z.number().optional().describe('End time (Unix timestamp ms)'), limit: z.number().optional().describe('Max entries to return (default 50, max 200)'), instanceId: z.string().optional().describe('Optional instance ID override'), }, async ({ startTime, endTime, limit, instanceId }) => { const id = resolveInstanceId(instanceId); const qs = buildQuery({ startTime, endTime, limit }); const data = await apiFetch(`/mcp/instance/${id}/hot-keys${qs}`); if (isLicenseError(data)) { return { content: [{ type: 'text' as const, text: licenseErrorResult(data) }] }; } return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, );