Skip to main content
Glama

create_maintenance_window

Schedule device maintenance to suppress alerts during planned downtime. Disables alerting for specified periods to prevent notifications during maintenance activities.

Instructions

Create a maintenance window for a device to suppress alerts during planned maintenance. The window disables alerting for the specified duration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idYesNinjaOne device ID to put into maintenance
startYesMaintenance window start time as a Unix timestamp (seconds). Use current time for immediate start.
endYesMaintenance window end time as a Unix timestamp (seconds).
disable_alertsNoWhether to disable alerts during the maintenance window

Implementation Reference

  • Handler function that creates a maintenance window for a device. Accepts device_id, start/end timestamps, and disable_alerts flag. Makes a PUT request to /device/{device_id}/maintenance endpoint with the maintenance window data and returns success message with timestamps or error.
    async ({ device_id, start, end, disable_alerts }) => {
      const data: Record<string, unknown> = {
        start,
        end,
        disabledFeatures: disable_alerts ? ["ALERTS"] : [],
      };
    
      try {
        await client.put(`/device/${device_id}/maintenance`, data);
        return toolResult(
          `Maintenance window created for device ${device_id}.\nStart: ${new Date(start * 1000).toISOString()}\nEnd: ${new Date(end * 1000).toISOString()}`,
        );
      } catch (error) {
        return toolResult(
          `Error creating maintenance window: ${error}`,
          true,
        );
      }
    },
  • Input schema definition using Zod. Defines four parameters: device_id (required number), start (required number - Unix timestamp), end (required number - Unix timestamp), and disable_alerts (optional boolean, defaults to true). Each parameter has descriptive metadata.
      device_id: z.number().describe("NinjaOne device ID to put into maintenance"),
      start: z
        .number()
        .describe(
          "Maintenance window start time as a Unix timestamp (seconds). Use current time for immediate start.",
        ),
      end: z
        .number()
        .describe(
          "Maintenance window end time as a Unix timestamp (seconds).",
        ),
      disable_alerts: z
        .boolean()
        .optional()
        .default(true)
        .describe("Whether to disable alerts during the maintenance window"),
    },
  • Complete tool registration using server.tool(). Registers 'create_maintenance_window' with description, input schema, and handler function. Part of registerMaintenanceTools function that registers multiple maintenance-related tools to the MCP server.
    server.tool(
      "create_maintenance_window",
      "Create a maintenance window for a device to suppress alerts during planned maintenance. The window disables alerting for the specified duration.",
      {
        device_id: z.number().describe("NinjaOne device ID to put into maintenance"),
        start: z
          .number()
          .describe(
            "Maintenance window start time as a Unix timestamp (seconds). Use current time for immediate start.",
          ),
        end: z
          .number()
          .describe(
            "Maintenance window end time as a Unix timestamp (seconds).",
          ),
        disable_alerts: z
          .boolean()
          .optional()
          .default(true)
          .describe("Whether to disable alerts during the maintenance window"),
      },
      async ({ device_id, start, end, disable_alerts }) => {
        const data: Record<string, unknown> = {
          start,
          end,
          disabledFeatures: disable_alerts ? ["ALERTS"] : [],
        };
    
        try {
          await client.put(`/device/${device_id}/maintenance`, data);
          return toolResult(
            `Maintenance window created for device ${device_id}.\nStart: ${new Date(start * 1000).toISOString()}\nEnd: ${new Date(end * 1000).toISOString()}`,
          );
        } catch (error) {
          return toolResult(
            `Error creating maintenance window: ${error}`,
            true,
          );
        }
      },
    );

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