get_anomalies
Retrieve anomaly detection events from persisted storage to investigate alert triggers or correlate with incidents. BetterDB continuously analyzes memory, hit rate, CPU, and other metrics using Z-score analysis.
Instructions
Get anomaly detection events from persisted storage. BetterDB continuously runs Z-score analysis on memory, hit rate, CPU, and other metrics — this returns the detected anomalies. Use to investigate what triggered an alert or correlate with an incident.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max events to return | |
| metricType | No | Filter by metric type | |
| startTime | No | Start time (Unix timestamp ms) | |
| instanceId | No | Optional instance ID override |
Implementation Reference
- packages/mcp/src/index.ts:500-519 (handler)Tool definition and handler implementation for 'get_anomalies' in the MCP server. It calls the /mcp/instance/{id}/history/anomalies endpoint.
server.tool( 'get_anomalies', 'Get anomaly detection events from persisted storage. BetterDB continuously runs Z-score analysis on memory, hit rate, CPU, and other metrics — this returns the detected anomalies. Use to investigate what triggered an alert or correlate with an incident.', { limit: z.number().optional().describe('Max events to return'), metricType: z.string().optional().describe('Filter by metric type'), startTime: z.number().optional().describe('Start time (Unix timestamp ms)'), instanceId: z.string().optional().describe('Optional instance ID override'), }, async ({ limit, metricType, startTime, instanceId }) => { const id = resolveInstanceId(instanceId); const qs = buildQuery({ limit, metricType, startTime }); const data = await apiFetch(`/mcp/instance/${id}/history/anomalies${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) }], }; },