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
- π³ Docker Ready - Optimized image with multi-stage build (271MB)
- π Robust Security - Command whitelist, read-only filesystem, audit logging
- π οΈ 23 OpenWRT Tools - Complete router management (network, system, Thread, packages, firmware OTA)
- π 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
βββββββββββββββββββββββ
β 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) β
βββββββββββββββββββββββ
- π 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
- Python 3.10+
- OpenWRT router with SSH enabled
- SSH access to router (root user recommended)
cd "c:\Users\Luis Antonio\Documents\UNAL\MCPs-OpenWRT"python -m venv venv
.\venv\Scripts\activate # Windows
pip install -e .# Copy example file
copy .env.example .env
# Edit .env with your router credentials# 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_routerIncludes 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"
]
}
}
}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.ps1Use 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 allopenwrt_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
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
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
openwrt_firmware_version- Current firmware version, board model, release infoopenwrt_firmware_upload- SCP a local.img/.binto/tmp/firmware.imgwith SHA256 checkopenwrt_firmware_verify-sysupgrade -Tto validate without flashingopenwrt_firmware_flash- Flash viasysupgradewith optionalkeep_settings(clean install when false)
Once configured, you can ask Claude:
- "Show me the WiFi status on my router"
- "List connected devices"
- "Restart the wan interface"
- "What's the router's memory usage?"
- "Update the package repositories"
- "Install the luci-app-openthread package"
- "Show me installed packages"
- "Give me information about the ot-br-posix package"
- "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"
- 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
- QUICKSTART_DOCKER.md - Quick start with Docker
- TEST_OPKG.md - Test IPK package management
- DOCKER_GUIDE.md - Complete Docker guide
# 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- β 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
- π 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
# Publish your image
docker login
docker tag openwrt-ssh-mcp:latest yourusername/openwrt-ssh-mcp:latest
docker push yourusername/openwrt-ssh-mcp:latest# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black .
ruff check --fix .
# Rebuild after changes
.\docker-mcp.ps1 buildContributions are welcome! Please:
- Fork the project
- Create a branch for your feature
- Commit your changes
- Push to the branch
- Open a Pull Request
MIT
Made with β€οΈ for the OpenWRT and MCP community