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
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | Yes | NinjaOne device ID to put into maintenance | |
| start | Yes | Maintenance window start time as a Unix timestamp (seconds). Use current time for immediate start. | |
| end | Yes | Maintenance window end time as a Unix timestamp (seconds). | |
| disable_alerts | No | Whether to disable alerts during the maintenance window |
Implementation Reference
- src/tools/maintenance.ts:63-81 (handler)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, ); } }, - src/tools/maintenance.ts:46-62 (schema)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"), }, - src/tools/maintenance.ts:42-82 (registration)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, ); } }, );