Set Alert Thresholds
set_alertDefine thresholds to trigger alerts when server response time exceeds a limit, uptime drops below a percentage, or consecutive failures occur.
Instructions
Configure alert thresholds for response time, uptime, and consecutive failures.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Server name | |
| max_response_time_ms | No | Alert if response time exceeds this | |
| min_uptime_percent | No | Alert if uptime drops below this | |
| consecutive_failures_before_alert | No |
Implementation Reference
- src/app.ts:791-797 (handler)The handler function that implements the 'set_alert' tool. It validates the server exists, then calls setAlertConfig to persist the alert configuration.
async (input: SetAlertInput) => { if (!getServer(input.name)) { throw new Error(`Server not registered: ${input.name}`); } return formatResponse(setAlertConfig(input)); } - src/alerts.ts:13-49 (helper)The setAlertConfig function that inserts or updates alert configuration in the database. Handles max_response_time_ms, min_uptime_percent, and consecutive_failures_before_alert fields.
export function setAlertConfig(input: SetAlertInput): { configured: true; config: AlertConfigRecord; } { const db = getDb(); db.prepare( ` INSERT INTO alerts ( server_name, max_response_time_ms, min_uptime_percent, consecutive_failures_before_alert ) VALUES (?, ?, ?, ?) ON CONFLICT(server_name) DO UPDATE SET max_response_time_ms = excluded.max_response_time_ms, min_uptime_percent = excluded.min_uptime_percent, consecutive_failures_before_alert = excluded.consecutive_failures_before_alert ` ).run( input.name, input.max_response_time_ms ?? null, input.min_uptime_percent ?? null, input.consecutive_failures_before_alert ); const config = getAlertConfig(input.name); if (!config) { throw new Error(`Failed to persist alert configuration for ${input.name}`); } return { configured: true, config }; } - src/types.ts:48-58 (schema)Zod schema for the set_alert tool input: name (string), max_response_time_ms (optional int), min_uptime_percent (optional 0-100), consecutive_failures_before_alert (int 1-10, default 3).
export const SetAlertSchema = z.object({ name: z.string().describe('Server name'), max_response_time_ms: z.number().int().optional().describe('Alert if response time exceeds this'), min_uptime_percent: z .number() .min(0) .max(100) .optional() .describe('Alert if uptime drops below this'), consecutive_failures_before_alert: z.number().int().min(1).max(10).default(3) }); - src/types.ts:126-126 (schema)TypeScript type SetAlertInput inferred from SetAlertSchema.
export type SetAlertInput = z.infer<typeof SetAlertSchema>; - src/app.ts:778-798 (registration)Registration of the 'set_alert' tool with metadata (title, description, inputSchema, annotations).
server.registerTool( 'set_alert', { title: 'Set Alert Thresholds', description: 'Configure alert thresholds for response time, uptime, and consecutive failures.', inputSchema: SetAlertSchema, annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false } }, async (input: SetAlertInput) => { if (!getServer(input.name)) { throw new Error(`Server not registered: ${input.name}`); } return formatResponse(setAlertConfig(input)); } );