ninja_get_device_scripting_options
Retrieve available scripts and built-in actions for a device to see what can be executed.
Instructions
Get available scripts and built-in actions that can be run on a device.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Device ID | |
| lang | No | Language tag for localized display names |
Implementation Reference
- src/tools/devices.ts:335-337 (handler)The handler function that executes the tool logic. It destructures 'id' from args, passes remaining params to the NinjaOne API via GET /device/{id}/scripting/options, with undefined/empty values cleaned out by the 'clean' utility.
handler: async ({ id, ...params }, client: NinjaOneClient) => client.get(`/device/${id}/scripting/options`, clean(params)), }, - src/tools/devices.ts:326-333 (schema)The input schema validation for the tool. Requires 'id' (number) and optionally accepts 'lang' (string for localized display names).
inputSchema: { type: 'object', required: ['id'], properties: { id: { type: 'number', description: 'Device ID' }, lang: { type: 'string', description: 'Language tag for localized display names' }, }, }, - src/tools/devices.ts:322-337 (registration)The tool is registered as a ToolDef object in the deviceTools array at src/tools/devices.ts. This array is exported and merged into ALL_TOOLS in src/tools/index.ts, which is then used to build a handler map and tool list in src/index.ts.
{ tool: { name: 'ninja_get_device_scripting_options', description: 'Get available scripts and built-in actions that can be run on a device.', inputSchema: { type: 'object', required: ['id'], properties: { id: { type: 'number', description: 'Device ID' }, lang: { type: 'string', description: 'Language tag for localized display names' }, }, }, }, handler: async ({ id, ...params }, client: NinjaOneClient) => client.get(`/device/${id}/scripting/options`, clean(params)), }, - src/utils.ts:2-6 (helper)The 'clean' utility used by the handler to strip undefined/null/empty values from the params before passing them as query parameters to the API.
export function clean(args: Record<string, any>): Record<string, unknown> { return Object.fromEntries( Object.entries(args).filter(([, v]) => v != null && v !== ''), ); }