opnsense-mcp-server

floriangrousset/opnsense-mcp-server

3.4

If you are the rightful owner of opnsense-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The OPNsense MCP Server allows AI models to manage OPNsense firewalls using natural language, leveraging the Model Context Protocol for secure interactions.

๐Ÿ”ฅ OPNsense MCP Server

๐Ÿš€ Transform your OPNsense firewall management with AI-powered natural language commands!

MseeP.ai Security Assessment Badge

Verified on MseeP Python 3.10+ MCP Compatible OPNsense


โš ๏ธ CRITICAL: Security & Usage Disclaimer

๐Ÿšจ THIS TOOL SHOULD NEVER BE USED IN PRODUCTION ENVIRONMENTS ๐Ÿšจ

โ›” Production Use: STRICTLY PROHIBITED

This project is ONLY for:

  • ๐Ÿงช Laboratory environments - Isolated test networks
  • ๐Ÿ“š Educational purposes - Learning about AI and network automation
  • ๐Ÿ”ฌ Experimentation - Exploring agentic AI capabilities
  • ๐ŸŽฏ Research - Understanding AI-controlled infrastructure

This project is NOT for:

  • โŒ Production firewalls (business or personal)
  • โŒ Any environment where downtime matters
  • โŒ Networks protecting real assets or data
  • โŒ Internet-facing or critical infrastructure

๐Ÿค– Why This Restriction?

Large Language Models (LLMs) are fundamentally unpredictable:

  1. Non-Deterministic Behavior

    • Same prompt can produce different results
    • No guarantees on output correctness
    • Can hallucinate configurations that seem correct but aren't
  2. Firewall Management is Critical

    • Mistakes expose your network to attacks
    • Misconfigurations can block all traffic
    • Recovery may require physical console access
    • Security implications are severe
  3. AI Technology Maturity

    • Current state (2025): Powerful but unreliable for critical systems
    • LLMs can confidently give wrong answers
    • Intent interpretation is imperfect
    • No formal verification of outputs

Example risks:

  • "Block suspicious traffic" โ†’ Blocks everything
  • "Open port for SSH" โ†’ Exposes unintended services
  • "Configure VPN" โ†’ Creates insecure tunnel
  • AI hallucinates non-existent APIs or parameters

๐ŸŽ“ Intended Audience

This project is for curious professionals and enthusiasts who want to explore:

  • How AI agents interact with network equipment
  • Capabilities and limitations of LLM-driven automation
  • Future possibilities of AI in infrastructure management
  • Natural language interfaces for complex systems

You should:

  • Have networking knowledge to recognize bad configurations
  • Use completely isolated lab environments
  • Understand you're experimenting with emerging technology
  • Be prepared for unexpected behaviors and errors

๐Ÿ  Recommended: Self-Hosted LLMs

For maximum safety and privacy, use local LLMs like Ollama:

Why local models:

  • ๐Ÿ”’ Privacy: Network configurations never leave your lab
  • ๐ŸŽ›๏ธ Control: Specific model versions, reproducible behavior
  • ๐Ÿ’ฐ Cost: No API fees
  • ๐Ÿ“ก Offline: No internet dependency
  • ๐Ÿ” Transparency: Inspect and modify model behavior

Setup with Ollama:

# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh

# Pull a model (e.g., llama3.2)
ollama pull llama3.2

# Use with MCP (configure in Claude Desktop or equivalent)

Note: Even with local models, use ONLY in lab environments. The unpredictability comes from the AI technology itself, not the hosting method.

๐Ÿค– AI-Generated Code Transparency

This codebase was created with AI assistance:

  • ๐Ÿ”ง ~90% generated using Claude Code
  • ๐Ÿ‘๏ธ Reviewed by both AI agents and humans
  • โœ… Tested with 296+ automated tests (100% pass rate)
  • ๐Ÿ“‹ Security audited for credential handling

What this means:

  • โœ… Rapid development of complex functionality
  • โš ๏ธ Possible bugs despite thorough review
  • ๐Ÿ” Complete transparency about code origin
  • ๐Ÿงช Your responsibility to test before trusting

Both AI reviewers and humans can miss issues. Treat this code as you would any open-source project: inspect it, test it thoroughly in safe environments, and report issues.

๐Ÿ›ก๏ธ Safety Guidelines for Lab Use

If using in your lab environment:

  1. Isolation is Critical

    • Use completely separate networks
    • No connection to production systems
    • Preferably virtual environments (VMs, containers)
    • Air-gapped from sensitive data
  2. Backup Before Every Change

    • Export OPNsense configuration before experiments
    • Test backup restoration procedures
    • Keep multiple backup generations
  3. Monitor Everything

    • Watch firewall logs in real-time
    • Set up alerts for unexpected changes
    • Have console access ready for recovery
  4. Start with Read-Only

    • Begin with status queries and information gathering
    • Review code for write operations before enabling
    • Gradually increase complexity as you understand behavior
  5. Expect Failures

    • AI will make mistakes - plan for it
    • Have rollback procedures documented
    • Know how to recover from console if locked out
    • Consider it a learning experience, not a reliable tool
  6. Never Trust, Always Verify

    • Review every AI suggestion before applying
    • Understand what changes will do
    • Check for unintended side effects
    • Use dry-run modes when available

