Skip to main content
Glama
itunified-io

mcp-opnsense

by itunified-io

opnsense_diag_log_resolver

Retrieve recent Unbound DNS resolver logs from your OPNsense firewall. Use the limit parameter to control the number of entries returned (up to 5000).

Instructions

Retrieve recent Unbound DNS resolver log entries.

Input Schema

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

Implementation Reference

  • Handler for opnsense_diag_log_resolver: parses args with LogQuerySchema, calls fetchLogWithFallback(client, 'resolver', limit), returns JSON result.
    case "opnsense_diag_log_resolver": {
      const parsed = LogQuerySchema.parse(args);
      const result = await fetchLogWithFallback(client, "resolver", parsed.limit);
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    }
  • LogQuerySchema defines the input schema for log-resolver: optional limit (1-5000, default 500) coerced from string.
    const LogQuerySchema = z.object({
      limit: z.coerce.number().int().min(1).max(5000).optional().default(500),
    });
  • Tool definition registration in diagnosticsToolDefinitions array with name 'opnsense_diag_log_resolver', description, and input schema.
    {
      name: "opnsense_diag_log_resolver",
      description: "Retrieve recent Unbound DNS resolver log entries.",
      inputSchema: {
        type: "object" as const,
        properties: {
          limit: { type: "number", description: "Number of log entries (1-5000, default 500)" },
        },
      },
    },
  • fetchLogWithFallback helper function that tries multiple API endpoint variants (get, post search, get core/) to retrieve log entries, used by the resolver 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 [];
    }
  • isNonEmptyLogPayload helper function that checks if a log payload contains data (array length > 0, or object with rows/total).
    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;
    }
Behavior2/5

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

With no annotations, the description fails to disclose what 'recent' means, any side effects, or whether the operation is read-only. The description is too brief to cover behavioral traits.

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, clear sentence that efficiently conveys the purpose without extraneous words.

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 the tool's simplicity (one optional parameter, no output schema), the description is adequate but could benefit from noting the default limit or that entries are from the tail of the log.

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 coverage is 100%, so baseline is 3. The description adds no additional meaning beyond the schema's parameter description for 'limit'.

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 (retrieve), resource (Unbound DNS resolver log entries), and differentiates from sibling diag_log_* tools by specifying the log source.

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

Usage Guidelines2/5

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

No guidance on when to use this tool vs alternatives like opnsense_diag_log_system or opnsense_diag_dns_lookup is provided.

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