openwrt-mcp
Provides read-only diagnostics and a gated PassWall 2 node switch for OpenWrt routers over SSH, covering system, network, Wi-Fi, clients, logs, ubus/UCI, services, and PassWall 2 status.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@openwrt-mcp How much RAM and disk space does my router have left?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
openwrt-agent-mcp
A Model Context Protocol server for OpenWrt, built for people who do not want an AI to brick their router.
Read-only by default. 12 read tools; one write tool that is disabled unless you enable it and confirm every call.
Zero runtime dependencies. Python 3.12+, standard library only. No Node, no Docker, no packages installed on the router.
Nothing runs on the router. It connects over SSH from your computer, so
apk upgradeand sysupgrade stay clean.PassWall 2 aware. Status, node list and active node; an optional node switch that snapshots, probes and rolls back by itself.
Persian documentation: README.fa.md
Choose your path
You are… | Start at |
New to OpenWrt | |
A developer | |
Building an AI agent |
Related MCP server: iStoreOS MCP Server
Start here (no OpenWrt experience)
You need three things: the router's address, SSH access, and a key.
1. Find the router address. Open LuCI in a browser. The address is usually
http://192.168.1.1 (some routers use 192.168.8.1 or 192.168.0.1). That is
OPENWRT_MCP_HOST.
2. Turn on SSH. In LuCI: System → Administration → SSH Access. Make sure the SSH server is enabled and the root password is set. On stock OpenWrt SSH is usually already on, port 22.
3. Create a key on your computer (not on the router):
ssh-keygen -t ed25519 -f ~/.ssh/openwrt-agent-mcp -C openwrt-agent-mcp -N ''
ssh-copy-id -i ~/.ssh/openwrt-agent-mcp.pub root@192.168.1.1Test it. It must print OK without asking for a password:
ssh -i ~/.ssh/openwrt-agent-mcp -o BatchMode=yes root@192.168.1.1 'echo OK'4. Run the server's self-test:
./bin/openwrt-mcp --check5. Add it to your AI client. Example for an MCP client that reads
opencode.json-style configuration:
{
"mcp": {
"openwrt": {
"type": "local",
"command": ["/absolute/path/to/openwrt-agent-mcp/bin/openwrt-mcp"],
"environment": {
"OPENWRT_MCP_HOST": "192.168.1.1",
"OPENWRT_MCP_KEY": "/Users/you/.ssh/openwrt-agent-mcp"
}
}
}
}Then ask in plain language:
"How much RAM and disk does the router have left?"
"Which devices are on Wi-Fi, and how strong is their signal?"
"Show me the last 50 log lines and summarise the errors."
"Which PassWall 2 node is active?"
Nothing above changes the router.
Install (developers)
git clone https://github.com/mortezabahmani/openwrt-agent-mcp.git
cd openwrt-agent-mcp
python3 -m unittest discover -s tests # 28 offline tests
./bin/openwrt-mcp --check --simulate # no device needed
./bin/openwrt-mcp # stdio MCP serverThere is no pip install step: the package is standard-library only. If you
prefer an installed entry point:
python3 -m venv .venv && . .venv/bin/activate
pip install -e .
openwrt-agent-mcp --checkMCP client configuration
Most clients accept a command plus environment:
{
"mcpServers": {
"openwrt": {
"command": "/absolute/path/to/openwrt-agent-mcp/bin/openwrt-mcp",
"args": [],
"env": {
"OPENWRT_MCP_HOST": "192.168.1.1",
"OPENWRT_MCP_USER": "root",
"OPENWRT_MCP_KEY": "/Users/you/.ssh/openwrt-agent-mcp"
}
}
}
}Configuration
Variable | Default | Meaning |
|
| Router address |
|
| SSH user |
|
| Private key path |
|
| SSH connect timeout (s) |
|
| Per-command timeout (s) |
|
|
|
|
|
|
Audit log: ~/Library/Logs/openwrt-agent-mcp/ on macOS,
$XDG_STATE_HOME/openwrt-agent-mcp/logs/ on Linux (mode 0600).
Tools
Full schemas and examples: docs/TOOLS.md.
Tool | Type | Returns |
| read | board, release, kernel, uptime, load, memory, overlay |
| read | interfaces, WAN status, routes |
| read | radios, channels, tx power, associated stations |
| read | DHCP leases + neighbours (identifiers masked by default) |
| read | last 1–200 lines of |
| read | objects, or methods of one allowlisted object |
| read | read methods on allowlisted objects |
| read | allowlisted UCI keys; secrets redacted |
| read | init scripts and key daemons |
| read | service instance + running proxy process |
| read | node remarks/type only |
| read | active |
| write | gated node switch with rollback |
PassWall 2
Read tools are always available. The switch tool is deliberately awkward:
PASSWALL2_ALLOW_WRITE=1 + confirm=true + a valid node indexIt then:
snapshots the previous
tcp_node/udp_node;sets both to the requested node and commits;
reloads PassWall 2;
probes DNS (
nslookup example.com);on failure, restores the snapshot, commits and reloads again.
A reload briefly interrupts proxied traffic. That is why it is off by default and why an agent must never call it on its own.
Safety model
Allowlists, not blocklists. Only named ubus objects and UCI configs are reachable.
fileis intentionally excluded: itsread/listmethods would turn a diagnostics server into an arbitrary file reader.No destructive tools. There is no reboot, sysupgrade, factory reset, package install or firewall flush tool.
Output hygiene. MAC addresses, long identifiers and
key/passwordpatterns are masked; output is capped at 12,000 characters.Audit trail. Every call appends one JSON line with tool, result size and error class (never the payload).
Bounded transport.
BatchMode=yes, no password fallback, 8 s connect and 20 s command timeouts.
If you need a capability outside this model, open an issue before opening a PR.
Test without a router
python3 -m unittest discover -s tests # fixtures + fake runner
./bin/openwrt-mcp --check --simulate # end-to-end stdio, no deviceThe simulator (src/openwrt_mcp/sim.py) is a synthetic router: fake ubus/UCI
output, no real addresses, MACs, keys or serials. The local check script uses it, so tests
never touch hardware.
Or run everything at once (lint is skipped if ruff is not installed):
./scripts/check.shContinuous integration (optional)
Hosted CI is not required. docs/ci-github-actions.yml is a ready workflow;
copy it to .github/workflows/ci.yml if your GitHub account can run Actions.
The same steps run locally in scripts/check.sh.
Troubleshooting
Symptom | Cause | Fix |
| key not authorised | run |
| changed host key | remove the old entry from |
| by design | use a dedicated tool |
| gate is closed | set |
| PassWall 2 has no nodes | add nodes in LuCI first |
| node is unreachable | the previous node was restored automatically |
Contributing
See CONTRIBUTING.md. Security reports: SECURITY.md.
License
MIT — see LICENSE.
Available Tools
13 toolsclientsB
Read-only: DHCP leases and ARP neighbours. Identifiers masked by default.
Inputs: include_identifiers.
logsA
Read-only: last N lines of logread (1..200).
Inputs: lines.
network_statusA
Read-only: interfaces, WAN status (ubus), and the routing table.
Inputs: no named parameters.
passwall2_activeB
Read-only: the tcp_node and udp_node currently selected.
Inputs: no named parameters.
passwall2_nodesA
Read-only: configured PassWall 2 nodes. Only remarks/type are returned; servers, ports, keys and UUIDs never leave the router.
Inputs: no named parameters.
passwall2_statusB
Read-only: PassWall 2 service instance and running proxy process.
Inputs: no named parameters.
passwall2_switch_nodeA
WRITE (gated): switch PassWall 2 to a node index. Requires PASSWALL2_ALLOW_WRITE=1 and confirm=true. Snapshots the previous node, reloads the service, probes DNS, and restores on failure.
Inputs: index (required), confirm.
service_statusC
Read-only: init scripts and key daemon processes.
Inputs: no named parameters.
system_infoB
Read-only: board, OpenWrt release, kernel, uptime, load, memory, overlay.
Inputs: no named parameters.
ubus_callB
Read-only: call a read method on an allowlisted ubus object. State-changing methods are refused before any SSH connection.
Inputs: method (required), object (required), args_json.
ubus_listA
Read-only: list ubus objects, or methods of one allowlisted object.
Inputs: object.
uci_getA
Read-only: uci get for an allowlisted config key. Secrets are redacted.
Inputs: key (required).
wifi_statusB
Read-only: radios, channels, tx power and associated stations.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Most tools cover clearly distinct resources: system, network, wifi, clients, logs, ubus, uci, services, and PassWall. The PassWall trio (status, nodes, active) and generic service_status could be momentarily confused, but their descriptions make the boundaries clear.
All names use snake_case, with a readable resource_status or namespace_action pattern such as network_status, ubus_list, uci_get, and passwall2_switch_node. Bare names like clients and logs are minor deviations but still clear.
13 tools is a well-scoped count for router diagnostics plus focused PassWall management. Each tool covers a distinct observability area or a clearly gated write operation.
The read-only surface is broad and covers the main diagnostic areas of an OpenWrt router, including system, network, wifi, clients, logs, ubus, uci, services, and PassWall. It intentionally lacks broader write operations such as uci_set, service restart, firewall inspection, or package management, which are minor gaps given the safe read-only design.
Maintenance
Related MCP Connectors
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
IP intelligence, network diagnostics, and AI service availability tools for AI agents.
Zero-trust gateway for AI agents: score tool calls, verify agent cards, enforce policy, audit.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables 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.1917MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to read-only monitor iStoreOS/OpenWRT routers via SSH or HTTP/ubus API, providing 31 tools for system status, network info, logs, and plugin status (OpenClash, Passwall, AdGuardHome, etc.).31MIT
- AlicenseBqualityDmaintenanceEnables management of OpenWrt routers via SSH, providing tools for network configuration, system administration, file operations, and package management through natural language.572MIT
- FlicenseAqualityDmaintenanceEnables read-only access to OpenWrt router state over LuCI's HTTP /ubus/ JSON-RPC interface without SSH, covering system info, networking, Wi-Fi, firewall, logs, storage, packages, and diagnostics.301-