๐Ÿ”ฎ Future of AI Infrastructure Management

This project explores the future, not the present:

We're in the early experimental phase of AI-controlled infrastructure. This technology will mature, but today:

  • โŒ Not reliable enough for production
  • โœ… Excellent for research and learning
  • ๐Ÿ”ฌ Helps identify what's needed for production-readiness

Future developments needed:

  • Formal verification of AI outputs
  • Deterministic reasoning for critical operations
  • Sandbox/simulation modes
  • Safety guardrails and constraints
  • Specialized models trained on network operations

By experimenting responsibly in labs, you contribute to understanding how this technology should evolve.

โš–๏ธ Legal Disclaimer

BY USING THIS SOFTWARE YOU ACKNOWLEDGE:

  • This is experimental software for laboratory use only
  • Authors assume NO responsibility for damages, outages, or security breaches
  • You accept ALL risk when running this on any firewall
  • Production use violates the intended purpose of this project
  • You will not hold authors liable for any consequences

Use at your own risk. You have been warned.


๐Ÿ“ž Questions or Report Issues?

Remember: This is a research project for curious professionals exploring AI capabilities in network automation. Keep it in the lab.


๐ŸŽฏ Quick Example: "Block all traffic from Russia and add those IPs to my threat list" โ†’ Done! โœ…

OPNsenseยฎ is a powerful open-source firewall and routing platform built on FreeBSD. This project transforms traditional firewall management by enabling natural language control through AI clients like Claude Desktop. Simply speak to your firewall as you would to a network engineer, and watch complex configurations happen automatically!

๐ŸŽ‰ What makes this special? Instead of clicking through web interfaces or memorizing API commands, just say:

  • "Show me what's using the most bandwidth" ๐Ÿ“Š
  • "Create a VPN user for my remote developer" ๐Ÿ‘ฅ
  • "Block suspicious traffic and generate a security report" ๐Ÿ›ก๏ธ

โšก Quick Start (5 minutes)

# 1. ๐Ÿ“ฅ Clone & Enter
git clone https://github.com/floriangrousset/opnsense-mcp-server && cd opnsense-mcp-server

# 2. ๐Ÿ› ๏ธ Setup Environment
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv && source .venv/bin/activate
uv pip install -r requirements.txt

# 3. ๐Ÿ” Configure Your OPNsense Credentials (Secure - Local Only!)
opnsense-mcp setup
# Enter your OPNsense URL, API key, and secret interactively
# ๐Ÿ”’ Credentials stored locally ONLY - never sent to AI models!

# 4. โš™๏ธ Configure Claude Desktop (Automatic!)
./setup-claude.sh  # ๐ŸŽ‰ Magic happens here!

# 5. ๐Ÿš€ Start Managing!
# Open Claude Desktop and say: "Configure OPNsense connection"

๐ŸŽŠ That's it! You're now managing your firewall with natural language!

๐Ÿ”’ Security Note: Your credentials are stored locally in ~/.opnsense-mcp/config.json with secure permissions (0600). They are never sent to Claude or any AI model. See for details.


OPNsense MCP Server Logo

๐Ÿง  What is an MCP Server? Why Is It a Game Changer for AI?

The Model Context Protocol (MCP) is a new standard that lets AI models (like Claude, ChatGPT, and others) securely interact with real-world tools, data, and systemsโ€”not just answer questions, but actually take action. You can think of it as "giving hands to the brain": the AI is the brain, and the MCP server is the set of hands that can reach out and do things in the real world. For more technical details, refer to the official MCP specification.

๐ŸŒŸ Why is this revolutionary?

  • ๐ŸŽฏ From Answers to Actions: Traditional AI models only provide information. With MCP, they actually perform tasksโ€”like managing your firewall, configuring VPNs, or analyzing security logsโ€”by calling tools exposed by an MCP server.
  • ๐Ÿ”’ Security and Trust: MCP is designed to be secure and auditable. You control exactly what the AI can access, and you can see every action it takes.
  • ๐Ÿ”Œ Plug-and-Play for AI Clients: Tools like Claude Desktop make it easy to connect to MCP servers. Just add the server in settings, and suddenly your AI can manage your OPNsense firewall!
  • ๐ŸŽญ Separation of Concerns: The AI doesn't need to know OPNsense APIs. The MCP server handles all the technical details, so you get automation power without security risks.

๐Ÿš€ How does it work in practice?

  1. ๐Ÿ  You run an MCP server (like this OPNsense MCP Server) on your machine or network
  2. ๐Ÿ”— You connect your AI client (like Claude Desktop) to the MCP server in settings
  3. โšก The AI can now use the tools exposed by the serverโ€”securely, with your oversight

๐Ÿ’ก The game changer: MCP servers let you safely delegate real-world network management tasks to AI, making your AI not just smart, but truly useful for infrastructure management!


๐Ÿ› ๏ธ Complete Feature Set (166 Tools!)

