opnsense_nat_source_list
Lists all Source NAT (outbound) rules with details including UUID, interface, source/destination, target, and enabled state.
Instructions
List all Source NAT (outbound) rules. Read-only. Returns rule UUID, sequence, interface, source/destination, target, enabled state.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/nat.ts:216-219 (handler)The handler function for the opnsense_nat_source_list tool. It calls client.get('/firewall/source_nat/search_rule') to list all Source NAT (outbound) rules from OPNsense and returns the result as JSON.
case "opnsense_nat_source_list": { const result = await client.get("/firewall/source_nat/search_rule"); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/tools/nat.ts:90-96 (schema)The tool definition and registration entry for opnsense_nat_source_list in the natToolDefinitions array. Defines the tool name, description, and an empty inputSchema (no parameters required).
export const natToolDefinitions = [ { name: "opnsense_nat_source_list", description: "List all Source NAT (outbound) rules. Read-only. Returns rule UUID, sequence, interface, source/destination, target, enabled state.", inputSchema: { type: "object" as const, properties: {} }, }, - src/index.ts:70-70 (registration)Registration of the handleNatTool as the handler for all NAT tools, including opnsense_nat_source_list. Each tool definition in natToolDefinitions maps to handleNatTool.
for (const def of natToolDefinitions) toolHandlers.set(def.name, handleNatTool); - src/index.ts:39-51 (registration)The tool definitions from nat.ts are spread into allToolDefinitions, which is used to populate the ListToolsRequestSchema response.
const allToolDefinitions = [ ...dnsToolDefinitions, ...firewallToolDefinitions, ...diagnosticsToolDefinitions, ...interfacesToolDefinitions, ...dhcpToolDefinitions, ...systemToolDefinitions, ...acmeToolDefinitions, ...firmwareToolDefinitions, ...routingToolDefinitions, ...vlanToolDefinitions, ...tailscaleToolDefinitions, ...natToolDefinitions, - src/client/opnsense-client.ts:6-26 (helper)The OPNsenseClient class that provides the get/post methods used by the handler to call the OPNsense REST API. The handler uses client.get('/firewall/source_nat/search_rule') to fetch source NAT rules.
export class OPNsenseClient { private readonly http: AxiosInstance; constructor(private readonly config: OPNsenseConfig) { const baseURL = config.url.replace(/\/+$/, "") + "/api"; this.http = axios.create({ baseURL, timeout: config.timeout ?? 30000, auth: { username: config.apiKey, password: config.apiSecret, }, httpsAgent: new https.Agent({ rejectUnauthorized: config.verifySsl ?? true, }), headers: { Accept: "application/json", }, }); }