ninja_get_device_active_jobs
Retrieve all active jobs currently running on a specific device. Use this to monitor job status and activity in real-time.
Instructions
Get currently running jobs on a device.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Device ID |
Implementation Reference
- src/tools/devices.ts:294-307 (handler)The full tool definition and handler for ninja_get_device_active_jobs. The handler makes a GET request to /device/{id}/jobs via the NinjaOneClient.
{ tool: { name: 'ninja_get_device_active_jobs', description: 'Get currently running jobs on a device.', inputSchema: { type: 'object', required: ['id'], properties: { id: { type: 'number', description: 'Device ID' }, }, }, }, handler: async ({ id }, client: NinjaOneClient) => client.get(`/device/${id}/jobs`), }, - src/tools/devices.ts:298-304 (schema)Input schema for the tool: requires a numeric 'id' parameter representing the Device ID.
inputSchema: { type: 'object', required: ['id'], properties: { id: { type: 'number', description: 'Device ID' }, }, }, - src/tools/index.ts:13-24 (registration)deviceTools array (which includes ninja_get_device_active_jobs) is spread into the ALL_TOOLS collection for registration.
export const ALL_TOOLS = [ ...deviceTools, ...organizationTools, ...alertTools, ...activityTools, ...ticketingTools, ...queryTools, ...policyTools, ...userTools, ...backupTools, ...systemTools, ]; - src/index.ts:35-59 (registration)The MCP server's CallTool handler: looks up the tool by name from toolMap (built from ALL_TOOLS) and invokes its handler.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const handler = toolMap.get(name); if (!handler) { return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true, }; } try { const result = await handler( (args ?? {}) as Record<string, unknown>, ninjaClient, ); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (err) { return { content: [{ type: 'text', text: err instanceof Error ? err.message : String(err) }], isError: true, }; } - src/tools/types.ts:1-8 (helper)The ToolDef interface that defines the shape of each tool definition, including the handler signature.
import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { NinjaOneClient } from '../client.js'; export interface ToolDef { tool: Tool; // eslint-disable-next-line @typescript-eslint/no-explicit-any handler: (args: any, client: NinjaOneClient) => Promise<unknown>; }