๐ŸŽฏ Click to expand the FULL toolkit - We've got everything you need!

๐Ÿ”Œ Connection & Configuration

ToolDescriptionExample Command
configure_opnsense_connectionSetup API connection"Connect to my OPNsense at 192.168.1.1"
get_api_endpointsList available endpoints"Show me all available API endpoints"

๐Ÿ–ฅ๏ธ System Management

ToolDescriptionExample Command
get_system_statusSystem overview & health"What's my firewall status?"
get_system_healthCPU, memory, disk metrics"Show system resource usage"
get_system_routesView routing table"Display the routing table"
restart_serviceControl system services"Restart the DHCP service"
backup_configExport configuration"Backup my firewall config"

๐Ÿ”ฅ Firewall Management

ToolDescriptionExample Command
firewall_get_rulesList all firewall rules"Show all firewall rules"
firewall_add_ruleCreate new firewall rule"Block port 445 from WAN"
firewall_delete_ruleRemove firewall rule"Delete rule abc123"
firewall_toggle_ruleEnable/disable rule"Disable the SSH access rule"
perform_firewall_auditComprehensive security audit"Audit my firewall security"

๐Ÿ“ Alias Management

ToolDescriptionExample Command
get_firewall_aliasesList all aliases"Show all firewall aliases"
add_to_aliasAdd IP/network to alias"Add 10.0.0.5 to BlockedIPs alias"
delete_from_aliasRemove from alias"Remove 10.0.0.5 from AllowedIPs"

๐Ÿ”„ NAT Management

ToolDescriptionExample Command
nat_list_outbound_rulesList outbound NAT rules"Show outbound NAT configuration"
nat_add_outbound_ruleCreate outbound NAT"Add outbound NAT for 10.0.0.0/24"
nat_delete_outbound_ruleRemove outbound NAT"Delete outbound NAT rule xyz"
nat_toggle_outbound_ruleEnable/disable NAT rule"Disable outbound NAT rule abc"
nat_list_one_to_one_rulesList 1:1 NAT mappings"Show one-to-one NAT rules"
nat_add_one_to_one_ruleCreate 1:1 NAT mapping"Map public IP to internal server"
nat_delete_one_to_one_ruleRemove 1:1 NAT"Delete 1:1 NAT mapping"
nat_get_port_forward_infoPort forwarding guidance"How do I setup port forwarding?"

๐ŸŒ Network Interface Management

ToolDescriptionExample Command
get_interfacesList all network interfaces"Show network interface status"
get_interface_detailsDetailed interface info"Get details for WAN interface"
reload_interfaceRestart network interface"Reload the LAN interface"
export_interface_configExport interface config"Export network configuration"

๐Ÿ”— VLAN Management

ToolDescriptionExample Command
list_vlansList all VLANs"Show all VLAN interfaces"
get_vlanGet VLAN configuration"Get VLAN 100 settings"
create_vlan_interfaceCreate new VLAN"Create VLAN 200 on em0 interface"
update_vlanModify VLAN settings"Change VLAN 100 description"
delete_vlanRemove VLAN interface"Delete VLAN 200"
reconfigure_vlansApply VLAN changes"Apply all VLAN configuration changes"

๐ŸŒ‰ Bridge Management

ToolDescriptionExample Command
list_bridgesList bridge interfaces"Show all network bridges"
get_bridgeBridge configuration details"Get bridge0 configuration"
create_bridgeCreate bridge interface"Create bridge between LAN1 and LAN2"
update_bridgeModify bridge settings"Update bridge spanning tree settings"
delete_bridgeRemove bridge interface"Delete bridge0 interface"

โšก Link Aggregation (LAGG)

ToolDescriptionExample Command
list_lagg_interfacesList LAGG interfaces"Show link aggregation groups"
get_laggLAGG configuration details"Get lagg0 configuration"
create_laggCreate LAGG interface"Create LACP bond with em0 and em1"
update_laggModify LAGG settings"Change LAGG protocol to failover"
delete_laggRemove LAGG interface"Delete lagg0 interface"
reconfigure_laggApply LAGG changes"Apply LAGG configuration changes"

๐Ÿท๏ธ Virtual IP Management

ToolDescriptionExample Command
list_virtual_ipsList virtual IP addresses"Show all virtual IPs"
get_virtual_ipVIP configuration details"Get virtual IP configuration"
create_virtual_ipCreate virtual IP"Add CARP VIP 10.0.0.100 on LAN"
update_virtual_ipModify VIP settings"Change virtual IP settings"
delete_virtual_ipRemove virtual IP"Delete virtual IP address"
get_next_carp_vhidGet available CARP ID"Find unused VHID for CARP setup"
reconfigure_virtual_ipsApply VIP changes"Apply virtual IP changes"

๐Ÿ“ก DHCP Server Management

ToolDescriptionExample Command
dhcp_list_serversList DHCP server configs"Show DHCP server configurations"
dhcp_get_serverDHCP server details"Get LAN DHCP server settings"
dhcp_set_serverConfigure DHCP server"Setup DHCP for VLAN100 network"
dhcp_restart_serviceRestart DHCP service"Restart the DHCP service"
dhcp_get_leasesCurrent DHCP leases"Show active DHCP leases"
dhcp_search_leasesSearch for specific leases"Find lease for MAC aa:bb:cc:dd:ee:ff"
dhcp_get_lease_statisticsDHCP usage statistics"Show DHCP usage statistics"

