OPNsense MCP
Provides a safety-focused interface for managing OPNsense firewalls, including reading firewall and NAT rules, packet-filter logs, system and service logs, route tables, and planning or executing configuration changes with risk classification.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OPNsense MCPShow me the firewall rules that are currently active"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OPNsense MCP
A safety-focused remote Model Context Protocol server for OPNsense's MVC API. It exposes stateful Streamable HTTP for remote agents, uses the API's native HTTP Basic authentication upstream, and fails closed when it cannot determine whether an OPNsense command is read-only.
One server instance represents one OPNsense firewall. The firewall URL and API credentials stay in the server environment; agents authenticate to MCP with a separate bearer token and cannot redirect requests to arbitrary network targets. Deploy one isolated instance per firewall when managing multiple appliances.
Architecture
Remote agent --HTTPS + MCP bearer token--> OPNsense MCP --HTTPS + API key/secret--> OPNsenseThe MCP endpoint uses the current Streamable HTTP transport at /mcp. Sessions are stateful so one-time mutation plans remain bound to the agent's MCP session. Sessions are capped, expire after inactivity, and authenticate on every HTTP request.
The built-in HTTP listener is intended to sit behind a TLS reverse proxy, ingress controller, VPN, or private overlay. Do not expose its plain HTTP port directly to an untrusted network.
OPNsense API Model
OPNsense routes API requests as:
/api/<module>/<controller>/<command>/<parameter...>The important behaviors for automation are:
API keys use HTTP Basic authentication: key as username, secret as password.
Access is still constrained by the key owner's OPNsense ACL privileges.
Requests and most responses are JSON. Downloads and streams may not be.
GETandPOSTdo not map cleanly to safe and unsafe operations. Some reads usePOST, and some mutations useGET.Mutable model controllers commonly expose
get,search,add,set,del, andtoggleoperations.Array model records use UUIDs. A
getwithout a UUID often returns a blank record populated with defaults.A successful model mutation usually writes staged configuration. A separate
applyorreconfigureactivates it.Model writes return values such as
{"result":"saved"}or{"result":"failed","validations":...}; HTTP 200 alone does not prove semantic success.OPNsense configuration locking, model validation, revision context, and ACL checks happen server-side and should not be bypassed.
Official references:
https://docs.opnsense.org/development/frontend/controller.html
https://docs.opnsense.org/development/frontend/models_fieldtypes.html
Safety Model
opnsense_request accepts only commands classified as reads. Classification is based on the command, not its HTTP method.
Mutations use two tools:
opnsense_plan_changereports the exact request and its risk without contacting OPNsense.opnsense_execute_changerequires a matching one-time token that expires after five minutes.
Risk classes distinguish staged writes, activation, disruptive service or firmware operations, and catastrophic reset/restore operations. Unknown commands fail closed as mutations.
The write mode is controlled outside the agent:
disabledpermits reads only.planpermits mutation analysis but never creates an execution token.enabledpermits execution with a matching token.
Use a dedicated OPNsense user and grant only the effective privileges required by the intended tools. For read-only deployments, also grant System: Deny config write (user-config-readonly) in OPNsense.
Curated Read Tools
The guarded generic client is supplemented by fixed read-only tools for common operational tasks:
opnsense_get_firewall_logsreads structured packet-filter events.opnsense_get_logsreads bounded pages from core and service logs, including system, configd, gateways, VPN, DNS, DHCP, IDS, routing, and web UI logs.opnsense_list_firewall_rulesreads filter rules visible to the automation API.opnsense_list_nat_rulesreads destination, source, one-to-one, or NPT rules.opnsense_get_route_tablereads either the live kernel routing table or configured static routes.
These tools call fixed query endpoints directly. They cannot select mutating sibling actions such as clearing logs, flushing states, changing rules, or applying configuration. Results remain subject to the API user's OPNsense ACL privileges.
Setup
npm install
npm run buildConfigure the environment using .env.example as a reference. Environment files are not loaded automatically and are ignored by Git. Generate a separate MCP token with openssl rand -hex 32; do not reuse an OPNsense API credential.
Prefer a publicly trusted certificate or set OPNSENSE_CA_FILE to the private CA certificate. OPNSENSE_TLS_VERIFY=false exists for isolated development only.
Run the remote server on loopback for a local TLS reverse proxy:
OPNSENSE_URL=https://firewall.example \
OPNSENSE_API_KEY=... \
OPNSENSE_API_SECRET=... \
MCP_AUTH_TOKEN=<random-token-at-least-32-characters> \
node dist/index.jsThe MCP URL is http://127.0.0.1:3000/mcp. Publish it as HTTPS through the reverse proxy and pass the token as:
Authorization: Bearer <MCP_AUTH_TOKEN>Example remote client configuration for clients that support URL and custom headers:
{
"mcpServers": {
"opnsense": {
"url": "https://mcp.example.com/mcp",
"headers": {
"Authorization": "Bearer ${MCP_AUTH_TOKEN}"
}
}
}
}Client configuration formats vary. Store the token in the client's secret facility rather than committing it in a configuration file.
Docker Compose
compose.yaml binds port 3000 to host loopback so a reverse proxy can terminate TLS safely.
export OPNSENSE_URL=https://firewall.example
export OPNSENSE_API_KEY=...
export OPNSENSE_API_SECRET=...
export MCP_AUTH_TOKEN="$(openssl rand -hex 32)"
export MCP_ALLOWED_HOSTS=mcp.example.com
docker compose up -d --buildWhen connecting directly to localhost:3000 during development, include localhost in MCP_ALLOWED_HOSTS. The unauthenticated health endpoint is available at /health and returns no target or credential details.
Remote Security
MCP_AUTH_TOKENis mandatory for HTTP transport and must contain at least 32 characters.MCP_ALLOWED_HOSTSis mandatory when binding to a non-loopback address and prevents Host-header DNS rebinding.Requests with a browser
Originheader are rejected unless the exact origin appears inMCP_ALLOWED_ORIGINS.MCP_MAX_SESSIONS,MCP_SESSION_TTL_MS, andMCP_RATE_LIMIT_PER_MINUTEbound remote resource use.Keep
OPNSENSE_TLS_VERIFY=true. UseOPNSENSE_CA_FILEfor an internal CA rather than disabling verification.Keep
OPNSENSE_WRITE_MODE=disabledfor monitoring-only deployments.Restrict the OPNsense API user with effective ACL privileges and
user-config-readonlywhere appropriate.Put the MCP endpoint behind HTTPS, firewall policy, and preferably a VPN or private network.
MCP_ALLOW_UNAUTHENTICATED=true exists only for isolated local development and should never be used for a remotely reachable listener.
Stdio Compatibility
Local clients can still launch the server as a subprocess:
OPNSENSE_URL=https://firewall.example \
OPNSENSE_API_KEY=... \
OPNSENSE_API_SECRET=... \
MCP_TRANSPORT=stdio \
node dist/index.jsConfiguration
OPNSENSE_URL: fixed firewall base URL.OPNSENSE_API_KEY: API key for the dedicated OPNsense user.OPNSENSE_API_SECRET: API secret for that key.OPNSENSE_WRITE_MODE:disabled,plan, orenabled.OPNSENSE_CA_FILE: optional private CA PEM file.OPNSENSE_TLS_VERIFY: defaults totrue.MCP_TRANSPORT:httpby default, orstdio.MCP_HOST: listener address, default127.0.0.1.MCP_PORT: listener port, default3000.MCP_PATH: MCP endpoint path, default/mcp.MCP_AUTH_TOKEN: remote-agent bearer token.MCP_ALLOWED_HOSTS: comma-separated hostnames accepted in the HTTP Host header.MCP_ALLOWED_ORIGINS: comma-separated browser origins; empty rejects browser-originated requests.MCP_MAX_SESSIONS: concurrent session cap, default100.MCP_SESSION_TTL_MS: idle session lifetime, default one hour.MCP_RATE_LIMIT_PER_MINUTE: per-client HTTP request limit, default120.
For example, a read call for system status uses:
{
"module": "core",
"controller": "system",
"command": "status"
}Current Limits
OPNsense does not publish a complete OpenAPI contract. The generated reference identifies routes and likely methods, but usually omits body schemas.
Plugin endpoints exist only when their packages are installed and ACL-authorized.
Semantic response validation is not yet endpoint-specific.
The lexical risk classifier is intentionally conservative. Curated tools should eventually use an audited endpoint manifest with explicit request and response schemas.
Plan tokens reduce accidental and mismatched execution, but MCP hosts should still present destructive tool approval to a human.
Remote authentication currently uses a deployment-wide static bearer token rather than an OAuth authorization server. Use separate deployments or an authenticating reverse proxy when agents require distinct identities.
Session state is in memory and is not shared across replicas. Run one replica unless external session storage and routing affinity are added.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Remote MCP for A2A caller identity, scope policy, verdict receipts, and audit history.
Remote MCP for Android CLI agent build gate, structured receipts, audit logs, and reviewer-ready evi
Remote MCP for Copilot CLI switch gate MCP, structured receipts, audit logs, and reviewer-ready evid
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ethereal-Jay/opnsense-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server