OPNSense MCP Server
A server that enables managing OPNSense firewalls through natural language interactions with Claude Desktop, supporting VLAN management, firewall rules configuration, and network interface queries.
Tools
configure
Configure OPNsense connection
list_vlans
List all VLANs
get_vlan
Get VLAN details
create_vlan
Create a new VLAN
delete_vlan
Delete a VLAN
update_vlan
Update VLAN description
list_firewall_rules
List all firewall rules
get_firewall_rule
Get firewall rule details
create_firewall_rule
Create a new firewall rule
create_firewall_preset
Create a firewall rule from a preset
update_firewall_rule
Update a firewall rule
delete_firewall_rule
Delete a firewall rule
toggle_firewall_rule
Toggle firewall rule enabled/disabled
find_firewall_rules
Find firewall rules by description
create_backup
Create a configuration backup
list_backups
List available backups
restore_backup
Restore a configuration backup
test_connection
Test API connection and authentication
get_interfaces
List available network interfaces
README
OPNSense MCP Server
A Model Context Protocol (MCP) server for managing OPNSense firewalls through natural language interactions with Claude Desktop.
Features
Phase 1 & 2 (Complete)
- VLAN Management: Create, update, delete, and list VLANs
- Firewall Rules: Manage firewall rules with presets and custom configurations
- Network Interfaces: Query available network interfaces
Phase 3 (Infrastructure Ready)
- Configuration Backup System: Automatic backups before changes
- Cache Layer: Redis-based caching for improved performance
- Audit Database: PostgreSQL-based audit trail
- DHCP Lease Management: View and search connected devices
Prerequisites
- Node.js 18+ and npm
- OPNSense firewall with API access enabled
- Claude Desktop with MCP support
- (Optional) Docker for Redis/PostgreSQL deployment
Installation
- Clone the repository:
git clone https://github.com/yourusername/opnsense-mcp.git
cd opnsense-mcp
- Install dependencies:
npm install
- Copy the environment template:
cp .env.example .env
- Configure your OPNSense API credentials in
.env:
OPNSENSE_HOST=https://your-opnsense-ip:port
OPNSENSE_API_KEY=your-api-key
OPNSENSE_API_SECRET=your-api-secret
OPNSENSE_VERIFY_SSL=true
# Start with optional features disabled
ENABLE_CACHE=false
BACKUP_ENABLED=false
- Build the project:
npm run build
Claude Desktop Configuration
Add this to your Claude Desktop configuration:
{
"mcpServers": {
"opnsense": {
"command": "node",
"args": ["C:\\path\\to\\opnsense-mcp\\dist\\index.js"],
"cwd": "C:\\path\\to\\opnsense-mcp"
}
}
}
Usage Examples
Once configured in Claude Desktop, you can use natural language commands:
- "List all VLANs"
- "Create VLAN 30 for gaming on interface igc3"
- "Show all firewall rules"
- "Create a rule to allow Minecraft on the gaming VLAN"
- "Find all rules that allow SSH"
- "Disable the rule blocking port 80"
Optional Features
Redis Cache & PostgreSQL Audit (Phase 3)
For enhanced performance and audit trails, deploy Redis and PostgreSQL:
# On your infrastructure server
docker run -d --name mcp-redis -p 6379:6379 redis:7-alpine
docker run -d --name mcp-postgres -p 5432:5432 \
-e POSTGRES_DB=opnsense_mcp \
-e POSTGRES_USER=mcp_user \
-e POSTGRES_PASSWORD=secure_password \
postgres:15-alpine
Then update your .env:
ENABLE_CACHE=true
REDIS_HOST=your-redis-host
POSTGRES_HOST=your-postgres-host
Architecture
Claude Desktop <--> MCP Server (Local) <--> OPNSense API
|
└--> (Optional) Redis/PostgreSQL
Security Notes
- Never commit
.envfiles with real credentials - Use HTTPS for OPNSense API connections
- Store API keys securely
- Consider network segmentation for management interfaces
Development
# Run TypeScript directly (development)
npm run dev
# Build for production
npm run build
# Run tests
npm test
Roadmap
- [x] Phase 1: Basic VLAN management
- [x] Phase 2: Firewall rule management
- [x] Phase 3: Infrastructure (backup, cache, audit)
- [ ] Phase 4: DHCP static mappings
- [ ] Phase 5: Multi-MCP orchestration
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
MIT License - see LICENSE file for details
Acknowledgments
- Built for the Model Context Protocol
- Designed to work with Claude Desktop
- Part of a larger Infrastructure as Code vision
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。