Skip to main content
Glama

list_alerts

Retrieve active alerts across NinjaOne devices with filtering by severity, device, and pagination. View alert details including UID, severity, message, device, and trigger time.

Instructions

List active alerts and conditions across all devices in NinjaOne. Returns alert UID, severity, message, device, and trigger time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
severityNoFilter alerts by severity level
device_filterNoFilter expression to limit devices (e.g., 'org = 123')
page_sizeNoNumber of alerts to return
afterNoAlert ID cursor for pagination

Implementation Reference

  • The async handler function that executes the list_alerts tool logic. It builds query parameters (severity, device_filter, page_size, after) and calls client.get('/alerts', params) to fetch alerts from the NinjaOne API.
    async ({ severity, device_filter, page_size, after }) => {
      const params: Record<string, string> = {
        pageSize: String(page_size),
      };
      if (severity) params.severity = severity;
      if (device_filter) params.df = device_filter;
      if (after !== undefined) params.after = String(after);
    
      try {
        const results = await client.get("/alerts", params);
        return toolResult(JSON.stringify(results, null, 2));
      } catch (error) {
        return toolResult(`Error listing alerts: ${error}`, true);
      }
    },
  • Zod schema definition for the list_alerts tool input parameters. Defines severity (enum), device_filter (string), page_size (number, default 100), and after (number) parameters with their descriptions.
      severity: z
        .enum(["NONE", "MINOR", "MODERATE", "MAJOR", "CRITICAL"])
        .optional()
        .describe("Filter alerts by severity level"),
      device_filter: z
        .string()
        .optional()
        .describe("Filter expression to limit devices (e.g., 'org = 123')"),
      page_size: z
        .number()
        .optional()
        .default(100)
        .describe("Number of alerts to return"),
      after: z
        .number()
        .optional()
        .describe("Alert ID cursor for pagination"),
    },
  • Complete registration of the list_alerts tool with the MCP server using server.tool(). Includes the tool name, description, schema, and handler function.
    server.tool(
      "list_alerts",
      "List active alerts and conditions across all devices in NinjaOne. Returns alert UID, severity, message, device, and trigger time.",
      {
        severity: z
          .enum(["NONE", "MINOR", "MODERATE", "MAJOR", "CRITICAL"])
          .optional()
          .describe("Filter alerts by severity level"),
        device_filter: z
          .string()
          .optional()
          .describe("Filter expression to limit devices (e.g., 'org = 123')"),
        page_size: z
          .number()
          .optional()
          .default(100)
          .describe("Number of alerts to return"),
        after: z
          .number()
          .optional()
          .describe("Alert ID cursor for pagination"),
      },
      async ({ severity, device_filter, page_size, after }) => {
        const params: Record<string, string> = {
          pageSize: String(page_size),
        };
        if (severity) params.severity = severity;
        if (device_filter) params.df = device_filter;
        if (after !== undefined) params.after = String(after);
    
        try {
          const results = await client.get("/alerts", params);
          return toolResult(JSON.stringify(results, null, 2));
        } catch (error) {
          return toolResult(`Error listing alerts: ${error}`, true);
        }
      },
    );
  • The NinjaOneClient.get() method that performs the actual HTTP GET request to the NinjaOne API endpoints. Used by list_alerts handler to fetch alert data.
    async get(
      path: string,
      params?: Record<string, string>,
    ): Promise<unknown> {
      return this.request("GET", path, undefined, params);
    }
  • Utility function that formats the tool response into the MCP standard format with content array and optional error flag.
    function toolResult(text: string, isError = false) {
      return { content: [{ type: "text" as const, text }], isError };
    }

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/fredriksknese/mcp-ninjaone'

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