Skip to main content
Glama
itunified-io

mcp-opnsense

by itunified-io

opnsense_diag_log_system

Retrieve recent OPNsense system log entries to diagnose kernel and generic system events. Configure the number of entries returned to control log depth.

Instructions

Retrieve recent OPNsense system log entries (kernel, generic system events).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of log entries (1-5000, default 500)

Implementation Reference

  • Handler case for opnsense_diag_log_system: parses args with LogQuerySchema (limit 1-5000, default 500), then calls fetchLogWithFallback(client, 'system', limit) which tries multiple API endpoint variants to retrieve system log entries, and returns the result as JSON text.
    case "opnsense_diag_log_system": {
      const parsed = LogQuerySchema.parse(args);
      const result = await fetchLogWithFallback(client, "system", parsed.limit);
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    }
  • fetchLogWithFallback helper function: tries three API endpoint variants (GET /diagnostics/log/system?limit=N, POST /diagnostics/log/system/search with rowCount, GET /diagnostics/log/core/system?limit=N) and returns the first non-empty response. Used by the log system handler.
    async function fetchLogWithFallback(
      client: OPNsenseClient,
      category: string,
      limit: number,
    ): Promise<unknown> {
      type Variant = { method: "get" | "post"; path: string; body?: unknown };
      const variants: Variant[] = [
        { method: "get", path: `/diagnostics/log/${category}?limit=${limit}` },
        {
          method: "post",
          path: `/diagnostics/log/${category}/search`,
          body: { current: 1, rowCount: limit, sort: {}, searchPhrase: "" },
        },
        { method: "get", path: `/diagnostics/log/core/${category}?limit=${limit}` },
      ];
    
      let lastResult: unknown = null;
      let lastError: unknown = null;
    
      for (const variant of variants) {
        try {
          const result =
            variant.method === "get"
              ? await client.get<unknown>(variant.path)
              : await client.post<unknown>(variant.path, variant.body);
    
          // A non-empty payload wins. Treat the result as non-empty if:
          //   - array with length > 0
          //   - object with rows[].length > 0
          //   - object with any other non-empty data field
          if (isNonEmptyLogPayload(result)) {
            return result;
          }
          lastResult = result;
        } catch (error) {
          lastError = error;
          // Endpoint not present (404) → keep trying. Other errors propagate
          // only if every variant fails.
        }
      }
    
      if (lastResult !== null) return lastResult;
      if (lastError) throw lastError;
      return [];
    }
    
    function isNonEmptyLogPayload(payload: unknown): boolean {
      if (Array.isArray(payload)) return payload.length > 0;
      if (payload && typeof payload === "object") {
        const obj = payload as Record<string, unknown>;
        if (Array.isArray(obj["rows"]) && (obj["rows"] as unknown[]).length > 0) return true;
        if (typeof obj["total"] === "number" && obj["total"] > 0) return true;
      }
      return false;
    }
  • LogQuerySchema - Zod schema for log query input validation: limit is a coerced integer between 1 and 5000, defaults to 500.
    const LogQuerySchema = z.object({
      limit: z.coerce.number().int().min(1).max(5000).optional().default(500),
    });
  • Tool definition registration for opnsense_diag_log_system: name, description ('Retrieve recent OPNsense system log entries'), and input schema (limit parameter). Exported in diagnosticsToolDefinitions array.
    {
      name: "opnsense_diag_log_system",
      description: "Retrieve recent OPNsense system log entries (kernel, generic system events).",
      inputSchema: {
        type: "object" as const,
        properties: {
          limit: { type: "number", description: "Number of log entries (1-5000, default 500)" },
        },
      },
    },
  • src/index.ts:61-61 (registration)
    Registration: maps all diagnosticsToolDefinitions (including opnsense_diag_log_system) to the handleDiagnosticsTool handler in the central toolHandlers map via server.setRequestHandler(CallToolRequestSchema).
    for (const def of diagnosticsToolDefinitions) toolHandlers.set(def.name, handleDiagnosticsTool);
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It mentions 'recent' but does not specify the time window, pagination, ordering, or whether entries are sorted chronologically. The return format is omitted, which limits transparency.

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 a single concise sentence that immediately conveys the tool's purpose with no wasted words. It is front-loaded 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?

For a simple log retrieval tool with one parameter, the description is mostly complete but lacks details about the output format (e.g., JSON array of lines). Without an output schema, more context about return structure would improve completeness.

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?

The schema provides full description for the only parameter 'limit' (1-5000, default 500). The description adds no additional meaning beyond the schema, achieving baseline adequacy.

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 tool retrieves recent OPNsense system log entries, specifying the resource (system log entries) and scope (kernel, generic system events). It effectively distinguishes itself from sibling log tools like opnsense_diag_log_gateways and opnsense_diag_log_resolver.

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 use for system logs, but lacks explicit guidance on when to use this tool versus alternatives (e.g., gateways, resolver logs). No when-not-to-use 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/itunified-io/mcp-opnsense'

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