Slim OPNsense MCP Server for managing firewall infrastructure via REST API.
mcp-opnsense
Slim OPNsense MCP Server for managing firewall infrastructure via the OPNsense REST API.
No SSH. No shell execution. API-only. 3 runtime dependencies.
Features
62 tools across 8 domains:
- DNS/Unbound (12) — Host overrides, forwards, blocklist, cache management
- Firewall (8) — Rules, aliases, NAT, apply changes
- Diagnostics (8) — ARP, routes, ping, traceroute, DNS lookup, firewall states/logs
- Interfaces (3) — List, configuration, statistics (read-only)
- DHCP (5) — Leases, static mappings (ISC DHCPv4 + Kea dual support)
- System (7) — Info, backup (list/download/revert), certificate listing, service control
- ACME/Let's Encrypt (14) — Accounts, challenges, certificates, renewal, settings
- Firmware/Plugins (5) — Version info, plugin management
Quick Start
npm install
cp .env.example .env # Edit with your OPNsense API credentials
npm run build
node dist/index.js # stdio transport for MCP
Claude Code Integration
Add to .mcp.json in your project root:
{
"mcpServers": {
"opnsense": {
"command": "node",
"args": ["/path/to/mcp-opnsense/dist/index.js"],
"env": {
"OPNSENSE_URL": "https://your-opnsense.example.com",
"OPNSENSE_API_KEY": "your-api-key",
"OPNSENSE_API_SECRET": "your-api-secret",
"OPNSENSE_VERIFY_SSL": "true"
}
}
}
}
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
OPNSENSE_URL |
Yes | — | OPNsense base URL (e.g. https://192.168.1.1) |
OPNSENSE_API_KEY |
Yes | — | API key for authentication |
OPNSENSE_API_SECRET |
Yes | — | API secret for authentication |
OPNSENSE_VERIFY_SSL |
No | true |
Set to false for self-signed certificates |
OPNSENSE_TIMEOUT |
No | 30000 |
Request timeout in milliseconds |
Available Tools (62)
DNS/Unbound (12 tools)
| Tool | Description |
|---|---|
opnsense_dns_list_overrides |
List host overrides (A/AAAA/CNAME) |
opnsense_dns_add_override |
Add a host override record |
opnsense_dns_delete_override |
Delete a host override by UUID |
opnsense_dns_list_forwards |
List DNS-over-TLS forwarding servers |
opnsense_dns_add_forward |
Add a DNS forwarding server |
opnsense_dns_delete_forward |
Delete a DNS forward by UUID |
opnsense_dns_list_blocklist |
List domain overrides (blocked domains) |
opnsense_dns_block_domain |
Block a domain |
opnsense_dns_unblock_domain |
Unblock a domain by UUID |
opnsense_dns_flush_cache |
Flush DNS cache and DNSBL data |
opnsense_dns_diagnostics |
Dump DNS cache for diagnostics |
opnsense_dns_apply |
Apply DNS changes (reconfigure Unbound) |
Firewall (8 tools)
| Tool | Description |
|---|---|
opnsense_fw_list_rules |
List all firewall filter rules |
opnsense_fw_add_rule |
Create a firewall rule |
opnsense_fw_update_rule |
Update a firewall rule by UUID |
opnsense_fw_delete_rule |
Delete a firewall rule by UUID |
opnsense_fw_toggle_rule |
Enable/disable a firewall rule |
opnsense_fw_list_aliases |
List firewall aliases (host, network, port, URL) |
opnsense_fw_manage_alias |
Create/update/delete aliases |
opnsense_fw_apply |
Apply pending firewall changes |
Diagnostics (8 tools)
| Tool | Description |
|---|---|
opnsense_diag_arp_table |
Show ARP table (IP-to-MAC mappings) |
opnsense_diag_routes |
Show routing table |
opnsense_diag_ping |
Ping a host from OPNsense |
opnsense_diag_traceroute |
Traceroute to a destination |
opnsense_diag_dns_lookup |
Perform DNS lookup from OPNsense |
| `opnsense_diag_f |
Tools (7)
opnsense_dns_list_overridesList host overrides (A/AAAA/CNAME)opnsense_dns_add_overrideAdd a host override recordopnsense_dns_delete_overrideDelete a host override by UUIDopnsense_fw_list_rulesList all firewall filter rulesopnsense_fw_add_ruleCreate a firewall ruleopnsense_diag_pingPing a host from OPNsenseopnsense_diag_tracerouteTraceroute to a destinationEnvironment Variables
OPNSENSE_URLrequiredOPNsense base URLOPNSENSE_API_KEYrequiredAPI key for authenticationOPNSENSE_API_SECRETrequiredAPI secret for authenticationOPNSENSE_VERIFY_SSLSet to false for self-signed certificatesOPNSENSE_TIMEOUTRequest timeout in millisecondsConfiguration
{"mcpServers": {"opnsense": {"command": "node", "args": ["/path/to/mcp-opnsense/dist/index.js"], "env": {"OPNSENSE_URL": "https://your-opnsense.example.com", "OPNSENSE_API_KEY": "your-api-key", "OPNSENSE_API_SECRET": "your-api-secret", "OPNSENSE_VERIFY_SSL": "true"}}}}