ninja_get_device_last_logged_on_user
Retrieve the last logged-on user for any device in your NinjaOne RMM platform to identify recent activity.
Instructions
Get the last user who logged on to a device.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Device ID |
Implementation Reference
- src/tools/devices.ts:291-292 (handler)The handler function that executes the tool logic. It makes a GET request to /device/{id}/last-logged-on-user via the NinjaOneClient.
handler: async ({ id }, client: NinjaOneClient) => client.get(`/device/${id}/last-logged-on-user`), - src/tools/devices.ts:279-290 (schema)The tool definition including name, description, and input schema (requires 'id' as a number).
{ tool: { name: 'ninja_get_device_last_logged_on_user', description: 'Get the last user who logged on to a device.', inputSchema: { type: 'object', required: ['id'], properties: { id: { type: 'number', description: 'Device ID' }, }, }, }, - src/tools/devices.ts:5-5 (registration)The tool is registered as part of the deviceTools array, which is exported and later combined into ALL_TOOLS in src/tools/index.ts.
export const deviceTools: ToolDef[] = [ - src/tools/index.ts:13-24 (registration)ALL_TOOLS combines all tool arrays including deviceTools. The toolMap in src/index.ts maps tool names to handlers for invocation.
export const ALL_TOOLS = [ ...deviceTools, ...organizationTools, ...alertTools, ...activityTools, ...ticketingTools, ...queryTools, ...policyTools, ...userTools, ...backupTools, ...systemTools, ]; - src/tools/types.ts:4-8 (helper)The ToolDef interface defines the structure used for all tool definitions, including the tool metadata and handler function.
export interface ToolDef { tool: Tool; // eslint-disable-next-line @typescript-eslint/no-explicit-any handler: (args: any, client: NinjaOneClient) => Promise<unknown>; }