mcp-opnsense

mcp-opnsense

MCP server for managing OPNsense firewalls, providing read-only tools for firewall rules, aliases, interface statistics, and gateway status with multi-instance support.

Category
Visit Server

README

mcp-opnsense

MCP server for managing OPNsense firewalls via Claude Code. Read-only tools first — write support planned.

Setup

1. Install dependencies

npm install
npm run build

2. Create OPNsense API user

⚠️ Do not use the admin/root user. Create a dedicated user with minimal privileges.

2a. Create a group

  1. System → Access → Groups → Add

    • Group name: mcp_readonly
    • Assign these privileges:
    Privilege Needed for
    GUI - Firewall: Rules list-firewall-rules, get-firewall-rule, list-aliases, get-alias
    GUI - Gateways get-gateway-status
    GUI - Diagnostics: Interface get-interface-stats
  2. Save

2b. Create a user

  1. System → Access → Users → Add

    • Username: mcp
    • Password: (generate a strong random password)
    • Group: mcp_readonly
  2. Save

2c. Generate API key

  1. System → Access → API Keys → Add
    • User: mcp
    • Download the key file (INI/txt format)
    • Keep it secure — it contains the key and secret

Note: OPNsense ACLs are page-level — the "Firewall: Rules" privilege grants both read and write API access. The MCP server currently only exposes read tools, so this is safe. When write tools are added, the same user will work without changes.

3. Create config file

mkdir -p ~/.mcp-opnsense
cp config.example.json ~/.mcp-opnsense/config.json
chmod 600 ~/.mcp-opnsense/config.json

Edit ~/.mcp-opnsense/config.json with your OPNsense connection details:

{
  "instances": [
    {
      "name": "home",
      "url": "https://192.168.1.1",
      "api_key": "your-key-here",
      "api_secret": "your-secret-here",
      "allow_insecure": true
    },
    {
      "name": "office",
      "url": "https://10.0.0.1",
      "api_key": "your-key-here",
      "api_secret": "your-secret-here",
      "allow_insecure": false
    }
  ],
  "default": "home"
}
  • name — short label for this instance
  • url — OPNsense base URL (HTTPS without trailing /api)
  • api_key / api_secret — from the downloaded key file in step 2c
  • allow_insecure — set true if using self-signed certificates (common on LAN)

Set OPNSENSE_CONFIG_PATH env var to override the config file location.

4. Configure Claude Code

Add to your Claude Code MCP config (usually ~/.claude/settings.json):

{
  "mcpServers": {
    "opnsense": {
      "command": "node",
      "args": ["/path/to/mcp-opnsense/dist/index.js"],
      "env": {}
    }
  }
}

Or use the dev mode (no build step):

{
  "mcpServers": {
    "opnsense": {
      "command": "npx",
      "args": ["tsx", "/path/to/mcp-opnsense/src/index.ts"],
      "env": {}
    }
  }
}

Available Tools

All tools accept an optional instance parameter to target a specific OPNsense instance (uses the configured default if omitted).

Tool Description
list-firewall-rules List firewall filter rules with optional search
get-firewall-rule Get a single rule by UUID
list-aliases List firewall aliases (host, network, port, URL types)
get-alias Get a single alias by UUID
get-interface-stats Get network interface statistics
get-gateway-status Live gateway monitoring (online/offline, latency, loss)

Note: The OPNsense API only manages rules created under Firewall → Automation → Filter. Legacy rules from Firewall → Rules are not accessible via API.

Development

# Run typecheck
npm run typecheck

# Run dev server (via tsx, no build step)
npm run dev

# Build to dist/
npm run build

# Run production
npm start

Multi-Instance

Define all your OPNsense endpoints in ~/.mcp-opnsense/config.json under the instances array. Use the instance parameter in any tool to target a specific instance:

"Check the gateway status for the office firewall"
→ get-gateway-status(instance: "office")

When no instance is specified, the default from config is used.

Known Limitations

  • Automation rules only — the API only exposes rules from Firewall → Automation. Classic Firewall → Rules entries are not reachable.
  • Self-signed certs — set allow_insecure: true for LAN OPNsense boxes with self-signed TLS.
  • API permissions — the OPNsense user must have the relevant permissions (Gateways, Firewall, Diagnostics) assigned.

Roadmap

  • [x] Read-only tools (firewall rules, aliases, diagnostics)
  • [ ] Write tools — add/update aliases (low risk)
  • [ ] Write tools — toggle firewall rules (with rollback)
  • [ ] Write tools — create/update/delete firewall rules
  • [ ] DHCP leases & static mappings
  • [ ] DNS overrides (Unbound/Dnsmasq)
  • [ ] VPN status (WireGuard, OpenVPN)
  • [ ] Service management (restart, status)
  • [ ] Config backup & restore via API

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured