OpenWRT SSH MCP Server
Enables AI agents to manage OpenWRT routers remotely via SSH, supporting system monitoring, network management, OpenThread Border Router configuration, and package management through natural language commands.
README
OpenWRT SSH MCP Server 🐳
A containerized MCP (Model Context Protocol) server for managing OpenWRT routers via SSH. This server allows AI agents (like Claude) to execute commands and manage OpenWRT routers remotely and securely.
🎉 STATUS: ✅ Fully functional and tested with physical router
✨ Features
- 🐳 Docker Ready - Optimized image with multi-stage build (271MB)
- 🔐 Robust Security - Command whitelist, read-only filesystem, audit logging
- 🛠️ 19 OpenWRT Tools - Complete router management (network, system, Thread, packages)
- 🚀 Easy Integration - Compatible with Claude Desktop and VS Code
- 📊 Monitoring - Detailed logs of all operations
- 🔄 MCP Toolkit - Fully compatible with Docker Desktop MCP
- 📦 Package Management - Install/remove IPK packages with opkg
- 🔗 OpenThread OTBR - Support for Thread Border Router
Architecture
┌─────────────────────┐
│ Claude / VS Code │ ← Your AI agent
└──────────┬──────────┘
│ MCP Protocol (stdio)
│
┌──────────▼──────────┐
│ Docker Container │ ← MCP Server
│ ┌──────────────┐ │
│ │ MCP Server │ │
│ │ (Python) │ │
│ └──────┬───────┘ │
└─────────┼───────────┘
│ SSH
│
┌─────────▼───────────┐
│ OpenWRT Router │ ← Your physical router
│ (192.168.1.1) │
└─────────────────────┘
Features
- 🔐 Secure SSH authentication (password or key-based)
- 🛠️ OpenWRT-specific tools (ubus, uci)
- ✅ Command validation with whitelist
- 📝 Audit logging
- 🐳 Docker support (optional)
- 🔌 Integration with Claude Desktop and VS Code
Requirements
- Python 3.10+
- OpenWRT router with SSH enabled
- SSH access to router (root user recommended)
Installation
1. Clone or create the project
cd "c:\Users\Luis Antonio\Documents\UNAL\MCPs-OpenWRT"
2. Create virtual environment and install dependencies
python -m venv venv
.\venv\Scripts\activate # Windows
pip install -e .
3. Configure SSH credentials
# Copy example file
copy .env.example .env
# Edit .env with your router credentials
4. Generate and copy SSH key (recommended)
# Generate dedicated key
ssh-keygen -t ed25519 -f ~/.ssh/openwrt_router -C "MCP Server"
# Copy to router
ssh-copy-id -i ~/.ssh/openwrt_router.pub root@192.168.1.1
# Update .env
OPENWRT_KEY_FILE=C:\Users\YOUR_USER\.ssh\openwrt_router
🔧 Configuration
Claude Desktop (Docker)
Includes optimized configuration in claude_desktop_config.json:
{
"mcpServers": {
"openwrt-router-docker": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"--network", "host",
"--env-file", "C:\\Users\\Luis Antonio\\Documents\\UNAL\\MCPs-OpenWRT\\.env",
"--mount", "type=bind,src=C:\\Users\\Luis Antonio\\.ssh,dst=/root/.ssh,readonly",
"openwrt-ssh-mcp:latest"
]
}
}
}
VS Code with GitHub Copilot
The project includes complete VS Code configuration:
Option 1: Direct Python (Recommended)
# Open workspace
code mcp-openwrt.code-workspace
# In Copilot Chat (Ctrl+Shift+I):
"What OpenWRT tools do I have available?"
Option 2: With Tasks
Terminal > Run Task > "Start MCP Server (Python)"
Option 3: Startup Script
.\start-mcp-vscode.ps1
Script Helper
Use docker-mcp.ps1 for all operations:
.\docker-mcp.ps1 build # Build image
.\docker-mcp.ps1 run # Run server
.\docker-mcp.ps1 test # Test connection
.\docker-mcp.ps1 logs # View logs
.\docker-mcp.ps1 shell # Open shell
.\docker-mcp.ps1 clean # Clean all
🛠️ Available Tools
System & Network (8 tools)
openwrt_test_connection- Test SSH connectionopenwrt_execute_command- Execute raw command (validated)openwrt_get_system_info- System info (uptime, memory, CPU)openwrt_restart_interface- Restart network interfaceopenwrt_get_wifi_status- WiFi status and clientsopenwrt_list_dhcp_leases- List DHCP clientsopenwrt_get_firewall_rules- View firewall rulesopenwrt_read_config- Read UCI config file
OpenThread Border Router (5 tools)
openwrt_thread_get_state- Current Thread stateopenwrt_thread_create_network- Create new Thread networkopenwrt_thread_get_dataset- Get network credentialsopenwrt_thread_get_info- Complete Thread network infoopenwrt_thread_enable_commissioner- Allow new devices
Package Management (6 tools)
openwrt_opkg_update- Update package listsopenwrt_opkg_install- Install IPK packagesopenwrt_opkg_remove- Remove packagesopenwrt_opkg_list_installed- List installed packagesopenwrt_opkg_info- Detailed package infoopenwrt_opkg_list_available- List available packages
💬 Usage Examples
Once configured, you can ask Claude:
System & Network
- "Show me the WiFi status on my router"
- "List connected devices"
- "Restart the wan interface"
- "What's the router's memory usage?"
Package Management
- "Update the package repositories"
- "Install the luci-app-openthread package"
- "Show me installed packages"
- "Give me information about the ot-br-posix package"
OpenThread
- "Create a Thread network called 'MyHome' on channel 15"
- "Show me the Thread network status"
- "Enable the commissioner to add new devices"
- "Give me the Thread network credentials"
Security
⚠️ IMPORTANT: This server has root access to your router. Make sure to:
- Use SSH key authentication (not password)
- Keep
.envout of version control - Review commands before production execution
- Enable audit logging
- Limit SSH access from router to your PC
📚 Documentation
🚀 Quick Start
- QUICKSTART_DOCKER.md - Quick start with Docker
- TEST_OPKG.md - Test IPK package management
📖 Detailed Guides
- DOCKER_GUIDE.md - Complete Docker guide
🧪 Testing
# Test with helper script
.\docker-mcp.ps1 test
# Test with MCP Inspector
npm install -g @modelcontextprotocol/inspector
npx @modelcontextprotocol/inspector docker run -i --rm openwrt-ssh-mcp:latest
# View logs
.\docker-mcp.ps1 logs
🔐 Implemented Security
- ✅ Read-only filesystem - Immutable container
- ✅ No capabilities - No special permissions
- ✅ SSH keys read-only - Protected keys
- ✅ Command whitelist - Only safe commands
- ✅ Audit logging - Complete logging
- ✅ Volatile tmpfs - /tmp cleaned on restart
- ✅ No privilege escalation - No sudo
🎯 Use Cases
Advanced Workflows
- 🔄 Automated backup of UCI configurations
- 📊 Network monitoring - Connected devices, resource usage
- 🔧 AI-guided troubleshooting
- 📝 Automatic documentation of changes
- 🚨 Network anomaly alerts
- 📦 Package management - Install/update software
- 🔗 Thread configuration - Create and manage Thread/Matter networks
- 🛡️ Security auditing - Review firewall rules
🐳 Docker Hub (Optional)
# Publish your image
docker login
docker tag openwrt-ssh-mcp:latest yourusername/openwrt-ssh-mcp:latest
docker push yourusername/openwrt-ssh-mcp:latest
🛠️ Development
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black .
ruff check --fix .
# Rebuild after changes
.\docker-mcp.ps1 build
🤝 Contributing
Contributions are welcome! Please:
- Fork the project
- Create a branch for your feature
- Commit your changes
- Push to the branch
- Open a Pull Request
📖 Resources
📄 License
MIT
Made with ❤️ for the OpenWRT and MCP community
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。