opnsense_diag_routes
Displays the current routing table to diagnose network paths and verify route configurations.
Instructions
Show the routing table
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "opnsense_diag_routes"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/diagnostics.ts:55-59 (schema)Tool definition (input schema) for opnsense_diag_routes — defines the tool name, description, and an empty inputSchema (no parameters).
{ name: "opnsense_diag_routes", description: "Show the routing table", inputSchema: { type: "object" as const, properties: {} }, }, - src/tools/diagnostics.ts:267-296 (handler)The handler function (handleDiagnosticsTool) case for 'opnsense_diag_routes' — calls client.get('/diagnostics/interface/getRoutes') and returns the routing table as JSON.
export async function handleDiagnosticsTool( name: string, args: Record<string, unknown>, client: OPNsenseClient, ): Promise<{ content: Array<{ type: "text"; text: string }> }> { try { switch (name) { case "opnsense_diag_arp_table": { const filters = ArpFilterSchema.parse(args); const result = await client.get<unknown>("/diagnostics/interface/getArp"); // Apply client-side filtering if any filter params provided if (filters.ip || filters.mac || filters.interface) { const entries = Array.isArray(result) ? result : []; const filtered = entries.filter((entry: Record<string, unknown>) => { if (filters.ip && !String(entry["ip"] ?? "").includes(filters.ip)) return false; if (filters.mac && !String(entry["mac"] ?? "").toLowerCase().includes(filters.mac.toLowerCase())) return false; if (filters.interface && String(entry["intf"] ?? "") !== filters.interface) return false; return true; }); return { content: [{ type: "text", text: JSON.stringify(filtered, null, 2) }] }; } return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } case "opnsense_diag_routes": { const result = await client.get("/diagnostics/interface/getRoutes"); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/index.ts:39-52 (registration)Tool definitions are spread into allToolDefinitions from diagnosticsToolDefinitions (line 42). The handler is registered in the toolHandlers map at line 61.
const allToolDefinitions = [ ...dnsToolDefinitions, ...firewallToolDefinitions, ...diagnosticsToolDefinitions, ...interfacesToolDefinitions, ...dhcpToolDefinitions, ...systemToolDefinitions, ...acmeToolDefinitions, ...firmwareToolDefinitions, ...routingToolDefinitions, ...vlanToolDefinitions, ...tailscaleToolDefinitions, ...natToolDefinitions, ]; - src/client/opnsense-client.ts:28-35 (helper)The client.get() method used by the handler — sends an HTTP GET request to the OPNsense API and returns the JSON response data.
async get<T>(path: string): Promise<T> { try { const response = await this.http.get<T>(path); return response.data; } catch (error: unknown) { throw extractError(error, `GET ${path}`); } }