delete_monitor
Permanently remove a CronAlert uptime monitor and its entire check history. This action cannot be undone.
Instructions
Permanently delete a monitor and all its check history. This cannot be undone.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Monitor ID |
Implementation Reference
- src/index.ts:171-174 (handler)The handler function that executes the delete_monitor tool. It accepts an id parameter and makes a DELETE request to the /monitors/{id} API endpoint, returning the response as JSON.
async ({ id }) => { const data = await apiRequest(`/monitors/${id}`, { method: "DELETE" }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/index.ts:159-175 (registration)The complete registration of the delete_monitor tool with the MCP server, including the tool name, description, schema, hints (destructive), and the handler function.
server.tool( "delete_monitor", "Permanently delete a monitor and all its check history. This cannot be undone.", { id: z.string().describe("Monitor ID"), }, { readOnlyHint: false, destructiveHint: true, openWorldHint: false, }, async ({ id }) => { const data = await apiRequest(`/monitors/${id}`, { method: "DELETE" }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/index.ts:162-164 (schema)Zod schema defining the input validation for delete_monitor tool. It requires a single parameter 'id' as a string representing the Monitor ID.
{ id: z.string().describe("Monitor ID"), }, - src/index.ts:20-42 (helper)The apiRequest helper function used by delete_monitor handler to make authenticated HTTP requests to the CronAlert API. It handles API key retrieval, request headers, error handling, and JSON response parsing.
async function apiRequest( path: string, options: RequestInit = {} ): Promise<unknown> { const apiKey = getApiKey(); const url = `${API_BASE}${path}`; const response = await fetch(url, { ...options, headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, ...options.headers, }, }); if (!response.ok) { const body = await response.text(); throw new Error(`API error ${response.status}: ${body}`); } return response.json(); }