by vespo92
Manage OPNsense firewalls through conversational AI, providing network configuration, device discovery, DNS filtering, HAProxy setup, and backup/restore via simple commands.
Enables control of OPNsense firewalls using natural‑language instructions. The server translates Claude Desktop or Claude Code queries into OPNsense API calls, handling VLANs, rules, device lookup, DNS filtering, HAProxy, and IaC deployments.
npx opnsense-mcp-server
or install globally with npm i -g opnsense-mcp-server.claude_desktop_config.json (macOS, Windows, Linux) or .claude/config.json for Claude Code. Use the NPX command and provide the required environment variables (OPNSENSE_HOST, OPNSENSE_API_KEY, OPNSENSE_API_SECRET, optional OPNSENSE_VERIFY_SSL).Q: Do I need to install anything on the OPNsense appliance? A: Only enable the built‑in API (System → Settings → Administration → Enable API) and create an API user with appropriate privileges.
Q: Can I store API credentials securely?
A: Yes. Use the system keychain syntax {{keychain:opnsense-api-key}} in the MCP configuration to pull secrets from macOS Keychain, Windows Credential Manager, or Linux Secret Service.
Q: What Node.js version is required? A: Node 18 or newer.
Q: How do I run the server in HTTP mode for automation?
A: Execute npm run start:sse (default port 3000) and point your automation tools to http://localhost:3000.
Q: What if Claude cannot connect to the server?
A: Verify the NPX command path, ensure all environment variables are set correctly (host must include https://), and test the server manually via npx opnsense-mcp-server.
A Model Context Protocol (MCP) server for comprehensive OPNsense firewall management. This server enables AI assistants like Claude to directly manage firewall configurations, diagnose network issues, and automate complex networking tasks.
npm install -g opnsense-mcp-server
.env file with your credentials:# Required
OPNSENSE_HOST=https://your-opnsense-host:port
OPNSENSE_API_KEY=your-api-key
OPNSENSE_API_SECRET=your-api-secret
OPNSENSE_VERIFY_SSL=false
# Optional - for SSH features
OPNSENSE_SSH_HOST=your-opnsense-host
OPNSENSE_SSH_USERNAME=root
OPNSENSE_SSH_PASSWORD=your-password
# Or use SSH key
# OPNSENSE_SSH_KEY_PATH=~/.ssh/id_rsa
opnsense-mcp-server
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"opnsense": {
"command": "npx",
"args": ["opnsense-mcp-server"],
"env": {
"OPNSENSE_HOST": "https://your-opnsense:port",
"OPNSENSE_API_KEY": "your-key",
"OPNSENSE_API_SECRET": "your-secret",
"OPNSENSE_VERIFY_SSL": "false"
}
}
}
}
// Automatically fix DMZ to LAN routing
await mcp.call('nat_fix_dmz', {
dmzNetwork: '10.0.6.0/24',
lanNetwork: '10.0.0.0/24'
});
// Allow NFS from DMZ to NAS
await mcp.call('firewall_create_rule', {
action: 'pass',
interface: 'opt8',
source: '10.0.6.0/24',
destination: '10.0.0.14/32',
protocol: 'tcp',
destination_port: '2049',
description: 'Allow NFS from DMZ'
});
// Run comprehensive routing diagnostics
await mcp.call('routing_diagnostics', {
sourceNetwork: '10.0.6.0/24',
destNetwork: '10.0.0.0/24'
});
// Run any OPNsense CLI command
await mcp.call('system_execute_command', {
command: 'pfctl -s state | grep 10.0.6'
});
The server provides 50+ MCP tools organized by category:
firewall_list_rules - List all firewall rulesfirewall_create_rule - Create a new rulefirewall_update_rule - Update existing rulefirewall_delete_rule - Delete a rulefirewall_apply_changes - Apply pending changesnat_list_outbound - List outbound NAT rulesnat_set_mode - Set NAT modenat_create_outbound_rule - Create NAT rulenat_fix_dmz - Fix DMZ NAT issuesnat_analyze_config - Analyze NAT configurationarp_list - List ARP table entriesrouting_diagnostics - Diagnose routing issuesrouting_fix_all - Auto-fix routing problemsinterface_list - List network interfacesvlan_create - Create VLANsystem_execute_command - Execute CLI commandbackup_create - Create configuration backupservice_restart - Restart a serviceFor a complete list, see docs/api/mcp-tools.md.
The repository includes comprehensive testing utilities:
# Test NAT functionality
npx tsx scripts/test/test-nat-ssh.ts
# Test firewall rules
npx tsx scripts/test/test-rules.ts
# Test routing diagnostics
npx tsx scripts/test/test-routing.ts
# Run all tests
npm test
git clone https://github.com/vespo92/OPNSenseMCP.git
cd OPNSenseMCP
npm install
npm run build
OPNSenseMCP/
├── src/ # Source code
│ ├── api/ # API client
│ ├── resources/ # Resource implementations
│ └── index.ts # MCP server entry
├── docs/ # Documentation
├── scripts/ # Utility scripts
│ ├── test/ # Test scripts
│ ├── debug/ # Debug utilities
│ └── fixes/ # Fix scripts
└── dist/ # Build output
.envnpx tsx scripts/test/test-nat-ssh.tsContributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
Version: 0.8.2 | Status: Production Ready | Last Updated: August 2025
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by chaitin
A self‑hosted web application firewall and reverse proxy that protects web applications from attacks and exploits by filtering, monitoring, and blocking malicious HTTP/S traffic.
by safedep
Provides enterprise‑grade open source software supply chain security by scanning source code, dependencies, containers and SBOMs, detecting vulnerabilities and malicious packages, and enforcing policy as code.
by semgrep
Offers an MCP server that lets LLMs, agents, and IDEs run Semgrep scans to detect security vulnerabilities in source code.
by PortSwigger
Enables Burp Suite to communicate with AI clients via the Model Context Protocol, providing an MCP server and bundled stdio proxy.
by cycodehq
Boost security in the development lifecycle via SAST, SCA, secrets, and IaC scanning.
by mobb-dev
Provides automatic security vulnerability remediation for code via a command‑line interface and an MCP server, leveraging findings from popular SAST tools such as Checkmarx, CodeQL, Fortify, and Snyk.
by ChristophEnglisch
Provides AI‑powered administration of Keycloak users and realms through the Model Context Protocol, enabling automated creation, deletion, and listing of users and realms from MCP clients such as Claude Desktop.
by Spathodea-Network
Provides a Model Context Protocol server that enables querying and retrieving threat intelligence data from OpenCTI through a standardized interface.
by firstorderai
Provides seamless access to two‑factor authentication codes and passwords for AI agents, enabling automated login while maintaining security.
{
"mcpServers": {
"opnsense": {
"command": "npx",
"args": [
"-y",
"opnsense-mcp-server@latest"
],
"env": {
"OPNSENSE_HOST": "https://<YOUR_OPNSENSE_IP_OR_HOST>",
"OPNSENSE_API_KEY": "<YOUR_API_KEY>",
"OPNSENSE_API_SECRET": "<YOUR_API_SECRET>",
"OPNSENSE_VERIFY_SSL": "true"
}
}
}
}claude mcp add opnsense npx -y opnsense-mcp-server@latest