Skip to main content
Glama

get_device_activities

Retrieve recent activity logs for a NinjaOne device to monitor events like alerts, script executions, and status changes.

Instructions

Get recent activity log for a specific device. Shows events such as alerts triggered, scripts run, and status changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idYesNinjaOne device ID
page_sizeNoNumber of activity entries to return
afterNoActivity ID cursor for pagination
activity_typeNoFilter by activity type (e.g., CONDITION, PATCH, SCRIPT)

Implementation Reference

  • Handler function for get_device_activities tool that makes an API call to /device/${device_id}/activities with pagination and activity type filtering, then returns JSON results or error message
    async ({ device_id, page_size, after, activity_type }) => {
      const params: Record<string, string> = {
        pageSize: String(page_size),
      };
      if (after !== undefined) params.after = String(after);
      if (activity_type) params.activityType = activity_type;
    
      try {
        const results = await client.get(
          `/device/${device_id}/activities`,
          params,
        );
        return toolResult(JSON.stringify(results, null, 2));
      } catch (error) {
        return toolResult(
          `Error fetching device activities: ${error}`,
          true,
        );
      }
    },
  • Zod schema definition for get_device_activities tool parameters: device_id (required number), page_size (optional number, default 50), after (optional number for pagination), activity_type (optional string filter)
    {
      device_id: z.number().describe("NinjaOne device ID"),
      page_size: z
        .number()
        .optional()
        .default(50)
        .describe("Number of activity entries to return"),
      after: z
        .number()
        .optional()
        .describe("Activity ID cursor for pagination"),
      activity_type: z
        .string()
        .optional()
        .describe("Filter by activity type (e.g., CONDITION, PATCH, SCRIPT)"),
    },
  • Registration of get_device_activities tool with the MCP server, including tool name, description, parameter schema, and handler function
    // ── Get Device Activities ────────────────────────────────────────────
    server.tool(
      "get_device_activities",
      "Get recent activity log for a specific device. Shows events such as alerts triggered, scripts run, and status changes.",
      {
        device_id: z.number().describe("NinjaOne device ID"),
        page_size: z
          .number()
          .optional()
          .default(50)
          .describe("Number of activity entries to return"),
        after: z
          .number()
          .optional()
          .describe("Activity ID cursor for pagination"),
        activity_type: z
          .string()
          .optional()
          .describe("Filter by activity type (e.g., CONDITION, PATCH, SCRIPT)"),
      },
      async ({ device_id, page_size, after, activity_type }) => {
        const params: Record<string, string> = {
          pageSize: String(page_size),
        };
        if (after !== undefined) params.after = String(after);
        if (activity_type) params.activityType = activity_type;
    
        try {
          const results = await client.get(
            `/device/${device_id}/activities`,
            params,
          );
          return toolResult(JSON.stringify(results, null, 2));
        } catch (error) {
          return toolResult(
            `Error fetching device activities: ${error}`,
            true,
          );
        }
      },
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions 'recent activity log' and example event types, but does not disclose behavioral traits such as pagination behavior (implied by 'after' parameter but not explained), rate limits, authentication requirements, or what 'recent' means temporally. The description adds some context but leaves significant gaps for a tool with 4 parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the core purpose and followed by specific examples of event types. Every sentence earns its place with no wasted words, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is moderately complete but lacks details on behavioral aspects like pagination, rate limits, or response format. It covers the purpose and examples of activity types, but for a tool with 4 parameters and no structured output, more context on usage and results would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters. The description adds minimal value beyond the schema by implying filtering via 'activity_type' with examples (e.g., CONDITION, PATCH, SCRIPT), but does not provide additional syntax or format details. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and resource 'recent activity log for a specific device', specifying the scope with 'Shows events such as alerts triggered, scripts run, and status changes.' This distinguishes it from sibling tools like get_device (general device info) or list_device_alerts (only alerts).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving activity logs for a specific device, but does not explicitly state when to use this tool versus alternatives like list_device_alerts (for alerts only) or get_device_jobs (for job-related activities). No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fredriksknese/mcp-ninjaone'

If you have feedback or need assistance with the MCP directory API, please join our Discord server