The OPNSense MCP Server enables Infrastructure as Code (IaC) management of OPNsense firewalls through comprehensive API integration. With this server, you can:
- Configure OPNsense Connection: Set up host, API key, and secret for firewall communication
- Test Connectivity: Verify API connection and authentication
- Manage VLANs: List, create, update, delete, and retrieve VLAN details
- Control Firewall Rules: List, create, update, delete, enable/disable, and search rules; supports predefined rule presets
- Handle Backups: Create, list, and restore configuration backups
- Network Operations: Retrieve available network interfaces and configure isolated networks
- DNS Management: Manage DNS blocklists
- IaC Integration: Declaratively manage OPNsense infrastructure using JSON or JavaScript
Provides tools for managing OPNSense firewalls, including VLAN creation and management, firewall rule configuration, network interface queries, and DHCP lease management
Implements an audit database for tracking changes made through the OPNSense MCP server
Used as an optional cache layer for improved performance in Phase 3 of the OPNSense MCP server
OPNSense MCP Server
A Model Context Protocol (MCP) server for managing OPNsense firewalls through Claude Desktop or Claude Code.
What is this?
OPNSense MCP Server enables you to control your OPNsense firewall using conversational AI. Instead of navigating complex firewall interfaces, simply tell Claude what you want to do.
Example interactions:
- "Create a guest network on VLAN 50"
- "Block social media sites on the network"
- "Find all devices connected in the last hour"
- "Set up port forwarding for my Minecraft server"
✨ Key Features
- Network Management - VLANs, interfaces, firewall rules
- Device Discovery - ARP tables, DHCP leases, network scanning
- DNS Filtering - Block unwanted domains and categories
- HAProxy - Load balancing and reverse proxy configuration
- Infrastructure as Code - Declarative network deployments
- Backup & Restore - Configuration management
- Dual Transport - Works with Claude Desktop and as HTTP server
🚀 Quick Start
Prerequisites
- Node.js 18+
- OPNsense firewall with API access enabled
- Claude Desktop or Claude Code
Installation
Via npm (Recommended)
Via GitHub (Latest Development)
For Development
📋 Configuration
Claude Desktop
Add to your Claude Desktop configuration file:
- MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- Linux:
~/.config/claude/claude_desktop_config.json
Claude Code
Add to .claude/config.json
in your project root:
Option 1: Using NPX (Recommended)
Option 2: Local Installation
Using System Keychain (Recommended for Security)
Instead of hardcoding credentials:
Then store credentials in your system keychain:
- MacOS: Use Keychain Access app
- Windows: Use Credential Manager
- Linux: Use Secret Service (gnome-keyring or KWallet)
Environment Variables
Variable | Description | Required | Default |
---|---|---|---|
OPNSENSE_HOST | OPNsense URL (include https://) | Yes | - |
OPNSENSE_API_KEY | API key from OPNsense | Yes | - |
OPNSENSE_API_SECRET | API secret from OPNsense | Yes | - |
OPNSENSE_VERIFY_SSL | Verify SSL certificates | No | true |
LOG_LEVEL | Logging level | No | info |
CACHE_ENABLED | Enable response caching | No | true |
CACHE_TTL | Cache time-to-live in seconds | No | 300 |
🔑 OPNsense API Setup
- Enable API in OPNsense:
- Navigate to: System → Settings → Administration
- Check: "Enable API"
- Save
- Create API credentials:
- Navigate to: System → Access → Users
- Edit user or create new
- Under "API Keys", click "+" to generate key/secret
- Save credentials securely
- Required privileges:
- System: API access
- Firewall: Rules: Edit
- Interfaces: VLANs: Edit
- Services: All
Then restart Claude Desktop/Code and start chatting!
📚 Documentation
- Getting Started Guide - Installation and setup
- Feature Guides - Learn specific features
- IaC Documentation - Infrastructure as Code
- API Reference - Complete tool reference
- Troubleshooting - Common issues and solutions
💡 Example Use Cases
Create a Secure Guest Network
Find Devices
Block Unwanted Content
Set Up Services
More examples in the examples/ directory.
🛠️ Advanced Usage
Server Mode (for agents and automation)
Infrastructure as Code
Deploy entire network configurations declaratively. See IaC documentation.
Custom Patterns
Build reusable network templates. See pattern examples.
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
🔧 Troubleshooting
Claude Code/Desktop Not Connecting
If the MCP server fails to connect:
- Check the command path:
- For NPX: Use
["npx", "--yes", "opnsense-mcp-server@latest"]
to ensure latest version - For local: Ensure path is correct:
node_modules/opnsense-mcp-server/dist/index.js
- For NPX: Use
- Verify environment variables:
- Host must include protocol:
https://192.168.1.1
not just192.168.1.1
- API credentials must match exactly (no extra spaces)
- Host must include protocol:
- Test standalone first:
- Check Claude logs:
- MacOS:
~/Library/Logs/Claude/
- Windows:
%APPDATA%\Claude\logs\
- Linux:
~/.config/claude/logs/
- MacOS:
Common Issues
- "command not found": Install globally with
npm i -g opnsense-mcp-server
or use npx - "EACCES permission denied": The package may need executable permissions
- "Cannot connect to OPNsense": Check firewall rules and API settings
📄 License
MIT License - see LICENSE for details.
🔗 Links
Built with ❤️ for the MCP ecosystem
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
A server that enables managing OPNSense firewalls through natural language interactions with Claude Desktop, supporting VLAN management, firewall rules configuration, and network interface queries.
- What is this?
- ✨ Key Features
- 🚀 Quick Start
- 📋 Configuration
- 🔑 OPNsense API Setup
- 📚 Documentation
- 💡 Example Use Cases
- 🛠️ Advanced Usage
- 🤝 Contributing
- 🔧 Troubleshooting
- 📄 License
- 🔗 Links
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityLets you use Claude Desktop, or any MCP Client, to use natural language to accomplish things on your Cloudflare account.Last updated -21,4532,841TypeScriptApache 2.0
- AsecurityAlicenseAqualityEnables natural language interaction with Azure services through Claude Desktop, supporting resource management, subscription handling, and tenant selection with secure authentication.Last updated -93615TypeScriptMIT License
- -securityAlicense-qualityA production-grade server that enables natural language interaction with pfSense firewalls through Claude Desktop and other GenAI applications, supporting multiple access levels and functional categories.Last updated -13PythonMIT License
- -securityFlicense-qualityProvides system monitoring and management capabilities for Claude CLI, allowing users to view system information, track resource usage, and manage processes through natural language commands.Last updated -Python