๐Ÿ“ DHCP Static Mappings

ToolDescriptionExample Command
dhcp_list_static_mappingsList DHCP reservations"Show DHCP static reservations"
dhcp_get_static_mappingGet reservation details"Get server DHCP reservation"
dhcp_add_static_mappingAdd DHCP reservation"Reserve 192.168.1.50 for printer"
dhcp_update_static_mappingUpdate reservation"Change printer IP reservation"
dhcp_delete_static_mappingDelete reservation"Remove printer DHCP reservation"

๐Ÿ” DNS Resolver (Unbound)

ToolDescriptionExample Command
dns_resolver_get_settingsDNS resolver configuration"Show DNS resolver settings"
dns_resolver_set_settingsConfigure DNS resolver"Enable DNSSEC validation"
dns_resolver_list_host_overridesList DNS host overrides"Show DNS host overrides"
dns_resolver_get_host_overrideGet host override details"Get override for server.local"
dns_resolver_add_host_overrideAdd DNS host override"Map server.local to 10.0.0.10"
dns_resolver_update_host_overrideUpdate host override"Change server.local IP address"
dns_resolver_delete_host_overrideDelete host override"Remove server.local override"
dns_resolver_list_domain_overridesList domain overrides"Show DNS domain forwarding"
dns_resolver_add_domain_overrideAdd domain override"Forward corp.com to 10.0.0.53"
dns_resolver_restart_serviceRestart DNS resolver"Restart DNS resolver service"

โฉ DNS Forwarder (dnsmasq)

ToolDescriptionExample Command
dns_forwarder_get_settingsDNS forwarder settings"Show DNS forwarder configuration"
dns_forwarder_set_settingsConfigure DNS forwarder"Enable DNS forwarder service"
dns_forwarder_list_hostsList forwarder hosts"Show DNS forwarder host entries"
dns_forwarder_add_hostAdd forwarder host entry"Add local.domain DNS entry"
dns_forwarder_restart_serviceRestart DNS forwarder"Restart DNS forwarder service"

๐Ÿ” Certificate Authority Management

ToolDescriptionExample Command
list_certificate_authoritiesList all CAs"Show Certificate Authorities"
get_certificate_authorityCA details"Get root CA information"
create_certificate_authorityCreate new CA"Create internal Certificate Authority"
delete_certificate_authorityRemove CA"Delete old Certificate Authority"
export_certificate_authorityExport CA certificate"Export CA certificate in PEM format"

๐Ÿ“œ Certificate Management

ToolDescriptionExample Command
list_certificatesList all certificates"Show all SSL certificates"
get_certificateCertificate details"Get web server certificate details"
import_certificateImport certificate"Import SSL certificate and private key"
delete_certificateRemove certificate"Delete expired certificate"
export_certificateExport certificate"Export VPN certificate"

๐Ÿ“‹ Certificate Signing Requests

ToolDescriptionExample Command
list_certificate_signing_requestsList CSRs"Show pending certificate requests"
get_certificate_signing_requestCSR details"Get CSR information"
create_certificate_signing_requestGenerate CSR"Create CSR for domain.com"
delete_certificate_signing_requestRemove CSR"Delete certificate request"

