ninja_get_device_activities
Retrieve activity logs for a specific device by ID. Filter results using page size, newerThan, olderThan, and language parameters.
Instructions
Get activity log for a specific device.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Device ID | |
| pageSize | No | Max activities to return (default 200, max 1000) | |
| newerThan | No | Return activities with ID newer than this value | |
| olderThan | No | Return activities with ID older than this value | |
| lang | No | Language tag (e.g. en) |
Implementation Reference
- src/tools/devices.ts:100-101 (handler)The handler function for ninja_get_device_activities — destructures id and remaining params, then makes a GET request to /device/{id}/activities with cleaned query parameters.
handler: async ({ id, ...params }, client: NinjaOneClient) => client.get(`/device/${id}/activities`, clean(params)), - src/tools/devices.ts:88-98 (schema)Input schema for ninja_get_device_activities — requires 'id' (number), with optional pageSize, newerThan, olderThan, and lang.
inputSchema: { type: 'object', required: ['id'], properties: { id: { type: 'number', description: 'Device ID' }, pageSize: { type: 'number', description: 'Max activities to return (default 200, max 1000)' }, newerThan: { type: 'number', description: 'Return activities with ID newer than this value' }, olderThan: { type: 'number', description: 'Return activities with ID older than this value' }, lang: { type: 'string', description: 'Language tag (e.g. en)' }, }, }, - src/tools/devices.ts:84-102 (registration)The tool is registered as part of the deviceTools array in src/tools/devices.ts, which is exported and then included in ALL_TOOLS in src/tools/index.ts (line 14), and registered with the MCP server in src/index.ts (line 24).
{ tool: { name: 'ninja_get_device_activities', description: 'Get activity log for a specific device.', inputSchema: { type: 'object', required: ['id'], properties: { id: { type: 'number', description: 'Device ID' }, pageSize: { type: 'number', description: 'Max activities to return (default 200, max 1000)' }, newerThan: { type: 'number', description: 'Return activities with ID newer than this value' }, olderThan: { type: 'number', description: 'Return activities with ID older than this value' }, lang: { type: 'string', description: 'Language tag (e.g. en)' }, }, }, }, handler: async ({ id, ...params }, client: NinjaOneClient) => client.get(`/device/${id}/activities`, clean(params)), }, - src/utils.ts:1-6 (helper)The clean() helper function used by the handler to strip null/undefined/empty string values from query parameters before making the API call.
// 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 !== ''), ); }