OPNsense MCP Server
About
Secure MCP server for managing OPNsense firewalls - 62 tools across firewall, DNS, DHCP, VPN, HAProxy, and security auditing with read-only default and automatic rollback protection.
Details
- Author
- lucamarien
- Categories
- Other, Developer Tools
Jump to
Setup
Install OPNsense MCP Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/lucamarien/opnsense-mcp-server
Follow the installation instructions in the repository README, then restart your MCP client.
A secureModel Context Protocol(MCP) server for managing OPNsense firewalls through AI assistants likeClaude Code, Cursor, and other MCP-compatible tools.
81 toolsacross 10 domains: system, firewall, network, DNS, DHCP, VPN, HAProxy, services, diagnostics, and security.
- Python 3.11+
- OPNsense 24.7 or newer— the MCP server relies on the MVC-based API endpoints introduced in OPNsense 24.7. Older versions use a different API structure that is not compatible. The server auto-detects the OPNsense version on first connect and selects the correct endpoint naming (camelCase for pre-25.7, snake_case for 25.7+). OPNsense 26.x is fully supported, including its changed firmware status response format.
This MCP server is designed with security as the primary concern:
- Read-only by default— write operations require explicit opt-in viaOPNSENSE_ALLOW_WRITES=true
- Savepoint/rollback (OPNsense < 26.7 only)— where OPNsense still offers the savepoint API, firewall modifications use its built-in 60-second auto-revert; changes must be explicitly confirmed or they roll back automatically. OPNsense 26.7 removed that API upstream — the server detects the missing endpoint at runtime and applies firewall changes immediately, with no automatic rollback
- Endpoint blocklist— dangerous endpoints (halt,reboot,poweroff,firmware update/upgrade) are hard-blocked at the API client level and can never be called
- API-only— no SSH access, no command execution, no direct config file manipulation
- Local transport— STDIO only, no network-exposed HTTP/SSE endpoints
- No credential exposure— API keys are never included in tool output, logs, or error messages
- Input validation— hostname parameters are validated against shell metacharacter injection
- Sensitive data stripping— config backup strips passwords and keys by default
- Log in to your OPNsense web interface
- Go toSystem > Access > Users
- Either edit an existing user or create a dedicated API user:
- For production use, create a dedicated user (e.g.,mcp-api) with only the privileges needed
- For read-only access, assign the user to a group with read-only API access
Tip:For a read-only setup (recommended for getting started), you don't need to change any permissions — the default API access is sufficient for all read-only tools.
# Using pip pip install opnsense-mcp-server # Using uv (recommended for isolated environments) uv pip install opnsense-mcp-server # Using Docker docker pull uhlenheide/opnsense-mcp-server # From source git clone https://github.com/lucamarien/opnsense-mcp-server cd opnsense-mcp-server pip install -e .
Docker image:the official image isuhlenheide/opnsense-mcp-server, published from this repository by.github/workflows/publish-docker.ymlon everyv*tag. There is nolucamarien/opnsense-mcp-serverimage — earlier README versions named it by mistake.
{ "mcpServers": { "opnsense": { "command": "opnsense-mcp", "env": { "OPNSENSE_URL": "https://192.168.1.1/api", "OPNSENSE_API_KEY": "your-api-key-here", "OPNSENSE_API_SECRET": "your-api-secret-here", "OPNSENSE_VERIFY_SSL": "false", "OPNSENSE_ALLOW_WRITES": "false" } } } }
Alternative:Use"command": "python", "args": ["-m", "opnsense_mcp"]if theopnsense-mcpCLI is not on your PATH.
Or add it globally to~/.claude/claude_code_config.json.
{ "mcpServers": { "opnsense": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "OPNSENSE_URL=https://192.168.1.1/api", "-e", "OPNSENSE_API_KEY=your-api-key-here", "-e", "OPNSENSE_API_SECRET=your-api-secret-here", "-e", "OPNSENSE_VERIFY_SSL=false", "-e", "OPNSENSE_ALLOW_WRITES=false", "uhlenheide/opnsense-mcp-server" ] } } }
Add to your Cursor MCP settings (Settings > MCP):
{ "mcpServers": { "opnsense": { "command": "opnsense-mcp", "env": { "OPNSENSE_URL": "https://192.168.1.1/api", "OPNSENSE_API_KEY": "your-api-key-here", "OPNSENSE_API_SECRET": "your-api-secret-here", "OPNSENSE_VERIFY_SSL": "false" } } } }
Custom ports:If your OPNsense web GUI runs on a non-standard port (e.g., 10443), include it in the URL:https://192.168.1.1:10443/api
Note:Savepoint protection only exists on OPNsense < 26.7. On 26.7+ these tools apply changes immediately and permanently — seeWrite Operations and Savepoints.
Full configuration management for the HAProxy load balancer (requires os-haproxy plugin).
Note:HAProxy changes do NOT use savepoint protection — they apply immediately on reconfigure. Always callopn_haproxy_configtestbeforeopn_reconfigure_haproxy.
Write operations requireOPNSENSE_ALLOW_WRITES=true. OnOPNsense < 26.7, firewall changes additionally go through OPNsense's savepoint mechanism:
- Before any firewall change, a savepoint is created automatically
- The change is applied(rule toggle, add, or delete)
- A 60-second countdown starts— if not confirmed, OPNsense automatically reverts the change
- Useopn_confirm_changeswith the returnedrevisionto make changes permanent
On those versions, if an AI assistant makes a bad firewall change that locks you out, the change reverts automatically within 60 seconds.
OPNsense 26.7 removed the savepoint/rollback API upstream, so there is no auto-revert on 26.7+.The server does not hardcode a version cut-off: it probes for the savepoint endpoint on the first firewall write and, if OPNsense answers that the endpoint does not exist, degrades to direct apply for the rest of the session. Checkopn_mcp_info— itssavepoint_supportfield reportstrue,false, ornullif no write has probed yet. Write tools then return an emptyrevision,opn_confirm_changesanswers withstatus: "not_applicable", and every firewall change is immediate and permanent.
Warning:On OPNsense 26.7+ take a config backup (opn_download_config, or System > Configuration > Backups) before enabling writes, and keep out-of-band access to the box — a rule that locks you out will not revert itself.
Note:opn_reconfigure_unbound,opn_reconfigure_haproxy,opn_reconfigure_ddclient,opn_reconfigure_dnsmasq, andopn_configure_mdns_repeaterrequire writes but don't use savepoints — they apply service configuration changes and are not automatically revertible.
- IPv6 Firewall Rules— Create rules withip_protocol="inet6"(savepoint-protected on OPNsense < 26.7)
- HAProxy IPv6 Bindings— Frontends with[::]:443or[2001:db8::1]:443bind addresses
- HAProxy IPv6 Backends— Servers with IPv6 addresses,resolvePrefer: ipv6on backends
- Dynamic DNS with IPv6— DDNS accounts with IPv6-capable checkip methods
- DHCPv6 Ranges (dnsmasq)— IPv6 DHCP ranges with Router Advertisement configuration
- DNS AAAA Records— Unbound host overrides with IPv6 addresses
- IPv6 Diagnostics— Traceroute withip_version="6", ping via hostname
These settings lack MVC API support in OPNsense and must be configured via the web GUI:
- WAN IPv6 setup— PPPoE with DHCPv6 prefix delegation, static IPv6, SLAAC
- LAN IPv6 addressing— Track Interface mode, static /64 assignment, prefix ID
- Interface assignment— Assigning physical ports to WAN/LAN/OPT roles
- 6to4/6rd tunnels— Transition tunnel mechanisms
- ISC DHCP / Kea DHCPv6: Not implemented. Only dnsmasq (the modern default) is supported for DHCPv6 ranges and Router Advertisements. ISC DHCP is deprecated; Kea DHCPv6 lease visibility is limited in the API.
- radvd: Not implemented as a separate tool set. Dnsmasq handles Router Advertisements natively via range configuration. Only one RA daemon should run per interface.
- Dual-stack firewall rules:inet46(dual-stack) works correctly in MVC API rules (opn_add_firewall_rule). However,inet46in legacy XML filter rules (GUI) silently produces no PF output — this is a known OPNsense bug that only affects legacy rules.
- Legacy GUI rules: Firewall rules created via the traditional OPNsense GUI are not accessible through the MVC API. Useopn_get_config_section("filter")for read-only access.
- Manual (GUI):Configure WAN IPv6 (DHCPv6-PD from ISP or static)
- Manual (GUI):Configure LAN interfaces (Track Interface mode for prefix delegation)
- MCP:Configure Router Advertisements viaopn_add_dnsmasq_rangewith RA flags
- MCP:Create IPv6 firewall rules (ICMPv6 must be allowed for NDP/RA/PMTUD)
- MCP:Add IPv6 DNS records viaopn_add_dns_override
- MCP:Configure Dynamic DNS with IPv6 checkip method
- MCP:Add IPv6 bind addresses to HAProxy frontends
- MCP:Verify withopn_ping,opn_traceroute(ip_version="6"),opn_gateway_status
The server automatically detects the OPNsense version on first connection and selects the correct API endpoint naming convention (camelCase for pre-25.7, snake_case for 25.7+).
Note on firewall rules:opn_list_firewall_rulesshows rules managed via the MVC/automation API. Rules configured through the OPNsense GUI use a legacy format not accessible via this API. This is a known OPNsense limitation.
"Connection refused" or timeout errors
- VerifyOPNSENSE_URLends with/api(e.g.,https://192.168.1.1/api)
- If using a non-standard port, include it:https://192.168.1.1:10443/api
- Ensure the OPNsense web GUI is accessible from the machine running the MCP server
- For self-signed certificates (default OPNsense setup), setOPNSENSE_VERIFY_SSL=false
- For production, install a proper certificate on OPNsense and keepOPNSENSE_VERIFY_SSL=true
- VerifyOPNSENSE_API_KEYandOPNSENSE_API_SECRETare correct
- API keys are case-sensitive — copy them exactly from the downloadedapikey.txt
- Check that the API user is not disabled in OPNsense
- Verify the API user has sufficient privileges for the operations you're attempting
- The API user may lack permissions for the requested endpoint
- For write operations, ensureOPNSENSE_ALLOW_WRITES=trueis set
opn_list_firewall_rulesreturns empty results
- This tool only shows MVC/automation rules, not legacy GUI rules
- Create rules via the automation API oropn_add_firewall_ruleto see them
- The firewall may not have a route to the target host
- Check gateway status withopn_gateway_status
- Default timeout is 30 seconds (30 poll cycles)
opn_download_configshows[REDACTED]values
- This is the default behavior for security. Passinclude_sensitive=trueto include passwords and keys (use with caution in AI conversations)
Write operations fail with "writes not enabled"
- SetOPNSENSE_ALLOW_WRITES=truein your MCP server configuration
- This is intentionally disabled by default for safety
- Therevisionparameter must match exactly what was returned by the write operation
- Confirmations must happen within 60 seconds or the change auto-reverts
- On OPNsense 26.7+ there is no savepoint API: write tools return an emptyrevisionandopn_confirm_changesreturnsstatus: "not_applicable". That is expected, not a failure — the change already applied permanently
# Test API connectivity directly curl -k -u "your-key:your-secret" https://your-opnsense-ip/api/core/firmware/status # Run the server directly python -m opnsense_mcp # Run tests to verify installation pytest -v
# Clone and install dev dependencies git clone https://github.com/lucamarien/opnsense-mcp-server cd opnsense-mcp-server pip install -e ".[dev]" # Run all tests (no real OPNsense needed — all tests use mocked API) pytest -v # Full CI pipeline (lint, format, type check, security scan, tests) make validate # Individual checks ruff check src/ tests/ # Lint (includes bandit security checks) ruff format src/ tests/ # Format mypy src/ --strict # Type checking
Domain-specific guides for common firewall configuration tasks:
These guides show real-world MCP tool usage patterns and explain the security considerations behind each approach.
Chia Health MCP Server — Patient workflow integration for a licensed US telehealth platform. Browse GLP-1 medications (semaglutide, tirzepatide), peptide therapies (sermorelin, NAD+, glutathione), and longevity treatments. Check eligibility, complete intake, sign consents, and manage treatment plans. 30 tools, HIPAA-compliant. All prescriptions evaluated by licensed US healthcare providers and delivered from FDA-regulated pharmacies across 50 states + DC.
Broker + MCP server for last-bidder-wins games on Solana — agents register, auto-fund a Privy wallet, and bid via streamable HTTP
AI-powered no-code app builder with 17 MCP tools — create projects, generate pages from natural language, AI text/image generation (GPT, Claude, Gemini, 14+ models), page CRUD, workflow execution, publish & version control. SSE transport, API key auth.
An mcp server for your food ordering needs.
Agent-to-Agent handoff certification for multi-agent systems — validates context preservation, verifies agent capabilities before handoff, logs transfer chains, and ensures no data loss in agent orchestration.
Unified MCP & skill management gateway with progressive disclosure. Manages multiple MCP servers as Agent Apps, loading tool schemas on demand for 99% context token savings. Shared across Claude Code, Codex, OpenCode and more.
A collection of Model Context Protocol (MCP) servers for various tasks and integrations, supporting both Python and Node.js environments.
Open-souSecurely feeds real security refreshed rules into Cursor, Claude Code, and Windsurf — zero config, no API key.
Health intelligence MCP — access biomarkers, biological age, and personalized longevity action plans from your Aniva profile.
Real-time stock heatmaps and investment tools delivered as interactive React components.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





