LO

lucamarien/opnsense-mcp-server

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

27 stars 12 forks 品質 83 トレンド 14MIT

AI アシスタントを通じて OPNsense ファイアウォールを管理するためのセキュアな MCP サーバー。 既読のみのデフォルト、保存ポイントのロールバック、およびセキュリティ監査で10ドメインにわたる62ツール.

概要

Claudeコード、Cursor、その他のMCP対応ツールなどのAIアシスタントを通じて、OPNsenseファイアウォールを管理するためのセキュアなモデルコンテキストプロトコル(MCP)サーバー。 システム、ファイアウォール、ネットワーク、DNS、DHCP、VPN、HAProxy、サービス、診断、セキュリティ - - — MCP サーバーは OPNsense 24.7 で導入された MVC ベースの API エンドポイントに依存しています。 古いバージョンでは、互換性のない異なるAPI構造を使用します。 サーバは、OPNsense 版を最初に接続し、正しいエンドポイントの命名(camelCase for pre-25.7, 25.7+ のヘビ case)を選択します。 OPNsense 26.xは変更されたファームウェアの状態の応答のフォーマットを含む十分に支えられます。 このMCPサーバーは、主要な懸念としてセキュリティで設計されています。 - — 書き込み操作は、OPNSENSE ALLOW WRITES=true を介して明示的にオプトインする必要があります。OPNsense が保存ポイント API を提供し、ファイアウォールの変更は内蔵60秒の自動変換を使用します。変更は明示的に確認され、自動的にロールバックします.

概要(AI 翻訳)

Claudeコード、Cursor、その他のMCP対応ツールなどのAIアシスタントを通じて、OPNsenseファイアウォールを管理するためのセキュアなモデルコンテキストプロトコル(MCP)サーバー。

81ツール10ドメインのシステム、ファイアウォール、ネットワーク、DNS、DHCP、VPN、HAProxy、サービス、診断、セキュリティ。

要件

  • Python 3.11+
  • OPNsense 24.7 または newer — MCP サーバは OPNsense 24.7 で導入された MVC ベースの API エンドポイントに依存しています。 古いバージョンでは、互換性のない異なるAPI構造を使用します。 サーバは、OPNsense 版を最初に接続し、正しいエンドポイントの命名(camelCase for pre-25.7, 25.7+ のヘビ case)を選択します。 OPNsense 26.xは変更されたファームウェアの状態の応答のフォーマットを含む十分に支えられます。

##セキュリティモデル

このMCPサーバーは、主要な懸念としてセキュリティで設計されています。

-デフォルトで読み込み専用 — 書き込み操作は[[OPNSENSE_ALLOW_WRITES=true]を介して明示的にオプトインを必要とします

  • Savepoint/rollback (OPNsense Access) > ユーザ 3。 既存のユーザーを編集するか、専用の API ユーザーを作成します。
  • 生産使用のために、必要な特権のみで専用のユーザー(例、mcp-api)を作成します

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

OPNsense MCP Server

A secure Model Context Protocol (MCP) server for managing OPNsense firewalls through AI assistants like Claude Code, Cursor, and other MCP-compatible tools.

81 tools across 10 domains: system, firewall, network, DNS, DHCP, VPN, HAProxy, services, diagnostics, and security.

Requirements

  • Python 3.11+
  • OPNsense 24.7 or newer — the MCP server relies on the MVC-based API endpoints introduced in OPNsense 24.7. Older versions use a different API structure that is not compatible. The server auto-detects the OPNsense version on first connect and selects the correct endpoint naming (camelCase for pre-25.7, snake_case for 25.7+). OPNsense 26.x is fully supported, including its changed firmware status response format.

Security Model

This MCP server is designed with security as the primary concern:

  • Read-only by default — write operations require explicit opt-in via OPNSENSE_ALLOW_WRITES=true
  • Savepoint/rollback (OPNsense < 26.7 only) — where OPNsense still offers the savepoint API, firewall modifications use its built-in 60-second auto-revert; changes must be explicitly confirmed or they roll back automatically. OPNsense 26.7 removed that API upstream — the server detects the missing endpoint at runtime and applies firewall changes immediately, with no automatic rollback
  • Endpoint blocklist — dangerous endpoints (halt, reboot, poweroff, firmware update/upgrade) are hard-blocked at the API client level and can never be called
  • API-only — no SSH access, no command execution, no direct config file manipulation
  • Local transport — STDIO only, no network-exposed HTTP/SSE endpoints
  • No credential exposure — API keys are never included in tool output, logs, or error messages
  • Input validation — hostname parameters are validated against shell metacharacter injection
  • Sensitive data stripping — config backup strips passwords and keys by default

Quick Start

1. Create an OPNsense API Key

  1. Log in to your OPNsense web interface
  2. Go to System > Access > Users
  3. Either edit an existing user or create a dedicated API user:
    • For production use, create a dedicated user (e.g., mcp-api) with only the privileges needed
    • For read-only access, assign the user to a group with read-only API access
  4. Scroll down to the API keys section and click the + button
  5. A key/secret pair will be generated and a file (apikey.txt) will be downloaded
  6. The file contains two lines — key=your-api-key-here and secret=your-api-secret-here
  7. Store these credentials securely — the secret cannot be retrieved again from OPNsense

Tip: For a read-only setup (recommended for getting started), you don’t need to change any permissions — the default API access is sufficient for all read-only tools.

2. Install

# Using pip
pip install opnsense-mcp-server
GitHub で README 全文を見る

インストール

docker run -i --rm -e OPNSENSE_URL=https://192.168.1.1/api -e OPNSENSE_API_KEY=your-api-key-here -e OPNSENSE_API_SECRET=your-api-secret-here -e OPNSENSE_VERIFY_SSL=false -e OPNSENSE_ALLOW_WRITES=false uhlenheide/opnsense-mcp-server
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "opnsense": { "command": "opnsense-mcp", "env": { "OPNSENSE_URL": "https://192.168.1.1/api", "OPNSENSE_API_KEY": "your-api-key-here", "OPNSENSE_API_SECRET": "your-api-secret-here", "OPNSENSE_VERIFY_SSL": "false", "OPNSENSE_ALLOW_WRITES": "false" } } } }