ninja_list_devices
List all managed devices in NinjaOne. Apply filters by organization or status, and paginate results using page size and cursor.
Instructions
List all managed devices. Use df for device filter expressions (e.g. "org = 1", "status = APPROVED"). Paginate with pageSize and after (last device ID).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| df | No | Device filter expression | |
| pageSize | No | Max devices to return | |
| after | No | Last device ID for pagination cursor |
Implementation Reference
- src/tools/devices.ts:5-21 (handler)Handler for ninja_list_devices tool. Calls GET /devices with optional query parameters (df, pageSize, after), filtering out null/empty values via the clean() utility.
export const deviceTools: ToolDef[] = [ { tool: { name: 'ninja_list_devices', description: 'List all managed devices. Use df for device filter expressions (e.g. "org = 1", "status = APPROVED"). Paginate with pageSize and after (last device ID).', inputSchema: { type: 'object', properties: { df: { type: 'string', description: 'Device filter expression' }, pageSize: { type: 'number', description: 'Max devices to return' }, after: { type: 'number', description: 'Last device ID for pagination cursor' }, }, }, }, handler: async (args, client: NinjaOneClient) => client.get('/devices', clean(args)), }, - src/tools/devices.ts:5-21 (schema)Input schema for ninja_list_devices: an object with optional 'df' (string filter), 'pageSize' (number), and 'after' (number cursor for pagination) properties.
export const deviceTools: ToolDef[] = [ { tool: { name: 'ninja_list_devices', description: 'List all managed devices. Use df for device filter expressions (e.g. "org = 1", "status = APPROVED"). Paginate with pageSize and after (last device ID).', inputSchema: { type: 'object', properties: { df: { type: 'string', description: 'Device filter expression' }, pageSize: { type: 'number', description: 'Max devices to return' }, after: { type: 'number', description: 'Last device ID for pagination cursor' }, }, }, }, handler: async (args, client: NinjaOneClient) => client.get('/devices', clean(args)), }, - src/tools/index.ts:4-4 (registration)Import of deviceTools from devices.ts into the ALL_TOOLS collection, which is registered with the MCP server via toolMap.
import { deviceTools } from './devices.js'; - src/index.ts:24-24 (registration)The toolMap is built from ALL_TOOLS by mapping tool name to handler. This is where ninja_list_devices gets registered for runtime dispatch.
const toolMap = new Map(ALL_TOOLS.map((def) => [def.tool.name, def.handler]));