Skip to main content
Glama
jaredhobbs

cronalert-mcp

by jaredhobbs

create_monitor

Set up automated URL monitoring to detect downtime by scheduling periodic checks and configuring alerts for failures.

Instructions

Create a new uptime monitor that periodically checks a URL and alerts on failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesDisplay name for the monitor
urlYesURL to monitor
checkIntervalNoCheck interval in seconds (default 180)
methodNoHTTP method (default GET)GET
expectedStatusCodeNoExpected HTTP status code (default 200)

Implementation Reference

  • The create_monitor handler function that executes when the tool is called. It constructs a request with name, url, checkInterval, method, and expectedStatusCode, then POSTs to /monitors endpoint via apiRequest.
    async ({ name, url, checkInterval, method, expectedStatusCode }) => {
      const data = await apiRequest("/monitors", {
        method: "POST",
        body: JSON.stringify({ name, url, checkInterval, method, expectedStatusCode }),
      });
      return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
    }
  • Input schema validation for create_monitor using zod. Defines required fields: name (string), url (string with URL validation), and optional fields: checkInterval (number, default 180), method (enum, default GET), expectedStatusCode (number, default 200).
    {
      name: z.string().describe("Display name for the monitor"),
      url: z.string().url().describe("URL to monitor"),
      checkInterval: z.number().int().positive().optional().default(180).describe("Check interval in seconds (default 180)"),
      method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]).optional().default("GET").describe("HTTP method (default GET)"),
      expectedStatusCode: z.number().int().optional().default(200).describe("Expected HTTP status code (default 200)"),
    },
  • src/index.ts:82-105 (registration)
    Full tool registration for create_monitor using server.tool(). Includes tool name, description, schema definition, execution hints (readOnlyHint: false, destructiveHint: true), and the async handler function.
    server.tool(
      "create_monitor",
      "Create a new uptime monitor that periodically checks a URL and alerts on failure.",
      {
        name: z.string().describe("Display name for the monitor"),
        url: z.string().url().describe("URL to monitor"),
        checkInterval: z.number().int().positive().optional().default(180).describe("Check interval in seconds (default 180)"),
        method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]).optional().default("GET").describe("HTTP method (default GET)"),
        expectedStatusCode: z.number().int().optional().default(200).describe("Expected HTTP status code (default 200)"),
      },
      {
    
          readOnlyHint: false,
          destructiveHint: true,
          openWorldHint: false,
      },
      async ({ name, url, checkInterval, method, expectedStatusCode }) => {
        const data = await apiRequest("/monitors", {
          method: "POST",
          body: JSON.stringify({ name, url, checkInterval, method, expectedStatusCode }),
        });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • The apiRequest helper function used by create_monitor handler. Handles API authentication via Bearer token, sets Content-Type headers, makes HTTP requests to the CronAlert API, and handles error responses.
    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();
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jaredhobbs/cronalert-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server