ninja_list_contacts
List all contacts from your NinjaOne account. Supports pagination with page size and cursor (last contact ID).
Instructions
List all contacts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageSize | No | Max results to return | |
| after | No | Last contact ID for pagination |
Implementation Reference
- src/tools/users.ts:104-104 (handler)The handler function for ninja_list_contacts that calls client.get('/contacts', clean(args)) to fetch contacts from the NinjaOne API.
handler: async (args, client: NinjaOneClient) => client.get('/contacts', clean(args)), - src/tools/users.ts:96-102 (schema)Input schema for ninja_list_contacts: accepts optional pageSize (number) and after (last contact ID for pagination) parameters.
inputSchema: { type: 'object', properties: { pageSize: { type: 'number', description: 'Max results to return' }, after: { type: 'number', description: 'Last contact ID for pagination' }, }, }, - src/tools/users.ts:92-105 (registration)Tool definition registration as part of the userTools array. The tool name 'ninja_list_contacts' is registered with its description, schema, and handler.
{ tool: { name: 'ninja_list_contacts', description: 'List all contacts.', inputSchema: { type: 'object', properties: { pageSize: { type: 'number', description: 'Max results to return' }, after: { type: 'number', description: 'Last contact ID for pagination' }, }, }, }, handler: async (args, client: NinjaOneClient) => client.get('/contacts', clean(args)), }, - src/tools/index.ts:13-24 (registration)userTools (which contains ninja_list_contacts) is spread into the ALL_TOOLS array, making it available to the MCP server.
export const ALL_TOOLS = [ ...deviceTools, ...organizationTools, ...alertTools, ...activityTools, ...ticketingTools, ...queryTools, ...policyTools, ...userTools, ...backupTools, ...systemTools, ]; - src/utils.ts:1-6 (helper)The clean() utility function used by the handler to filter out null/empty arguments before passing them as query parameters.
// eslint-disable-next-line @typescript-eslint/no-explicit-any export function clean(args: Record<string, any>): Record<string, unknown> { return Object.fromEntries( Object.entries(args).filter(([, v]) => v != null && v !== ''), ); }