freshcrate
Skin:/
Home > MCP Servers > OPNSenseMCP

OPNSenseMCP

MCP Server for OPNSense to act as IaC proxy

Why this rank:Strong adoptionRelease freshnessHealthy release cadence

Description

MCP Server for OPNSense to act as IaC proxy

README

OPNsense MCP Server

npm version License: MIT

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.

Features

đŸ”Ĩ Firewall Management

  • Complete CRUD operations for firewall rules
  • Proper handling of API-created "automation rules"
  • Inter-VLAN routing configuration
  • Batch rule creation and management
  • Enhanced persistence with multiple fallback methods

🌐 NAT Configuration (SSH-based)

  • Outbound NAT rule management
  • NAT mode control (automatic/hybrid/manual/disabled)
  • No-NAT exception rules for inter-VLAN traffic
  • Automated DMZ NAT issue resolution
  • Direct XML configuration manipulation

🔍 Network Diagnostics

  • Comprehensive routing analysis
  • ARP table inspection with vendor identification
  • Interface configuration management
  • Network connectivity troubleshooting
  • Auto-fix capabilities for common issues

đŸ–Ĩī¸ SSH/CLI Execution

  • Direct command execution on OPNsense
  • Configuration file manipulation
  • System-level operations not available via API
  • Service management and restarts

📊 Additional Capabilities

  • VLAN management
  • DHCP lease viewing and management
  • DNS blocklist configuration
  • HAProxy load balancer support
  • Configuration backup and restore
  • Infrastructure as Code support

Installation

Prerequisites

  • Node.js 18+ or Bun 1.0+
  • OPNsense firewall (v24.7+ recommended)
  • API credentials for OPNsense
  • SSH access (optional, for advanced features)

Quick Start with npm

  1. Install the package:
npm install -g opnsense-mcp-server
  1. Create a .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
  1. Start the MCP server:
opnsense-mcp-server

Quick Start with Bun (Faster)

Bun provides significantly faster startup times and better performance.

  1. Install Bun (if not already installed):
curl -fsSL https://bun.sh/install | bash
  1. Clone and install:
git clone https://github.com/vespo92/OPNSenseMCP.git
cd OPNSenseMCP
bun install
  1. Create your .env file (same as npm version above)

  2. Run with Bun:

# Development with hot reload
bun run dev:bun

# Production
bun run start:bun

Using Bun with Claude Desktop

{
  "mcpServers": {
    "opnsense": {
      "command": "bun",
      "args": ["run", "/path/to/OPNSenseMCP/src/index.ts"],
      "env": {
        "OPNSENSE_HOST": "https://your-opnsense:port",
        "OPNSENSE_API_KEY": "your-key",
        "OPNSENSE_API_SECRET": "your-secret",
        "OPNSENSE_VERIFY_SSL": "false"
      }
    }
  }
}

Usage with Claude Desktop (npm)

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"
      }
    }
  }
}

Common Use Cases

Fix DMZ NAT Issues

// Automatically fix DMZ to LAN routing
await mcp.call('nat_fix_dmz', {
  dmzNetwork: '10.0.6.0/24',
  lanNetwork: '10.0.0.0/24'
});

Create Firewall Rules

// 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'
});

Diagnose Routing Issues

// Run comprehensive routing diagnostics
await mcp.call('routing_diagnostics', {
  sourceNetwork: '10.0.6.0/24',
  destNetwork: '10.0.0.0/24'
});

Execute CLI Commands

// Run any OPNsense CLI command
await mcp.call('system_execute_command', {
  command: 'pfctl -s state | grep 10.0.6'
});

MCP Tools Reference

The server provides 50+ MCP tools organized by category:

Firewall Tools

  • firewall_list_rules - List all firewall rules
  • firewall_create_rule - Create a new rule
  • firewall_update_rule - Update existing rule
  • firewall_delete_rule - Delete a rule
  • firewall_apply_changes - Apply pending changes

NAT Tools

  • nat_list_outbound - List outbound NAT rules
  • nat_set_mode - Set NAT mode
  • nat_create_outbound_rule - Create NAT rule
  • nat_fix_dmz - Fix DMZ NAT issues
  • nat_analyze_config - Analyze NAT configuration

Network Tools

  • arp_list - List ARP table entries
  • routing_diagnostics - Diagnose routing issues
  • routing_fix_all - Auto-fix routing problems
  • interface_list - List network interfaces
  • vlan_create - Create VLAN

System Tools

  • system_execute_command - Execute CLI command
  • backup_create - Create configuration backup
  • service_restart - Restart a service

For a complete list, see docs/api/mcp-tools.md.

Documentation

Testing

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

Development

Building from Source

git clone https://github.com/vespo92/OPNSenseMCP.git
cd OPNSenseMCP
npm install
npm run build

Project Structure

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

Troubleshooting

API Authentication Failed

  • Verify API key and secret are correct
  • Ensure API access is enabled in OPNsense
  • Check firewall rules allow API access

SSH Connection Failed

  • Verify SSH credentials in .env
  • Ensure SSH is enabled on OPNsense
  • Check user has appropriate privileges

NAT Features Not Working

  • NAT management requires SSH access
  • Add SSH credentials to environment variables
  • Test with: npx tsx scripts/test/test-nat-ssh.ts

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Acknowledgments


Version: 0.8.2 | Status: Production Ready | Last Updated: August 2025

Release History

