ninja_query_installed_os_patches
Retrieve OS patch installation history across all managed devices. Filter by status and dates to track patch compliance.
Instructions
Query OS patch install history across all managed devices.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| df | No | Device filter expression | |
| pageSize | No | Max results to return | |
| cursor | No | Pagination cursor from previous response | |
| status | No | Filter by install status | |
| installedBefore | No | Filter patches installed before this date | |
| installedAfter | No | Filter patches installed after this date |
Implementation Reference
- src/tools/queries.ts:11-28 (handler)The queryTool factory function generates the handler for ninja_query_installed_os_patches. The handler (line 26) calls client.get(path, clean(args)), which makes a GET request to '/queries/os-patch-installs' with cleaned arguments.
function queryTool( name: string, description: string, path: string, extraProps: Record<string, unknown> = {}, ): ToolDef { return { tool: { name, description, inputSchema: { type: 'object', properties: { ...basePaginationProps, ...extraProps }, }, }, handler: async (args, client: NinjaOneClient) => client.get(path, clean(args)), }; } - src/tools/queries.ts:69-78 (schema)The tool definition/schema for ninja_query_installed_os_patches. It specifies the name, description, API path '/queries/os-patch-installs', and input schema with base pagination props (df, pageSize, cursor) plus extra filter props (status, installedBefore, installedAfter).
queryTool( 'ninja_query_installed_os_patches', 'Query OS patch install history across all managed devices.', '/queries/os-patch-installs', { status: { type: 'string', description: 'Filter by install status' }, installedBefore: { type: 'string', description: 'Filter patches installed before this date' }, installedAfter: { type: 'string', description: 'Filter patches installed after this date' }, }, ), - src/tools/index.ts:13-24 (registration)The tool (via queryTools array) is spread into ALL_TOOLS which is the master list of all tool definitions registered with the MCP server.
export const ALL_TOOLS = [ ...deviceTools, ...organizationTools, ...alertTools, ...activityTools, ...ticketingTools, ...queryTools, ...policyTools, ...userTools, ...backupTools, ...systemTools, ]; - src/index.ts:31-33 (registration)The MCP server registers the tool for listing via ListToolsRequestSchema handler, making it available to clients.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ALL_TOOLS.map((def) => def.tool), })); - src/index.ts:35-60 (registration)The MCP server dispatches tool calls to the handler via CallToolRequestSchema, looking up the handler by tool name in the toolMap.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const handler = toolMap.get(name); if (!handler) { return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true, }; } try { const result = await handler( (args ?? {}) as Record<string, unknown>, ninjaClient, ); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (err) { return { content: [{ type: 'text', text: err instanceof Error ? err.message : String(err) }], isError: true, }; } });