vespo92/OPNSenseMCP

šŸ”’ Security
0 Views
0 Installs

šŸ“‡ šŸ  - MCP Server for managing & interacting with Open Source NGFW OPNSense via Natural Language

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "vespo92-opnsensemcp": {
      "command": "npx",
      "args": [
        "-y",
        "vespo92-opnsensemcp"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

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

Related MCP Servers

13bm/GhidraMCP

šŸ ā˜• šŸ  - MCP server for integrating Ghidra with AI assistants. This plugin enables binary analysis, providing tools for function inspection, decompilation, memory exploration, and import/export analysis via the Model Context Protocol.

šŸ”’ Security1 views
123Ergo/unphurl-mcp

šŸ“‡ ā˜ļø - URL intelligence for AI agents. 13 tools for security signals and data quality: redirect behaviour, brand impersonation detection, domain age, SSL validation, parked detection, URL structural analysis, DNS enrichment.

šŸ”’ Security0 views
82ch/MCP-Dandan

šŸ šŸ“‡ šŸ  šŸŽ 🪟 🐧 - Real-time security framework for MCP servers that detects and blocks malicious AI agent behavior by analyzing tool call patterns and intent across multiple threat detection engines.

šŸ”’ Security0 views
9hannahnine-jpg/arc-gate-mcp

šŸ - Runtime governance for MCP tool calls. Blocks prompt injection and capability abuse before tool results reach your agent.

šŸ”’ Security0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

No check timestamp yet.

Unclaimed listing (imported or pending owner verification). Claim it →
ā˜… Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.