Provides comprehensive management of ASUS routers running Asuswrt-Merlin firmware, including system monitoring, device management, WiFi control, service restarts, NVRAM operations, file transfers, VPN management, and custom command execution via SSH/SCP.
ASUS Merlin Router MCP Server
Model Context Protocol (MCP) server for managing ASUS routers running Asuswrt-Merlin firmware via SSH/SCP.
Features
System Information: Get router uptime, memory, CPU, firmware version
Device Management: List connected devices
WiFi Control: Check WiFi status across all radios
Service Management: Restart services (wireless, VPN, etc.)
NVRAM Operations: Read/write router configuration variables
File Operations: Upload/download files via SCP
VPN Management: Check VPN status
Process Monitoring: List running processes
Custom Commands: Execute any SSH command
Prerequisites
Router Setup
Enable SSH on your router:
Login to router web interface
Go to Administration > System
Set Enable SSH to LAN only (or LAN & WAN if needed)
Click Apply
(Recommended) Set up SSH key authentication:
# On your Debian workstation ssh-keygen -t rsa -b 4096 # Copy your public key to router ssh-copy-id admin@192.168.1.1 # Or manually via web interface: # Administration > System > SSH Authentication Key
Debian Workstation Setup
Installation
Option 1: Local Installation (Recommended for Development)
Clone or create project directory:
mkdir asus-merlin-mcp cd asus-merlin-mcpSave the MCP server code as
Create virtual environment and install dependencies:
python3 -m venv venv source venv/bin/activate pip install -r requirements.txtConfigure router connection:
cp .env.example .env nano .env # Edit with your router detailsTest the connection:
# Export environment variables export $(cat .env | xargs) # Run the server (it will connect via stdio) python asus_merlin_mcp.py
Option 2: Docker Installation
Build the Docker image:
docker build -t asus-merlin-mcp .Edit docker-compose.yml with your router credentials
Run with Docker Compose:
docker-compose up -d
Option 3: Podman Installation
Claude Configuration
The configuration location depends on which Claude installation you're using:
Claude Code (Native Installation)
MCP servers are automatically configured in ~/.claude.json
under your project path:
Config file: ~/.claude.json
For Local Installation:
For Docker Installation:
For Podman Installation:
Claude Code (NPM Installation)
Config file: ~/.claude/settings.json
For Local Installation:
For Docker Installation:
For Podman Installation:
Claude Desktop
Config file locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows:
%APPDATA%\Claude\claude_desktop_config.json
Linux:
~/.config/Claude/claude_desktop_config.json
For Local Installation:
For Docker Installation:
For Podman Installation:
Important Notes:
Replace
/home/yourusername
with your actual home directory path (e.g.,/home/triskull
)Do NOT use
${HOME}
or~
in JSON configuration files - they will not expandAfter updating the configuration file, restart Claude Code or Claude Desktop for the changes to take effect
Usage Examples
Once configured in Claude Desktop, you can interact with your router:
Example prompts:
"What's the current status of my router?"
"List all connected devices"
"Restart the wireless service"
"Show me the WiFi configuration"
"Get the value of wan_ipaddr from NVRAM"
"Upload this backup script to /jffs/scripts/"
"Check if VPN is running"
"Show me the router's system log"
Available Tools
Tool | Description |
| System info (uptime, memory, firmware) |
| List DHCP clients |
| WiFi status for all radios |
| Restart specific service |
| Reboot router (requires confirmation) |
| Read NVRAM variable |
| Write NVRAM variable |
| Run custom SSH command |
| Read file from router |
| Upload file (tries SFTP, falls back to shell if unavailable) |
| Download file (tries SFTP, falls back to shell if unavailable) |
| Check VPN status |
| Show running processes |
Common Services to Restart
wireless
- WiFi serviceswan
- WAN connectionhttpd
- Web interfacevpnclient1
- VPN client 1vpnclient2
- VPN client 2dnsmasq
- DNS/DHCP server
Security Notes
Use SSH keys instead of passwords for better security
Enable SSH on LAN only unless you need WAN access
Be careful with NVRAM operations - incorrect values can break your router
Test commands manually first before automating
Keep backups of your router configuration
Troubleshooting
Connection Issues
Permission Denied
Import Errors
Volume Mount Errors (Docker/Podman)
If you see an error like:
Cause: JSON configuration files do not expand shell variables like ${HOME}
or ~
.
Solution: Replace ${HOME}
with your actual home directory path in the configuration:
To find your home directory:
How-To Guide: Common Administrative Tasks
This section provides practical examples for common router administration tasks using the MCP tools.
Managing the Hosts File
The router's custom hosts file (/jffs/configs/hosts.add
) allows you to add static DNS entries that persist across reboots.
View Current Hosts File
Via Claude:
MCP Tool Used: read_file
Add a New Host Entry
Option 1: Download, Edit, Upload (Recommended)
Download the file:
"Download /jffs/configs/hosts.add from the router to ./hosts.add"Uses: Note: Downloads are MD5 checksum verified for integrity
Edit the file locally with your text editor:
nano hosts.add # Add line like: # 192.168.0.100 newserver.damage.inc newserverUpload back to router:
"Upload ./hosts.add to /jffs/configs/hosts.add on the router"Uses: Note: Uploads are MD5 checksum verified to ensure file integrity
Apply changes:
"Restart the dnsmasq service"Uses:
Option 2: Direct Command
Via Claude:
Uses:
Then restart dnsmasq:
Update an Existing Host Entry
Download the hosts file
Edit locally to change the desired line
Upload back to router
Restart dnsmasq
Remove a Host Entry
Via Claude:
Replace
Managing NVRAM Variables
NVRAM stores persistent router configuration. Warning: Incorrect values can break your router!
Get a Single NVRAM Variable
Uses:
Set an NVRAM Variable (Without Commit)
Uses:
This sets the variable in RAM but won't persist across reboots.
Set and Commit NVRAM Variable
Uses:
⚠️ Warning: Committed changes persist across reboots. Double-check values before committing!
Backup NVRAM to File
Managing Custom Scripts
Scripts in /jffs/scripts/
persist across reboots and can run at various router events.
Common Script Hooks
init-start
- First script run during bootservices-start
- Runs after router services startwan-start
- Runs when WAN interface comes upfirewall-start
- Runs when firewall starts
Upload a Custom Script
MD5 checksum automatically verified to ensure script integrity
Then make it executable:
View Existing Scripts
Read a Script's Contents
Monitoring and Diagnostics
Check System Resources
Uses:
List All Connected Devices
Uses:
Find a Specific Device
Check WiFi Status
Uses:
View System Logs
Uses:
Monitor Running Processes
Uses:
VPN Management
Check VPN Status
Uses:
View VPN Configuration
Restart VPN Client
Uses:
Service Management
Restart Wireless Service
Useful after changing WiFi settings
Restart WAN Connection
Forces WAN reconnection
Restart Web Interface
Restarts the router's web UI
File Management
Note: All file uploads and downloads are cryptographically verified using MD5 checksums to ensure data integrity. This is especially important for binary files, scripts, and executables.
Download Router Files
Checksum verified for integrity
Upload Configuration Files
Checksum verified to prevent corruption
Check File Permissions
Make Script Executable
Advanced Router Operations
Backup Entire JFFS Partition
View Network Connections
Check Router Temperature (if supported)
Reboot Router
Requires confirmation -
Tips and Best Practices
Always test commands manually first before automating them
Keep backups of configuration files before making changes
Use descriptive hostnames in hosts.add for easier management
Document your custom scripts with comments
Restart services after configuration changes to apply them
Use SSH keys instead of passwords for better security
Be cautious with NVRAM commits - test without commit first
Monitor logs after making changes to catch issues early
Advanced Usage
Backup Router Configuration
Upload Custom Scripts
Monitor Router Health
Contributing
Feel free to extend this MCP server with additional tools for:
Traffic monitoring
Firewall rule management
Bandwidth statistics
Port forwarding configuration
Guest network management
Resources
License
MIT License - Use at your own risk. Always maintain backups of your router configuration.
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables management of ASUS routers running Asuswrt-Merlin firmware via SSH/SCP. Supports system monitoring, device management, WiFi control, service restarts, NVRAM operations, file transfers, VPN management, and custom command execution.