ninja_submit_os_patch_apply
Apply OS patches on a device, either specific patches or all approved pending patches.
Instructions
Apply OS patches on a device. Omit patchIds to apply all approved pending patches.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Device ID | |
| patchIds | No | Specific patch IDs to apply (omit to apply all approved pending patches) |
Implementation Reference
- src/tools/devices.ts:437-456 (handler)The tool definition for 'ninja_submit_os_patch_apply'. Defines the schema (name, description, inputSchema with 'id' required and optional 'patchIds' array) and the handler that POSTs to /device/{id}/patch/os/apply with optional patchIds body.
{ tool: { name: 'ninja_submit_os_patch_apply', description: 'Apply OS patches on a device. Omit patchIds to apply all approved pending patches.', inputSchema: { type: 'object', required: ['id'], properties: { id: { type: 'number', description: 'Device ID' }, patchIds: { type: 'array', items: { type: 'number' }, description: 'Specific patch IDs to apply (omit to apply all approved pending patches)', }, }, }, }, handler: async ({ id, patchIds }, client: NinjaOneClient) => client.post(`/device/${id}/patch/os/apply`, patchIds ? { patchIds } : undefined), }, - src/tools/devices.ts:5-5 (registration)The deviceTools array is exported from this file and imported into tools/index.ts (line 4), which is then collected into ALL_TOOLS and used to register the tool with the MCP server in src/index.ts (line 24).
export const deviceTools: ToolDef[] = [ - src/tools/index.ts:4-4 (registration)Imports deviceTools from devices.ts, which includes the ninja_submit_os_patch_apply tool.
import { deviceTools } from './devices.js'; - src/index.ts:24-24 (registration)Builds a tool map from ALL_TOOLS, using the tool name as key and handler as value, enabling lookup on CallToolRequestSchema.
const toolMap = new Map(ALL_TOOLS.map((def) => [def.tool.name, def.handler])); - src/tools/types.ts:1-8 (schema)Defines the ToolDef interface used to type the tool definition objects, including the Tool schema and handler function signature.
import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { NinjaOneClient } from '../client.js'; export interface ToolDef { tool: Tool; // eslint-disable-next-line @typescript-eslint/no-explicit-any handler: (args: any, client: NinjaOneClient) => Promise<unknown>; }