opnsense_diag_fw_states
Display all active firewall connection tracking states to monitor current network flows and diagnose firewall performance.
Instructions
List active firewall connection tracking states
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/diagnostics.ts:121-125 (registration)Tool definition/registration for opnsense_diag_fw_states in diagnosticsToolDefinitions array — declares the tool name, description, and empty input schema to the MCP ListTools protocol.
{ name: "opnsense_diag_fw_states", description: "List active firewall connection tracking states", inputSchema: { type: "object" as const, properties: {} }, }, - src/tools/diagnostics.ts:391-394 (handler)Handler logic for opnsense_diag_fw_states — calls OPNsense API endpoint /diagnostics/firewall/query_states via POST and returns the result as JSON.
case "opnsense_diag_fw_states": { const result = await client.post("/diagnostics/firewall/query_states"); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/index.ts:61-61 (registration)Registration of the diagnostics tool handler function (including opnsense_diag_fw_states) into the MCP server's tool handler map.
for (const def of diagnosticsToolDefinitions) toolHandlers.set(def.name, handleDiagnosticsTool); - src/index.ts:42-42 (registration)Diagnostics tool definitions (including opnsense_diag_fw_states) spread into the allToolDefinitions array for ListTools response.
...diagnosticsToolDefinitions, - src/client/opnsense-client.ts:49-83 (helper)The OPNsenseClient.post() method used by the handler to send the HTTP POST request to the OPNsense API.
async post<T>(path: string, data?: unknown): Promise<T> { try { const response = await this.http.post<T>(path, data ?? {}, { headers: { "Content-Type": "application/json" }, }); return response.data; } catch (error: unknown) { throw extractError(error, `POST ${path}`); } } async delete<T>(path: string): Promise<T> { try { const response = await this.http.delete<T>(path); return response.data; } catch (error: unknown) { throw extractError(error, `DELETE ${path}`); } } static fromEnv(): OPNsenseClient { const url = process.env["OPNSENSE_URL"]; const apiKey = process.env["OPNSENSE_API_KEY"]; const apiSecret = process.env["OPNSENSE_API_SECRET"]; if (!url) throw new Error("OPNSENSE_URL environment variable is required"); if (!apiKey) throw new Error("OPNSENSE_API_KEY environment variable is required"); if (!apiSecret) throw new Error("OPNSENSE_API_SECRET environment variable is required"); const verifySsl = process.env["OPNSENSE_VERIFY_SSL"] !== "false"; const timeout = parseInt(process.env["OPNSENSE_TIMEOUT"] ?? "30000", 10); return new OPNsenseClient({ url, apiKey, apiSecret, verifySsl, timeout }); } }