NetDefense for OPNsense
OfficialProvides tools for managing OPNsense firewalls, including device management, configuration sync, health checks, firmware upgrades, backups, and remote console access.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
ndcli
Manage a fleet of OPNsense firewalls from your terminal — or let any MCP-compatible AI agent do it.
ndcli is the command-line interface and MCP server for NetDefense for OPNsense: list devices, push config, run health checks, roll out firmware, manage backups, and orchestrate an entire organizational unit or fleet from one command — scriptable end to end, no web app required.
Give an AI agent your firewall fleet
The second binary in this repo, netdefense-mcp, exposes 182 MCP tools covering every domain ndcli does — devices, organizations, OUs, sync, tasks, run commands, schedules, snippets, software policies, templates, networks, variables, backups, firmware tracks, support tickets, the responder console, and persistent remote consoles. Point Claude, or any other MCP-compatible client, at it and it can inspect and operate your entire fleet the same way a human operator would from the CLI — not a single device, the whole organization.
Start with the sharp edge, because it's the one that matters. ndcli.device.console_exec runs arbitrary shell commands on a device, with administrative privilege, and takes no confirmation flag. It is gated on the caller's role — a read-only token is refused before a stream ever opens — but an agent holding a write-scoped token has a shell. Scope the token you hand an agent accordingly, and if you want a hard limit that no token can cross, set the device-side remote-access policy on the firewall itself (Services → NetDefense → Settings), which caps what any session may be regardless of who asks.
The rest of the AI-facing surface has real, but narrower, guardrails:
Destructive and fleet-wide tools require an explicit confirmation. Every tool whose name says delete, remove, rename, revoke or disable (
ndcli.device.remove,ndcli.org.delete,ndcli.schedule.disableand the rest), detaching backup from its schedule (ndcli.backup.config_set_schedule), and fleet-wide actions such asndcli.device.approve_all,ndcli.sync.applyand thendcli.run.*commands, return a dry-run preview unless the caller passesconfirm=true— an agent can't wipe a fleet on its first hallucinated call. Many other changes act at once: most tools that create or add things, every enable, attaching backup to a schedule, replying on a ticket, andconsole_exec(see above).High-impact tools ask you, not the agent. Approving devices (
ndcli.device.approve,ndcli.device.approve_all), removing, powering off or restarting devices, attaching snippets, software policies, templates or devices (ndcli.template.add_snippet,ndcli.template.add_software,ndcli.ou.template_add,ndcli.ou.add_device), changing a role or sending an invite, opening a console session, and every tool that reads or writes a local file (the attachment tools andattach_paths) run only after you approve the exact call in a prompt your MCP client shows you (MCP elicitation). The prompt shows what the server looked up, such as a pending device's uuid and registration time. If that changes while the prompt is open, say a device registers, the call is refused (APPROVAL_STALE) and nothing runs.confirm=truealone does not run them: the agent can set it, but it can't answer the prompt. A client that cannot show the prompt getsAPPROVAL_UNAVAILABLEand thendclicommand to run yourself. Setting"NDCLI_MCP_APPROVAL": "off"in the server'senvruns these tools without asking, as a plainconfirm=truecall: it reopens the gap the prompt closes, since an agent steered by text in a device name, a ticket or a variable can then approve devices, attach configuration or upload files on its own. The prompt comes once perconsole_open, not perconsole_exec, so command output read during a session can still steer the commands that follow.It structurally cannot mint non-expiring credentials.
ndcli.auth.token_createonly accepts bounded lifetimes (30–365 days) over MCP; anever-expiring personal access token can only be created interactively on the CLI — the MCP tool schema doesn't offer the option, and the handler rejects it if forced.Secrets never enter the AI-facing toolset. Backup encryption keys and storage credentials have no MCP tool and no MCP-exposed field. They're reachable only via
ndcli backup encryption-keyandndcli backup config seton the CLI. The organization's agent token, which registers devices, is returned only byndcli.org.create, once;ndcli.org.describeleaves it out, andndcli org describeshows it.Ticket attachment tools touch the local filesystem.
ndcli.support.attachment_upload,ndcli.respond.attachment_uploadand theattach_pathsof the create, reply and note tools read a local path on the machine running the server (a regular file, at most 25 MiB), and only inside the directories listed undermcp.attachment_dirsin ndcli'sconfig.yaml(none until you add one;~/is your home directory, and each directory covers its subtree). ndcli's own configuration and credential files are never uploaded;ndcli.support.attachment_downloadandndcli.respond.attachment_downloadwrite one, always as a new file namednetdefense-<code>-<random>in the directory set undermcp.download_dirinconfig.yaml(the server's working directory when unset; some MCP clients start servers in/, where nothing can be written): the filename an attachment carries is chosen by whoever uploaded it and is never used on disk, and the tools take no destination path and never overwrite. They are the only tools in the set that read or write local files.Interactive login and account deletion stay CLI-only. Browser-based login and
ndcli auth deletearen't exposed to MCP — they need a human in the loop by design. Note this is about those commands:ndcli device connectis CLI-only too, but the underlying device-session capability is reachable over MCP through theconsole_*tools, so treat "CLI-only command" and "not reachable by an agent" as different things.
Point any MCP-compatible agent at the netdefense-mcp binary (config shape varies by client; this is the common form):
{
"mcpServers": {
"netdefense": {
"command": "netdefense-mcp",
"env": { "NDCLI_TOKEN": "ndpat_..." }
}
}
}The server uses ndcli's default config. To point it at another one, add "args": ["--conf", "/path/to/config.yaml"] with an absolute path; the file must exist. netdefense-mcp --help lists its flags and exits.
Every tool carries MCP annotations: readOnlyHint on the tools that change nothing, and destructiveHint on those that overwrite, remove or act on a device. To offer an agent only the read-only tools, start the server with --read-only (or set "NDCLI_MCP_READ_ONLY": "true" in its env). Names, device facts, variable values and ticket text in tool results are written by organization members, devices and support, not by you, so an agent can meet text that tries to instruct it; the server tells the agent to treat them as data, and read-only mode is the hard limit when you only need answers.
Each tool result has two text blocks. The first is the server's own header: success, error_code and pagination when they apply, and result, a note naming the tag of the second block. The second is the response JSON (success, data, message, error, pagination) between <ndcli-data-TAG> and </ndcli-data-TAG> lines, with a new random tag for each result. Text in the data can't close the block early, because the encoder writes < and > as \u003c and \u003e. Programs read the response by dropping the first and last line of the second block; results carry no structuredContent. The ndcli://org/{name} and ndcli://org/{name}/devices resources use the same block, as text/plain.
Full tool list and setup: https://netdefense.io/docs/mcp/
Related MCP server: OPNsense MCP Server
Install
Homebrew (macOS / Linux)
brew install netdefense-io/tap/ndcliScoop (Windows)
scoop bucket add netdefense https://github.com/netdefense-io/scoop-bucket
scoop install ndcliBinary downloads
Pre-built archives for macOS (amd64/arm64), Linux (amd64/arm64), and Windows (amd64) are on the ndcli-releases page. Each archive contains ndcli, netdefense-mcp, the netdefense terminal UI and netdefense-connect.
netdefense-connect is a companion the other three start for a remote session when the organization uses the direct-peer + encrypted relay transport. It is looked up beside the program that starts it, so keep the four in one directory. THIRD_PARTY_NOTICES, in the same archive, holds the licences of the software they are built from.
From source
Requires Go 1.27.4+.
git clone https://github.com/netdefense-io/NDCLI.git
cd NDCLI
make build build-mcp
make build-connect # the companion for direct-peer + encrypted relay sessionsUsage
ndcli auth login # interactive login, opens a browser
ndcli config set org acme-corp
ndcli device list # see the fleet
ndcli device approve edge-fw-03 # bring a newly-registered device under management
ndcli run ping --device edge-fw-03 --host 1.1.1.1
ndcli sync apply --ou branch-offices
ndcli device health edge-fw-03 -f detailedEvery command supports -f table|simple|detailed|json. Run ndcli --help for the full surface.
Exit status: 0 on success, 1 when a command fails, and 3 when a bulk command (device approve-all, sync apply) succeeded for some devices and failed for others.
Security model
NDAgent — the daemon that runs on the firewall — understands exactly eleven named operations: ping, config sync, config pull, restart, reboot, shutdown, backup, remote session, plugin install, firmware upgrade, firmware track step. It rejects anything else.
Every command dispatched to a device is Ed25519-signed, covering the operation, the target device, an expiry, and a strictly-increasing per-device sequence number — so a command can't be replayed, reordered, or forged by a compromised relay in the middle. The agent opens no listening ports; it only dials out over TLS, so there's nothing on the device for an attacker to scan or connect to.
What that does and doesn't buy you. All of the above is integrity on the command channel: it stops tampering, replay, misdelivery, and a compromised relay minting instructions. It is not containment. One of those eleven operations is a remote session, and a session reaches a shell — so a compromised control plane, or a stolen credential with write access, is not stopped by any of it. The honest claim is cryptographic integrity on the channel, not "an attacker with your credentials can't do anything".
The limit that is enforced against a caller who already holds write access is set on the device, not here: NDAgent's remote-access policy caps every session at full, readonly (web UI only — no shell, no SSH, no exec stream) or disabled, and the control plane cannot raise it.
Full writeup and threat model: https://netdefense.io/security
What's open source
NDAgent and NDCLI (this repo) — the daemon that runs on your firewall, and the CLI/MCP server you run from your workstation — are open source under Apache-2.0. The source is public, so your team can also review the code that runs on your firewall and your workstation: build it from source, and read how the agent verifies signed commands, the agent's operation set and the MCP tool definitions directly.
The control plane that coordinates a fleet — the API, the web app, scheduling, and the device relay — is closed-source SaaS, with a free tier for personal use. See netdefense.io/pricing for details.
Links
MCP setup: https://netdefense.io/docs/mcp/
Security model: https://netdefense.io/security
NDAgent (the firewall-side agent, also open source): https://github.com/netdefense-io/NDAgent
License
Apache License 2.0 — see LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
MCP gateway and cloud hosting for MCP servers, agents and apps like RAG, managed from your agent.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server implementation for managing OPNsense firewalls. This server allows Claude and other MCP-compatible clients to interact with all features exposed by the OPNsense API.1AGPL 3.0
- AlicenseNot gradedqualityCmaintenanceA modular MCP server that provides access to over 2,000 OPNsense firewall management methods through 88 specialized tools. It enables AI assistants to securely manage firewall rules, network interfaces, and system diagnostics using a type-safe TypeScript interface.99MIT
- AlicenseAqualityBmaintenanceA secure MCP server for managing OPNsense firewalls through AI assistants. Provides 81 tools across system, firewall, network, DNS, DHCP, VPN, HAProxy, services, diagnostics, and security domains.81261 PyPI30MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI clients to manage OPNsense firewall, interfaces, DHCP, DNS, routes, and services via natural language through 42 MCP tools.1MIT