ninja_list_activities
Get system activity logs filtered by class, date range, type, status, user, or device.
Instructions
Get the system activity log. Filter by class (SYSTEM/DEVICE/USER), date range, type, status, user, or device.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| class | No | Activity class filter (default: ALL) | |
| before | No | Return activities before this date/time (ISO 8601) | |
| after | No | Return activities after this date/time (ISO 8601) | |
| olderThan | No | Return activities with ID older than this value (pagination) | |
| newerThan | No | Return activities with ID newer than this value (pagination) | |
| type | No | Activity type filter | |
| status | No | Activity status filter | |
| user | No | Filter by technician username | |
| seriesUid | No | Return activities related to a specific alert series UID | |
| df | No | Device filter expression | |
| pageSize | No | Max results to return (10–1000, default 200) | |
| lang | No | Language tag (e.g. en) | |
| tz | No | Time zone tag (e.g. America/Chicago) |
Implementation Reference
- src/tools/activities.ts:49-49 (handler)The handler function for ninja_list_activities. Makes a GET request to /activities with cleaned query parameters via the NinjaOneClient.
handler: async (args, client: NinjaOneClient) => client.get('/activities', clean(args)), - src/tools/activities.ts:11-47 (schema)Input schema definition for ninja_list_activities, defining all accepted parameters including class filter, date range, pagination, type, status, user, seriesUid, device filter, pageSize, lang, and tz.
inputSchema: { type: 'object', properties: { class: { type: 'string', enum: ['SYSTEM', 'DEVICE', 'USER', 'ALL'], description: 'Activity class filter (default: ALL)', }, before: { type: 'string', description: 'Return activities before this date/time (ISO 8601)', }, after: { type: 'string', description: 'Return activities after this date/time (ISO 8601)', }, olderThan: { type: 'number', description: 'Return activities with ID older than this value (pagination)', }, newerThan: { type: 'number', description: 'Return activities with ID newer than this value (pagination)', }, type: { type: 'string', description: 'Activity type filter' }, status: { type: 'string', description: 'Activity status filter' }, user: { type: 'string', description: 'Filter by technician username' }, seriesUid: { type: 'string', description: 'Return activities related to a specific alert series UID', }, df: { type: 'string', description: 'Device filter expression' }, pageSize: { type: 'number', description: 'Max results to return (10–1000, default 200)' }, lang: { type: 'string', description: 'Language tag (e.g. en)' }, tz: { type: 'string', description: 'Time zone tag (e.g. America/Chicago)' }, }, }, - src/tools/activities.ts:5-51 (registration)The tool is defined as part of the activityTools array, which is exported and then aggregated into ALL_TOOLS in src/tools/index.ts and registered with the MCP server in src/index.ts.
export const activityTools: ToolDef[] = [ { tool: { name: 'ninja_list_activities', description: 'Get the system activity log. Filter by class (SYSTEM/DEVICE/USER), date range, type, status, user, or device.', inputSchema: { type: 'object', properties: { class: { type: 'string', enum: ['SYSTEM', 'DEVICE', 'USER', 'ALL'], description: 'Activity class filter (default: ALL)', }, before: { type: 'string', description: 'Return activities before this date/time (ISO 8601)', }, after: { type: 'string', description: 'Return activities after this date/time (ISO 8601)', }, olderThan: { type: 'number', description: 'Return activities with ID older than this value (pagination)', }, newerThan: { type: 'number', description: 'Return activities with ID newer than this value (pagination)', }, type: { type: 'string', description: 'Activity type filter' }, status: { type: 'string', description: 'Activity status filter' }, user: { type: 'string', description: 'Filter by technician username' }, seriesUid: { type: 'string', description: 'Return activities related to a specific alert series UID', }, df: { type: 'string', description: 'Device filter expression' }, pageSize: { type: 'number', description: 'Max results to return (10–1000, default 200)' }, lang: { type: 'string', description: 'Language tag (e.g. en)' }, tz: { type: 'string', description: 'Time zone tag (e.g. America/Chicago)' }, }, }, }, handler: async (args, client: NinjaOneClient) => client.get('/activities', clean(args)), }, ]; - src/utils.ts:2-6 (helper)The clean() utility function used by the handler to strip null/empty values from the arguments before passing them as query parameters.
export function clean(args: Record<string, any>): Record<string, unknown> { return Object.fromEntries( Object.entries(args).filter(([, v]) => v != null && v !== ''), ); } - src/client.ts:47-57 (helper)The NinjaOneClient.get() method that the handler delegates to, performing an authenticated GET request to the NinjaOne API.
async get<T = unknown>(path: string, params?: Record<string, unknown>): Promise<T> { try { const res = await this.http.get<T>(path, { params, headers: await this.authHeader(), }); return res.data; } catch (err) { throw new Error(`GET ${path} failed: ${apiError(err)}`); } }