
OPNSense
STDIOOPNsense防火墙管理与基础设施即代码服务器
OPNsense防火墙管理与基础设施即代码服务器
A Model Context Protocol (MCP) server for managing OPNsense firewalls with Infrastructure as Code (IaC) capabilities.
=======
# Clone the repository git clone https://github.com/vespo92/OPNSenseMCP cd opnsense-mcp # Install dependencies npm install # Build the project npm run build # Copy and configure environment cp .env.example .env # Edit .env with your OPNsense credentials
Create a .env
file with your OPNsense configuration:
# Required OPNSENSE_HOST=https://192.168.1.1 OPNSENSE_API_KEY=your_api_key OPNSENSE_API_SECRET=your_api_secret # Optional IAC_ENABLED=true ENABLE_CACHE=false REDIS_HOST=localhost POSTGRES_HOST=localhost
# Start the MCP server npm start # Or use with Claude Desktop # Add to claude_desktop_config.json: { "mcpServers": { "opnsense": { "command": "node", "args": ["dist/index.js"], "cwd": "/path/to/opnsense-mcp" } } }
Deploy network infrastructure declaratively:
{ "name": "home-network", "resources": [{ "type": "opnsense:network:vlan", "id": "guest-vlan", "name": "Guest Network", "properties": { "interface": "igc3", "tag": 10, "description": "Isolated guest network" } }] }
// Create a new VLAN for IoT devices const vlan = { type: "opnsense:network:vlan", properties: { interface: "igc3", tag: 20, description: "IoT Network - Isolated" } };
// Block all traffic from guest network to main LAN const rule = { type: "opnsense:firewall:rule", properties: { action: "block", interface: "guest_vlan", source: "guest_vlan_subnet", destination: "lan_subnet", description: "Block guest to LAN" } };
// Block social media sites const blocklist = { type: "opnsense:dns:blocklist", properties: { domains: ["facebook.com", "twitter.com", "tiktok.com"], description: "Social media block", enabled: true } };
// Deploy a complete guest network with isolation const guestNetwork = { name: "guest-network-setup", resources: [ { type: "opnsense:network:vlan", id: "guest-vlan", properties: { interface: "igc3", tag: 10, description: "Guest WiFi Network" } }, { type: "opnsense:firewall:rule", id: "guest-internet", properties: { action: "pass", interface: "guest_vlan", source: "guest_vlan_subnet", destination: "any", description: "Allow guest internet" } }, { type: "opnsense:firewall:rule", id: "block-guest-lan", properties: { action: "block", interface: "guest_vlan", source: "guest_vlan_subnet", destination: "lan_subnet", description: "Isolate guest from LAN" } } ] };
Once configured in Claude Desktop, you can ask Claude to:
Connection refused errors
Authentication failures
VLAN creation fails
Build errors
npm ci
for clean dependency installationFor more detailed troubleshooting, see our Troubleshooting Guide.
Contributions are welcome! Please read our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.