get_alerts
Retrieve recent guard alerts and errors to monitor if AI agents are hitting safety limits like loop detection and budget exceeded thresholds.
Instructions
Get recent guard alerts (loop detection, budget exceeded) and errors. Useful for checking if your agents are hitting safety limits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max alerts to return (default 50) | |
| since | No | ISO timestamp — only alerts after this time |
Implementation Reference
- mcp-server/src/tools.ts:81-100 (handler)The 'get_alerts' tool definition including its input schema and handler function. The handler calls client.getAlerts() with limit and since parameters, then stringifies the result.
{ name: "get_alerts", description: "Get recent guard alerts (loop detection, budget exceeded) and errors. " + "Useful for checking if your agents are hitting safety limits.", inputSchema: { type: "object", properties: { limit: { type: "number", description: "Max alerts to return (default 50)" }, since: { type: "string", description: "ISO timestamp — only alerts after this time" }, }, }, handler: async (client, args) => { const result = await client.getAlerts({ limit: args.limit ? String(args.limit) : undefined, since: args.since as string | undefined, }); return JSON.stringify(result, null, 2); }, }, - mcp-server/src/tools.ts:82-99 (schema)Input schema for get_alerts: optional 'limit' (number, max 50) and 'since' (string, ISO timestamp).
name: "get_alerts", description: "Get recent guard alerts (loop detection, budget exceeded) and errors. " + "Useful for checking if your agents are hitting safety limits.", inputSchema: { type: "object", properties: { limit: { type: "number", description: "Max alerts to return (default 50)" }, since: { type: "string", description: "ISO timestamp — only alerts after this time" }, }, }, handler: async (client, args) => { const result = await client.getAlerts({ limit: args.limit ? String(args.limit) : undefined, since: args.since as string | undefined, }); return JSON.stringify(result, null, 2); }, - mcp-server/src/client.ts:55-57 (helper)The getAlerts method on AgentGuardClient that makes the actual HTTP GET request to /api/v1/alerts.
async getAlerts(opts?: { limit?: string; since?: string }) { return this.fetch<{ alerts: unknown[] }>("/api/v1/alerts", opts); } - mcp-server/src/index.ts:23-42 (registration)Registration loop in index.ts that registers all tools (including get_alerts) with the MCP server using server.tool().
// Register each tool with the MCP server for (const tool of tools) { const shape = buildToolShape(tool.inputSchema.properties, tool.inputSchema.required ?? []); const toolName = tool.name; const handler = tool.handler; server.tool(toolName, tool.description, shape, async (args) => { try { const text = await handler(client, args as Record<string, unknown>); return { content: [{ type: "text" as const, text }] }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } }); }