ninja_list_organizations
Retrieve a list of organizations (clients/customers) from NinjaOne with support for filtering by criteria and paginating results.
Instructions
List all organizations (clients/customers) in NinjaOne. Supports filtering and pagination.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageSize | No | Max organizations to return | |
| after | No | Last org ID from previous page for pagination | |
| of | No | Organization filter expression |
Implementation Reference
- src/tools/organizations.ts:5-20 (handler)Definition of 'ninja_list_organizations' tool including its input schema and handler. The handler function calls client.get('/organizations', clean(args)) to list all organizations with optional filtering and pagination.
export const organizationTools: ToolDef[] = [ { tool: { name: 'ninja_list_organizations', description: 'List all organizations (clients/customers) in NinjaOne. Supports filtering and pagination.', inputSchema: { type: 'object', properties: { pageSize: { type: 'number', description: 'Max organizations to return' }, after: { type: 'number', description: 'Last org ID from previous page for pagination' }, of: { type: 'string', description: 'Organization filter expression' }, }, }, }, handler: async (args, client: NinjaOneClient) => client.get('/organizations', clean(args)), }, - src/tools/organizations.ts:5-20 (schema)Input schema for 'ninja_list_organizations': optional pageSize (number), after (number for pagination), and of (string for organization filter expression).
export const organizationTools: ToolDef[] = [ { tool: { name: 'ninja_list_organizations', description: 'List all organizations (clients/customers) in NinjaOne. Supports filtering and pagination.', inputSchema: { type: 'object', properties: { pageSize: { type: 'number', description: 'Max organizations to return' }, after: { type: 'number', description: 'Last org ID from previous page for pagination' }, of: { type: 'string', description: 'Organization filter expression' }, }, }, }, handler: async (args, client: NinjaOneClient) => client.get('/organizations', clean(args)), }, - src/tools/index.ts:13-24 (registration)All tools including organizationTools are aggregated in ALL_TOOLS array and exposed via the MCP server.
export const ALL_TOOLS = [ ...deviceTools, ...organizationTools, ...alertTools, ...activityTools, ...ticketingTools, ...queryTools, ...policyTools, ...userTools, ...backupTools, ...systemTools, ]; - src/index.ts:24-33 (registration)toolMap is built from ALL_TOOLS mapping tool name to handler, and tools are listed via ListToolsRequestSchema handler.
const toolMap = new Map(ALL_TOOLS.map((def) => [def.tool.name, def.handler])); const server = new Server( { name: 'ninjaone-mcp', version: '1.0.0' }, { capabilities: { tools: {} } }, ); server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ALL_TOOLS.map((def) => def.tool), })); - src/utils.ts:2-6 (helper)The clean() utility strips null/empty values from args before passing them as query parameters to the API call.
export function clean(args: Record<string, any>): Record<string, unknown> { return Object.fromEntries( Object.entries(args).filter(([, v]) => v != null && v !== ''), ); }