OpenWRT SSH MCP Server

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.

Category
Visit Server

README

OpenWRT SSH MCP Server ๐Ÿณ

Status Docker Python MCP

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 connection
  • openwrt_execute_command - Execute raw command (validated)
  • openwrt_get_system_info - System info (uptime, memory, CPU)
  • openwrt_restart_interface - Restart network interface
  • openwrt_get_wifi_status - WiFi status and clients
  • openwrt_list_dhcp_leases - List DHCP clients
  • openwrt_get_firewall_rules - View firewall rules
  • openwrt_read_config - Read UCI config file

OpenThread Border Router (5 tools)

  • openwrt_thread_get_state - Current Thread state
  • openwrt_thread_create_network - Create new Thread network
  • openwrt_thread_get_dataset - Get network credentials
  • openwrt_thread_get_info - Complete Thread network info
  • openwrt_thread_enable_commissioner - Allow new devices

Package Management (6 tools)

  • openwrt_opkg_update - Update package lists
  • openwrt_opkg_install - Install IPK packages
  • openwrt_opkg_remove - Remove packages
  • openwrt_opkg_list_installed - List installed packages
  • openwrt_opkg_info - Detailed package info
  • openwrt_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 .env out of version control
  • Review commands before production execution
  • Enable audit logging
  • Limit SSH access from router to your PC

๐Ÿ“š Documentation

๐Ÿš€ Quick Start

๐Ÿ“– Detailed Guides

๐Ÿงช 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:

  1. Fork the project
  2. Create a branch for your feature
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

๐Ÿ“– Resources

๐Ÿ“„ License

MIT


Made with โค๏ธ for the OpenWRT and MCP community

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured