get_device_software
Retrieve installed software inventory for a NinjaOne device to monitor applications and manage device configurations.
Instructions
Get the list of installed software on a specific device.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | Yes | NinjaOne device ID |
Implementation Reference
- src/tools/devices.ts:135-145 (handler)Handler function that executes the get_device_software tool logic. It calls the NinjaOne API endpoint /device/{device_id}/software and returns the installed software list as JSON.
async ({ device_id }) => { try { const result = await client.get(`/device/${device_id}/software`); return toolResult(JSON.stringify(result, null, 2)); } catch (error) { return toolResult( `Error fetching device software: ${error}`, true, ); } }, - src/tools/devices.ts:132-134 (schema)Input schema definition using Zod. Defines a required device_id parameter (number) to identify which device's software to retrieve.
{ device_id: z.number().describe("NinjaOne device ID"), }, - src/tools/devices.ts:129-146 (registration)Tool registration using server.tool() which registers the 'get_device_software' tool with its name, description, schema, and handler function.
server.tool( "get_device_software", "Get the list of installed software on a specific device.", { device_id: z.number().describe("NinjaOne device ID"), }, async ({ device_id }) => { try { const result = await client.get(`/device/${device_id}/software`); return toolResult(JSON.stringify(result, null, 2)); } catch (error) { return toolResult( `Error fetching device software: ${error}`, true, ); } }, ); - src/tools/devices.ts:5-7 (helper)Helper function toolResult() that formats the response content for MCP tools, creating a standardized text response with optional error flag.
function toolResult(text: string, isError = false) { return { content: [{ type: "text" as const, text }], isError }; } - src/ninjaone-client.ts:105-110 (helper)NinjaOneClient.get() method used by the handler to make authenticated API calls to the NinjaOne REST API endpoints.
async get( path: string, params?: Record<string, string>, ): Promise<unknown> { return this.request("GET", path, undefined, params); }