VO

vespo92/opnsensemcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

99 stars 19 forks 质量 81 趋势 8MIT

vespo92/opnsensemcp 是从 https://github.com/vespo92/opnsensemcp. 导入的 MCP 服务器候选

概览

vespo92/opnsensemcp 是从 https://github.com/vespo92/opnsensemcp. 导入的 MCP 服务器候选

概述(AI 翻译)

一台用于全面管理 OPNsense 防火墙的模型上下文协议(MCP)服务器。该服务器使像 Claude 这样的 AI 助手能够直接管理防火墙配置、诊断网络问题并自动化复杂网络任务。

特色

🔥 防火墙管理

  • 防火墙规则的完整CRUD操作
  • 正确处理API创建的“自动化规则”
  • VLAN间路由配置
  • 批量规则创建与管理
  • 增强的持久性,采用多种备份方法

🌐 NAT 配置(基于 SSH)

  • 出站NAT规则管理
  • NAT模式控制(自动/混合/手动/禁用)
  • VLAN间流量的无NAT例外规则
  • 自动化 DMZ NAT 问题解决
  • 直接的XML配置操作

🔍 网络诊断

  • 全面的布线分析
  • 带供应商标识的ARP表检查
  • 接口配置管理
  • 网络连接故障排除
  • 针对常见问题的自动修复功能

🖥️ SSH/CLI 执行

  • OPNsense 上的直接命令执行
  • 配置文件操作
  • 系统级操作,API 无法提供
  • 服务管理与重启

📊 附加功能

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

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.

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+ to run the server (Bun 1.1.39+ to develop on it)
  • 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

# Recommended for a new/production router — see "Safety Modes" below
# OPNSENSE_READ_ONLY=true
  1. Start the MCP server:
opnsense-mcp-server

⚠️ Safety Modes (read this before pointing at a production router)

By default this server can make live, immediate changes to your firewall — add/delete rules, change NAT, restart services, run whitelisted shell commands over SSH. Two environment variables (operator-only — a tool call can never set or override them) add a safety net:

Variable Effect
在 GitHub 查看完整 README

安装

npx opnsense-mcp-server
新手?先看 mcpskill.org 教程 →

配置

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