VersionChangesUrgencyDate
v0.11.0## What's Changed * chore(deps): Bump @types/uuid from 10.0.0 to 11.0.0 by @dependabot[bot] in https://github.com/vespo92/OPNSenseMCP/pull/16 * chore(ci): Bump actions/cache from 4 to 5 by @dependabot[bot] in https://github.com/vespo92/OPNSenseMCP/pull/17 * chore(ci): Bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/vespo92/OPNSenseMCP/pull/18 * chore(deps): Bump the production-dependencies group with 2 updates by @dependabot[bot] in https://github.com/vespo92/OHigh4/8/2026
v0.9.2## What's New ### Dependency Upgrades - **zod**: 3.25.62 → 4.1.13 (major upgrade with performance improvements) - **drizzle-orm**: 0.29.5 → 0.45.0 - **drizzle-kit**: 0.31.4 → 0.31.8 ### Breaking Changes Addressed - Zod v4: `ZodError.errors` renamed to `ZodError.issues` ### Dependabot - Updated configuration to allow automatic updates for zod and drizzle-orm ### Installation ```bash npx opnsense-mcp-server@0.9.2 ``` Or with Bun: ```bash bun run /path/to/OPNSenseMCP/src/index.ts ```Low12/7/2025
v0.9.1## What's New ### Security Fixes - **CRITICAL**: Upgraded `@modelcontextprotocol/sdk` from 0.5.0 to 1.24.3 - Fixes DNS rebinding vulnerability (HIGH severity) - Fixed axios DoS vulnerability ### Bun Support 🚀 Now supports [Bun](https://bun.sh) for significantly faster startup times! **New scripts:** - `bun run start:bun` - Run with Bun - `bun run dev:bun` - Development mode with hot reload - `bun run build:bun` - Build with Bun **Claude Desktop with Bun:** ```json { "mcpServers": { Low12/7/2025
v0.9.0## What's New ### Features - **Modular Plugin Architecture**: Complete plugin system with SSE event streaming - **Dashboard**: Web-based monitoring interface - **Comprehensive Plugins**: Extended plugin ecosystem ### Security - **Credential Leak Fixed**: Removed `.mcp.json` from git tracking (contained API keys) - **Enhanced .gitignore**: Added patterns for credentials, secrets, SSH keys, and tokens ### Bug Fixes - Resolved all TypeScript build errors from merged PR - Fixed incorrect import nLow12/7/2025
v0.8.2## 🎉 Major Release: SSH-based NAT Management & Complete Repository Reorganization ### 🚀 Key Features #### NAT Management (NEW) - **Complete NAT control via SSH** - Since OPNsense doesn't expose NAT through REST API - **DMZ NAT fix** - Resolves inter-VLAN routing issues automatically - **NAT modes** - Support for automatic, hybrid, manual, and disabled modes - **No-NAT rules** - Create exception rules for internal traffic #### Firewall Improvements - **Fixed automation rules visibility** - ALow8/24/2025
v0.7.5## 🐛 Bug Fixes ### Critical: Fixed Firewall Rule Persistence Issue - **Problem**: Firewall rules were created successfully (returning UUIDs) but weren't persisting or showing up when listing rules - **Root Cause**: Incomplete configuration save - API was only calling `/firewall/filter/apply` without proper persistence ### Solution Implemented: 1. **Enhanced `applyChanges()` method**: - Now calls both `/firewall/filter/apply` and `/firewall/filter/reconfigure` - Implements proper save/reLow8/20/2025
v0.7.2**Full Changelog**: https://github.com/vespo92/OPNSenseMCP/compare/v0.7.1...v0.7.2Low8/7/2025
v0.7.1## What's Changed * add MCP server badge by @punkpeye in https://github.com/vespo92/OPNSenseMCP/pull/1 ## New Contributors * @punkpeye made their first contribution in https://github.com/vespo92/OPNSenseMCP/pull/1 **Full Changelog**: https://github.com/vespo92/OPNSenseMCP/commits/v0.7.1Low8/7/2025
v0.7.3## 🐛 Bug Fixes - Fixed ESM import paths missing .js extensions - Updated npx command to use --yes flag for better compatibility - Added @latest to ensure newest version is fetched ## 📚 Documentation - Updated all configuration examples with working syntax - Added troubleshooting section for connection issues - Improved Claude Code/Desktop setup instructions ## 🔧 Configuration Working Claude Code configuration: ```json { "mcpServers": { "opnsense": { "command": "npx", "arLow8/7/2025

Dependencies & License Audit

Loading dependencies...

Similar Packages

Perplexity-Comet-MCPNo descriptionmain@2026-06-07
google-workspace-mcp-with-scriptNo descriptionmain@2026-06-07
scagent🔍 Discover security flaws and improve code quality with ShenCha, an AI-powered autonomous code audit agent designed for developers.main@2026-06-07
claude-blockerđŸ›Ąī¸ Block distracting websites when Claude Code is in use, ensuring focused work sessions and minimizing interruptions.main@2026-06-07
any-api🚀 Seamlessly route requests between multiple LLM APIs using a unified gateway on Cloudflare Workers for efficient development and integration.main@2026-06-07

More in MCP Servers

PlanExeCreate a plan from a description in minutes
agentroveYour own Claude Code UI, sandbox, in-browser VS Code, terminal, multi-provider support (Anthropic, OpenAI, GitHub Copilot, OpenRouter), custom skills, and MCP servers.
ProxmoxMCP-PlusEnhanced Proxmox MCP server with advanced virtualization management and full OpenAPI integration.
node9-proxyThe Execution Security Layer for the Agentic Era. Providing deterministic "Sudo" governance and audit logs for autonomous AI agents.