๐Ÿ”„ ACME (Let's Encrypt) Management

ToolDescriptionExample Command
list_acme_accountsList ACME accounts"Show Let's Encrypt accounts"
get_acme_accountACME account details"Get ACME account information"
create_acme_accountCreate ACME account"Setup Let's Encrypt account"
delete_acme_accountRemove ACME account"Delete Let's Encrypt account"
list_acme_certificatesList ACME certificates"Show Let's Encrypt certificates"
get_acme_certificateACME certificate details"Get LE certificate details"
create_acme_certificateRequest ACME certificate"Get Let's Encrypt cert for domain.com"
sign_acme_certificateIssue certificate"Issue ACME certificate"
revoke_acme_certificateRevoke certificate"Revoke compromised certificate"
delete_acme_certificateRemove ACME certificate"Delete ACME certificate"

๐Ÿ” Certificate Analysis & Monitoring

ToolDescriptionExample Command
analyze_certificate_expirationCheck certificate expiry"Check certificate expiration status"
validate_certificate_chainValidate trust chain"Validate certificate trust chain"
get_certificate_usageCertificate usage info"Where is this certificate used?"

๐Ÿ‘ฅ User Management

ToolDescriptionExample Command
list_usersList all users"Show all system users"
get_userUser account details"Get admin user information"
create_userCreate new user"Add new administrator user"
update_userModify user settings"Update user permissions"
delete_userRemove user account"Delete inactive user account"
toggle_userEnable/disable user"Disable user account temporarily"
create_admin_userQuick admin creation"Create admin user quickly"
create_readonly_userCreate read-only user"Add monitoring-only user"
reset_user_passwordReset user password"Reset user password securely"
bulk_user_creationMass user creation"Import users from template"

๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Group Management

ToolDescriptionExample Command
list_groupsList all groups"Show all user groups"
get_groupGroup details"Get administrators group info"
create_groupCreate user group"Create network operators group"
update_groupModify group settings"Update group description"
delete_groupRemove group"Delete empty user group"
add_user_to_groupAdd group member"Add user to administrators group"
remove_user_from_groupRemove group member"Remove user from operators group"
setup_user_group_templateCreate group template"Setup role-based group template"

๐Ÿ›ก๏ธ Privilege Management

ToolDescriptionExample Command
list_privilegesList available privileges"Show all available permissions"
get_user_effective_privilegesUser's actual privileges"What permissions does user have?"
assign_privilege_to_userGrant user privilege"Give user firewall management access"
revoke_privilege_from_userRemove user privilege"Remove admin rights from user"

๐Ÿ”‘ Authentication Systems

ToolDescriptionExample Command
list_auth_serversList auth servers"Show LDAP/RADIUS servers"
test_user_authenticationTest user login"Test user authentication"

๐Ÿ“Š Comprehensive Logging & Monitoring

ToolDescriptionExample Command
get_firewall_logsFirewall activity logs"Show last 100 blocked connections"
get_system_logsSystem event logs"Display system events from today"
get_service_logsService-specific logs"Show DHCP service logs"
search_logsSearch across all logs"Find failed login attempts"
export_logsExport logs to file"Export today's logs to JSON"
get_log_statisticsLog analysis & stats"Show 24-hour log analysis"
clear_logsClear old log files"Clear logs older than 30 days"
configure_loggingAdjust log settings"Set firewall logging to debug level"
analyze_security_eventsSecurity threat analysis"Analyze security events and threats"
generate_log_reportGenerate log reports"Create daily security report"

๐Ÿ”Œ Plugin & Service Management

ToolDescriptionExample Command
list_pluginsList installed plugins"Show all installed plugins"
install_pluginInstall new plugin"Install WireGuard VPN plugin"

๐ŸŒ VPN Connection Monitoring

ToolDescriptionExample Command
get_vpn_connectionsVPN connection status"Show active VPN connections"

๐Ÿšฆ Traffic Shaping & QoS Management

ToolDescriptionExample Command
traffic_shaper_get_statusService status and statistics"Show traffic shaper status"
traffic_shaper_reconfigureApply QoS configuration changes"Apply traffic shaping changes"
traffic_shaper_get_settingsGeneral QoS configuration"Show traffic shaper settings"

๐Ÿ”ง Pipe Management (Bandwidth Limits)

ToolDescriptionExample Command
traffic_shaper_list_pipesList all bandwidth pipes"Show all traffic shaper pipes"
traffic_shaper_get_pipeGet pipe details"Get details for pipe abc123"
traffic_shaper_create_pipeCreate bandwidth limiting pipe"Create 100 Mbps pipe for guest network"
traffic_shaper_update_pipeModify pipe settings"Update pipe bandwidth to 50 Mbps"
traffic_shaper_delete_pipeRemove bandwidth pipe"Delete unused traffic pipe"
traffic_shaper_toggle_pipeEnable/disable pipe"Disable guest network pipe"

โš–๏ธ Queue Management (Weighted Sharing)

ToolDescriptionExample Command
traffic_shaper_list_queuesList all traffic queues"Show all traffic shaper queues"
traffic_shaper_get_queueGet queue details"Get queue configuration for VoIP"
traffic_shaper_create_queueCreate weighted sharing queue"Create high-priority VoIP queue"
traffic_shaper_update_queueModify queue settings"Change queue weight to 80"
traffic_shaper_delete_queueRemove traffic queue"Delete old queue configuration"
traffic_shaper_toggle_queueEnable/disable queue"Enable gaming priority queue"

๐Ÿ“‹ Rule Management (Traffic Classification)

ToolDescriptionExample Command
traffic_shaper_list_rulesList all QoS rules"Show all traffic shaping rules"
traffic_shaper_get_ruleGet rule details"Get rule configuration"
traffic_shaper_create_ruleCreate traffic classification rule"Route gaming traffic to high-priority queue"
traffic_shaper_update_ruleModify rule settings"Update rule to target new queue"
traffic_shaper_delete_ruleRemove QoS rule"Delete obsolete traffic rule"
traffic_shaper_toggle_ruleEnable/disable rule"Enable VoIP priority rule"

๐ŸŽฏ Common QoS Use Cases (Helpers)

ToolDescriptionExample Command
traffic_shaper_limit_user_bandwidthPer-user bandwidth limiting"Limit user 192.168.1.50 to 10 Mbps"
traffic_shaper_prioritize_voipVoIP traffic prioritization"Setup VoIP priority with 5 Mbps guaranteed"
traffic_shaper_setup_gaming_priorityGaming traffic optimization"Optimize 100 Mbps connection for gaming"
traffic_shaper_create_guest_limitsGuest network bandwidth limits"Limit guest network to 20 Mbps total"

๐Ÿ”ง Advanced & Custom Tools

ToolDescriptionExample Command
exec_api_callExecute custom API calls"Execute GET on /api/custom/endpoint"

๐ŸŽฏ Total: 166 powerful tools for complete OPNsense management through natural language!


๐ŸŒŸ Real-World Success Stories

๐Ÿข Enterprise Network Management

"We manage 50+ OPNsense firewalls across multiple sites. This MCP server lets our junior admins safely make changes using natural language, reducing configuration errors by 80% and training time by weeks!" - Network Operations Team

๐Ÿšจ Incident Response

"During a security incident, I told Claude: 'Block all traffic from these suspicious IPs and create an audit report.' Done in 15 seconds instead of 5 minutes of clicking through interfaces!" - Security Engineer

๐Ÿ“š Learning & Training Tool

"Perfect for learning OPNsense! New team members can ask Claude to explain what each rule does before applying it. It's like having a network mentor available 24/7." - IT Training Manager

๐Ÿ  Home Lab Enthusiasts

"I can finally manage my home lab firewall properly without memorizing every interface. Just tell it what I want, and it handles the technical details!" - Home Lab Enthusiast


๐ŸŽฏ Try These Commands!

๐Ÿ”ฐ Beginner-Friendly Commands

Perfect for getting started:

  • "Show me the firewall status and health"
  • "List all network interfaces and their status"
  • "What devices are currently connected via DHCP?"
  • "Show me recent firewall activity"
  • "Create a backup of my configuration"
โšก Power User Commands

For network administrators:

  • "Create a geo-blocking rule for all countries except USA and Canada"
  • "Setup a VLAN for IoT devices with restricted internet access"
  • "Analyze security logs and identify potential threats from the last 24 hours"
  • "Create DHCP reservations for all devices in the server VLAN"
  • "Generate SSL certificates for internal services using Let's Encrypt"
๐Ÿš€ Expert-Level Commands

Advanced infrastructure management:

  • "Create a high-availability CARP setup with automatic failover between firewalls"
  • "Configure certificate-based VPN with automatic user provisioning and revocation"
  • "Implement zero-trust network segmentation for the DMZ with micro-segmentation rules"
  • "Setup automated threat response: block IPs with more than 10 failed attempts in 5 minutes"
  • "Create a comprehensive security audit report with compliance recommendations"

๐Ÿ“‹ Requirements

  • ๐Ÿ Python 3.10+ (Modern Python environment)
  • ๐Ÿ”ฅ OPNsense Firewall with API access configured
  • ๐Ÿค– MCP-compatible client (Claude Desktop recommended)
  • ๐Ÿ’พ Minimum 100MB disk space for installation

๐Ÿ“ฆ Prerequisites

  • ๐Ÿ”ง git - For cloning the repository
  • โšก uv - Ultra-fast Python package manager (see installation below)
  • ๐Ÿ”จ jq - JSON processor (for automated Claude Desktop setup)

๐Ÿš€ Installation Guide

Step 1: ๐Ÿ“ฅ Clone the Repository

git clone https://github.com/floriangrousset/opnsense-mcp-server
cd opnsense-mcp-server

Step 2: โšก Install uv (Ultra-Fast Python Manager)

uv is blazing fast and handles everything automatically:

# ๐ŸŽ macOS/Linux - One command install
curl -LsSf https://astral.sh/uv/install.sh | sh

# ๐ŸชŸ Windows (PowerShell)
curl -LsSf https://astral.sh/uv/install.ps1 | powershell -c -

Step 3: ๐Ÿ  Create Virtual Environment

# Create isolated Python environment
uv venv

# Activate it
source .venv/bin/activate        # ๐Ÿง Linux/macOS
# .venv\Scripts\activate         # ๐ŸชŸ Windows

Step 4: ๐Ÿ“š Install Dependencies

# Install all required packages (super fast with uv!)
uv pip install -r requirements.txt

Step 5: ๐Ÿ” Make Scripts Executable (Linux/macOS only)

chmod +x opnsense-mcp-server.py setup-claude.sh

๐ŸŽ‰ Installation Complete!

Time to configure your OPNsense connection...


๐Ÿ” Setup OPNsense API Access

๐Ÿ“Œ Important: Create dedicated API credentials for maximum security!

๐Ÿ”‘ Step-by-Step API Setup:

  1. ๐ŸŒ Login to your OPNsense web interface
  2. ๐Ÿงญ Navigate to System โ†’ Access โ†’ Users
  3. ๐Ÿ‘ค Select the user for API access (or create a dedicated mcp-server user)
  4. ๐Ÿ”‘ Scroll down to the API keys section
  5. โž• Click the + button to generate new API keys
  6. ๐Ÿ“ Download the API key file (contains your credentials)

๐Ÿ’ก Pro Tip: Create a dedicated user with minimal required privileges instead of using admin credentials!


๐Ÿค– Configure Claude Desktop

Choose your preferred setup method:

๐ŸŽฏ Method 1: Auto-Magic Setup (Recommended)

The easiest way - one command does everything!

# Install jq if needed
brew install jq          # ๐ŸŽ macOS
sudo apt install jq     # ๐Ÿง Ubuntu/Debian
sudo yum install jq      # ๐ŸŽฉ RHEL/CentOS

# Run the magic setup script
./setup-claude.sh

๐ŸŽŠ That's it! The script automatically:

  • โœ… Finds your Claude Desktop config
  • โœ… Smart Python detection - Uses virtual environment (.venv/bin/python) if available
  • โœ… Safe configuration - Shows current vs new config before updating
  • โœ… Automatic backups - Creates timestamped backups before any changes
  • โœ… Existing config detection - Asks permission before overwriting existing entries
  • โœ… Creates proper file paths
  • โœ… Sets up everything perfectly

๐Ÿ”„ Restart Claude Desktop and you're ready to go!

๐Ÿ”ง Method 2: Manual Configuration

Click here for manual setup steps
  1. ๐Ÿ“ฅ Install Claude Desktop if you haven't already
  2. ๐Ÿ–ฅ๏ธ Open Claude Desktop
  3. โš™๏ธ Access settings from the Claude menu
  4. ๐Ÿ› ๏ธ Go to the Developer tab
  5. ๐Ÿ“ Click "Edit Config"
  6. ๐Ÿ”ง Add this configuration (replace /path/to/ with your actual path):
{
  "mcpServers": {
    "opnsense": {
      "command": "/FULL/PATH/TO/.venv/bin/python",
      "args": [
        "/FULL/PATH/TO/opnsense-mcp-server.py"
      ],
      "env": {}
    }
  }
}
  1. ๐Ÿ’พ Save the config file
  2. ๐Ÿ”„ Restart Claude Desktop

๐ŸŽฎ Usage Examples

Now the fun begins! Talk to your firewall like you're talking to a network engineer:

๐Ÿ”Œ First Steps: Connect to Your Firewall

Configure my OPNsense firewall with the following information:
URL: https://192.168.1.1
API Key: your_api_key
API Secret: your_api_secret

๐Ÿ“Š System Monitoring

What's the current status of my OPNsense firewall?
Show me system health - CPU, memory, and disk usage
What devices are currently getting DHCP leases?

๐Ÿ”ฅ Firewall Management

List all firewall rules and show me which ones are disabled
Create a rule to allow HTTP and HTTPS from any source to my web server at 192.168.1.100
Block all traffic from China and Russia and add them to my geo-blocking alias
Delete that risky SSH rule we created yesterday

๐ŸŒ Network Configuration

Show me all network interfaces and their current status
Create VLAN 100 on interface em0 for my IoT devices
Set up DHCP for VLAN 100 with range 10.100.1.10 to 10.100.1.200

๐Ÿท๏ธ Alias Management

Show me all firewall aliases and what IPs are in each one
Add these suspicious IPs to my BlockedIPs alias: 192.168.100.50, 10.0.0.200
Create a new alias called "WebServers" with my internal server IPs

๐Ÿ” Certificate Management

List all my SSL certificates and show me which ones expire soon
Create a Let's Encrypt certificate for my domain example.com
Generate a certificate signing request for our internal CA

๐Ÿ“‹ User Management

Create a new read-only user called "monitoring" for our NOC team
Show me all users and their effective privileges
Reset the password for user "john.doe"

๐Ÿ“Š Logging & Analysis

Show me the last 50 firewall blocks and identify any patterns
Analyze security events from the past 24 hours and create a threat report
Export today's logs in JSON format for analysis

๐Ÿ›ก๏ธ Security Operations

Perform a comprehensive security audit of my firewall configuration
Check for any weak configurations or security issues
Analyze certificate expiration status across all certificates

๐Ÿ”ง Advanced Operations

Create a high-availability CARP setup with VIP 192.168.1.200
Set up link aggregation between em0 and em1 using LACP
Configure outbound NAT for my new VLAN to use the WAN interface

๐Ÿ’ก The magic: Just describe what you want in plain English, and watch your firewall configuration happen automatically!


๐Ÿ”’ Security Best Practices

โœ… Recommended Security Setup

Security MeasureImplementationWhy It Matters
๐Ÿ”‘ Dedicated API UserCreate specific mcp-server userLimits blast radius if compromised
๐ŸŽฏ Minimal PrivilegesGrant only necessary permissionsPrinciple of least privilege
๐Ÿ“ IP RestrictionsLimit API access to your networkPrevents external API abuse
๐Ÿ” Audit LoggingEnable comprehensive loggingTrack all API activities
๐Ÿ“Š Regular ReviewsWeekly perform_firewall_auditCatch security drift early
๐Ÿ” HTTPS OnlyForce HTTPS for web interfaceEncrypt all communications

๐Ÿ›ก๏ธ Security Commands to Run Regularly

Perform a comprehensive security audit and show me any issues
Check for any users with excessive privileges
Analyze recent login attempts and flag any suspicious activity
Show me all API access in the last 24 hours

โš ๏ธ Production Environment Guidelines

๐Ÿญ Click here for production security recommendations

๐Ÿšจ Critical for Production Systems:

๐Ÿ”’ Maximum Security Approach
  • Disable Web GUI/API after initial setup on production firewalls
  • Console Management via direct serial cable connection
  • Configuration Staging in isolated lab environment first
๐Ÿ”„ Staging Workflow
  1. ๐Ÿงช Configure in secure lab environment using MCP server
  2. ๐Ÿงช Test all changes thoroughly
  3. ๐Ÿ“ค Export configuration (config.xml)
  4. ๐Ÿ”’ Import to production firewall (running headless)
  5. โœ… Verify via console that changes worked
โš–๏ธ Risk Assessment

This MCP server provides powerful automation but requires API access. Carefully evaluate:

  • ๐ŸŽฏ Threat Model: What are your specific risks?
  • ๐Ÿ” Monitoring: Can you detect API abuse quickly?
  • ๐Ÿšซ Network Isolation: Is the management network properly segmented?
  • ๐Ÿ‘ฅ Team Training: Do operators understand the security implications?

๐Ÿ”ง Troubleshooting

๐Ÿšจ Common Issues & Quick Fixes

ProblemSolutionHow to Check
๐Ÿ”Œ Connection FailedCheck API credentials"Test my OPNsense connection"
๐ŸŒ Network UnreachableVerify firewall accessibilityping 192.168.1.1
๐Ÿ”‘ Authentication ErrorCheck API key/secret formatRegenerate API credentials
๐Ÿšซ Permission DeniedReview user privileges"Show me my user permissions"
๐Ÿ’ป Claude Desktop IssuesCheck MCP server configRestart Claude Desktop

๐Ÿ” Diagnostic Commands

Use these commands to troubleshoot:

Test my connection to OPNsense and show me any errors
Show me the current API user permissions and privileges
Display the last 10 API calls and their results
Check if all required services are running on the firewall

๐Ÿ“‹ Step-by-Step Troubleshooting

  1. ๐Ÿ” Check Connection: curl -k https://YOUR_FIREWALL_IP/api/core/firmware/status
  2. ๐Ÿ”‘ Verify Credentials: Ensure API key/secret are correct
  3. ๐ŸŒ Test Network: Can you access the web interface?
  4. ๐Ÿ› ๏ธ Check Permissions: Does the API user have required privileges?
  5. ๐Ÿ“ฑ Restart Services: Try restarting Claude Desktop
  6. ๐Ÿ“‹ Check Logs: Look at Claude Desktop console for error messages

๐Ÿงช Testing

โœ… Test Suite Status

The project includes a comprehensive test suite with 296 tests covering all core functionality:

# Run all tests
pytest

# Run with verbose output
pytest -v

# Run with coverage report
pytest --cov=src/opnsense_mcp --cov-report=html

# Run specific test file
pytest tests/test_core/test_client_basic.py

Current Status: โœ… 296/296 tests passing (100%)

For detailed test results and coverage information, see .

๐Ÿ”ง Development Testing

# Install development dependencies
uv pip install -e ".[dev]"

# Run tests with detailed output
pytest -vv --tb=short

# Run only fast tests (exclude integration)
pytest -m "not integration"

# Run failed tests from last run
pytest --lf

# Check code quality
black src/ tests/        # Format code
ruff check src/ tests/   # Lint code
mypy src/                # Type checking

๐Ÿค Contributing & Community

๐Ÿ’ก Want to Contribute?

We love contributions! Here's how you can help:

  • ๐Ÿ› Found a bug? Open an issue with details
  • ๐Ÿ’ก Have an idea? Submit a feature request
  • ๐Ÿ”ง Fixed something? Create a pull request
  • ๐Ÿ“š Improved docs? Documentation PRs are welcome!
  • โญ Like the project? Give us a star on GitHub!
  • โœ… All PRs must pass tests - Run pytest before submitting

See CONTRIBUTING.md for detailed contribution guidelines.

๐ŸŒŸ Community & Support

  • ๐Ÿ’ฌ Discussions: Share ideas and get help
  • ๐Ÿ› Issues: Report bugs and request features
  • ๐Ÿ“ง Questions: Ask anything about OPNsense + MCP integration
  • ๐ŸŽ‰ Showcase: Share your automation success stories!

๐Ÿ“š References & Acknowledgements

๐Ÿ”ฅ OPNsenseยฎ

This project interfaces with OPNsense firewalls - a powerful open source, FreeBSD-based firewall and routing platform.

๐Ÿค– Anthropic & Model Context Protocol (MCP)

This server implements MCP to enable AI-powered firewall management through Claude Desktop.

๐ŸŽจ AI Assistance

The project logo and portions of the codebase were created with AI assistance, demonstrating the collaborative future of software development.


๐Ÿ“œ License

This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.

๐Ÿ“Œ What this means:

  • โœ… Free to use for personal and commercial projects
  • โœ… Modify and distribute under the same license
  • โœ… Network use requires sharing source code modifications
  • โœ… Patent protection included

๐Ÿ™ Star History & Recognition

If this project helped you manage your OPNsense firewall more effectively, please consider giving it a โญ on GitHub!

Together, we're making network management more accessible through AI! ๐Ÿš€