openwrt-ubus-mcp
Allows an AI assistant to manage an OpenWrt router through its ubus JSON-RPC API without SSH or router-side software, with read tools for router status, interfaces, DHCP leases, Wi-Fi clients, firewall configuration, UCI config and logs, plus narrow write tools for DHCP static leases, port forwards and firewall traffic rules using preview, confirm and rollback protection.
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-ubus-mcp check router status and list connected Wi-Fi clients"
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-ubus-mcp
openwrt-ubus-mcp lets an AI assistant manage an OpenWrt router without SSH, root, or any software installed on the router. It talks only to the router's own ubus JSON-RPC API, the one LuCI uses, as a dedicated login, so the router itself enforces what the AI may touch, through a stock rpcd ACL. Every change is previewed, applied under OpenWrt's rollback timer, and confirmed only after a fresh login proves the router still answers, so a bad firewall rule reverts itself instead of locking you out. Wi-Fi keys and passwords are redacted before anything leaves the server.
Status: v0.1.1, December 2026, on PyPI, GHCR and the MCP Registry. MIT licensed. The engineering notebook (docs/NOTEBOOK.md) records how it was built and live-tested, including the rpcd behaviour the live tests uncovered. The story behind it, in plain words: Letting Claude manage my OpenWrt router, without giving it the keys.
What it is, and what it isn't
It is a small Python MCP server that runs on any machine that can reach the router (your laptop, a home server, a container). It offers read tools for the router's state and a few narrow write tools: DHCP static leases, port forwards and firewall traffic rules.
It isn't a remote shell, a firmware or package manager, or a general UCI editor. It can't touch interfaces, the WAN or wireless settings, and it can't reboot the router. That is on purpose (see Limits). It is not affiliated with the OpenWrt project.
Related MCP server: OpenWrt MCP Controller
The safety model
ubus only. The server speaks rpcd's JSON-RPC over HTTP(S) at
/ubus. There is no SSH session, no shell, and nofileorexeccall anywhere in the code.The router enforces the limits. The server logs in as its own rpcd user. The ACL (rpcd/acl.d/openwrt-ubus-mcp.json) allows a short list of read calls, plus UCI writes to the
dhcpandfirewallconfigs only. A bug in this server, or a confused AI, can't widen that: rpcd refuses anything else. Without the write group the login is read-only.Preview, then confirm. Every write tool first returns the exact UCI changes it would make and leaves nothing staged. Only a second call with
confirm: trueapplies them. Clients that show tool calls put that preview in front of you.Changes undo themselves. A confirmed change is applied with
uci applyand the rollback timer armed (30 s). The server waits for services to settle (5 s), checks that a fresh login still works, and only then sendsuci confirm. If the router stops answering, nothing confirms the change and the router restores the old config on its own. The server watches until it has, and reportsrolled_back.Only its own entries. Sections the server creates are named
mcp_*in UCI, and its firewall entries show in LuCI asmcp:<name>. The remove tools refuse anything else unless you passforce: true.Secrets stay on the router. Wi-Fi keys, PSKs, passwords and private keys are shown as
***in tool output and in the server's own logs, matched both by option name and by value. Tests enforce it, and the live check compares every output against the router's real secrets.
Before | Applied, not confirmed (+10 s) | Rolled back by the router (+45 s) |
|
|
|
The rollback test in LuCI's Traffic Rules. The server added a disabled rule, mcp:rollback-test,
so it changed nothing, and deliberately didn't confirm it. The router removed it by itself 30 s
after apply. The "before" and "after" images are byte-identical files.
More screenshots.
Tools
Read | |
| model, firmware, kernel, uptime, load, memory |
| lan/wan/...: up, protocol, device, addresses, gateway, DNS |
| active DHCPv4 and DHCPv6 leases |
| each radio: SSID, channel, TX power, signal, encryption |
| associated stations with signal and rates, named from the DHCP leases |
| zones, forwardings, rules and port forwards |
| one of |
| the last lines of the log, optionally filtered |
| anything staged in the server's session (normally nothing) |
Write (preview, then | |
| DHCP static leases (MAC, IPv4 address in the LAN subnet, hostname) |
| port forwards (firewall |
| traffic rules (ACCEPT, DROP or REJECT; IPv4, IPv6 or both) |
Inputs are checked before anything is staged: MAC addresses, hostnames, port ranges and zones. A lease's IP must be inside the LAN subnet (not the network, broadcast or router address), and its MAC, IP and name must not already be in use.
1. Set up the router (once)
You need rpcd and uhttpd-mod-ubus, which come with LuCI on stock OpenWrt images. Copy the
rpcd folder to the router and run the installer there:
scp -O -r rpcd root@192.168.1.1:/tmp/
ssh -t root@192.168.1.1 sh /tmp/rpcd/install.sh --writeIt asks for a password (12 characters or more) and stores only its hash, made with
uhttpd -m. It installs the ACL and creates one rpcd login named mcp. Leave out
--write for a read-only login. Running it again updates the same login, removing any
duplicates, instead of adding another.
It also lists the ACL file in /etc/sysupgrade.conf. A firmware upgrade keeps /etc/config/rpcd
(the login) but not files added under /usr/share, so without that line the login would survive
an upgrade with no permissions at all. Tested with real upgrades: with the line the ACL is kept;
without it, it is lost.
Things that trip people up:
scp -Ois needed because OpenWrt's dropbear has no SFTP server.Copy to
/tmp/as shown, not to a named folder: when the target folder already exists, a secondscp -rputs the files one level deeper and you'd run the old copy.The installer restarts rpcd, which logs everyone out of LuCI. Just log in again.
To undo it, run ssh root@192.168.1.1 sh /tmp/rpcd/uninstall.sh. It removes the
login, the ACL and its sysupgrade.conf line, and lists any mcp_* entries still in dhcp or firewall so you can
remove them too. If you'd rather set it up by hand, rpcd/login.example
shows the login section.
2. Run the server
Settings come from environment variables (see example.env):
Variable | Default | |
|
| the router's ubus endpoint; |
|
| |
| required | |
|
|
|
|
| seconds before an unconfirmed change is rolled back |
|
| wait after apply before the check (0 to 20) |
|
| or |
|
| HTTP only |
| required for HTTP | |
| extra Host names accepted over HTTP, e.g. |
stdio, started by your MCP client
With uv there is nothing to install first:
claude mcp add openwrt -e OPENWRT_PASSWORD=your-password -- uvx openwrt-ubus-mcpOr with pip:
pip install openwrt-ubus-mcp
claude mcp add openwrt -e OPENWRT_PASSWORD=your-password -- openwrt-ubus-mcpAdd -e OPENWRT_URL=https://192.168.1.1/ubus if your router isn't at the default address.
Other clients use the same command and environment in their own config format.
HTTP, as a service (Docker)
Run it on one machine and point several clients at it, protected by a bearer token:
docker run -d --name openwrt-ubus-mcp --network host --restart unless-stopped \
-e OPENWRT_PASSWORD=your-password -e MCP_BEARER_TOKEN=your-long-random-token \
-e MCP_HTTP_BIND=192.168.1.10 -e MCP_HTTP_ALLOWED_HOSTS=example-host \
ghcr.io/kk4hfj/openwrt-ubus-mcp
claude mcp add --transport http openwrt http://example-host:8765/mcp \
--header "Authorization: Bearer your-long-random-token"compose.yaml does the same from a .env file, with a read-only filesystem and
no Linux capabilities. Bind to a private address (a VPN interface is ideal), never to 0.0.0.0
on an untrusted network. Make a token with openssl rand -hex 32.
How it compares
OpenWrt MCP servers broadly come in three kinds:
SSH-based servers log in from your machine and run commands. They can do anything the login can, and their limits live in the server's own code.
On-router servers install their own daemon on the router, with its own policy engine and audit log, and usually reach the client over an SSH tunnel. They can cover far more of the router (packages, upgrades, any ubus call) than this one does.
API-based servers use a REST API that has to be installed on the router first.
This one sits in a narrow spot: nothing to install on the router (one JSON file and one login), no SSH at all, and limits that rpcd enforces, the same mechanism that already guards LuCI. The price is scope: it only does what the ACL and its few typed tools allow. If you want an agent that can explore and change anything on the router, one of the others will suit you better.
Limits
No interfaces, WAN, wireless writes, VLANs or bridges. A wrong change there can cut off the machine the server runs on, and recovery would rest entirely on the rollback timer. Wireless status is read-only.
No reboot, packages, upgrades or shell. The ACL doesn't allow them.
IPv4 for leases and port forwards. DHCPv6 leases are shown but not managed.
One router per server. Run one instance per router.
Rollback restores the router's config, not what happened meanwhile. It can't undo what a client did during the 30 s window.
Tested versions
OpenWrt | Result |
25.12.6 | Tested live on a real router: |
24.10.8 | Tested in a KVM virtual machine (the official armsr-armv8 image, no Wi-Fi): |
Reports for other versions are welcome as issues.
Roadmap
openwrt-ubus-mcp is meant to become the control layer of a small fleet console: many routers, staged rollouts that stop at the first failure, health monitoring, and token enrollment. That console is planned, not built. See the executive summary and the whitepaper.
Development
python -m venv .venv && .venv/bin/pip install -e '.[test]'
.venv/bin/pytest # fake ubus and BusyBox ash, no router needed
OPENWRT_LIVE=1 python scripts/live_check.py # read tools against a real router
OPENWRT_LIVE=1 python scripts/rollback_proof.py # the rollback proof (adds a disabled rule)The fake ubus models rpcd's sessions, ACL refusals, per-session staging, and apply with a
rollback timer, including rpcd putting rolled-back changes back into the applying session. It
runs on a test clock. Each safety rule was mutation-checked: break it and a test fails. The
router scripts are tested under BusyBox ash with a stand-in uci.
License
MIT. See LICENSE.
Available Tools
15 toolsdhcp_leasesARead-onlyIdempotent
Active DHCPv4 and DHCPv6 leases: hostname, IP, MAC and time left (as LuCI shows them).
Inputs: no named parameters. Returns: object
firewall_configARead-onlyIdempotent
Firewall UCI config grouped as defaults, zones, forwardings, rules and redirects (port forwards).
Inputs: no named parameters. Returns: object
firewall_rule_addADestructive
Add a traffic rule. src/dest: zone names or "*" (dest omitted = traffic to the router itself). target: ACCEPT, REJECT or DROP. proto: tcp, udp, "tcp udp", icmp or all. family: ipv4, ipv6 or any. Without confirm=true this only returns a preview of the UCI changes and changes nothing. With confirm=true it applies them with the router's rollback timer, checks the router still answers, and confirms; if the check fails, the router restores the old config by itself.
Inputs: src (required), name (required), dest, proto, +7 more. Returns: object
firewall_rule_removeADestructive
Remove a firewall rule, by section id or name. Only ones this server created unless force=true. Without confirm=true this only returns a preview of the UCI changes and changes nothing. With confirm=true it applies them with the router's rollback timer, checks the router still answers, and confirms; if the check fails, the router restores the old config by itself.
Inputs: name, force, confirm, section. Returns: object
interfacesCRead-onlyIdempotent
Logical network interfaces (lan, wan ...): up/down, protocol, device, addresses, gateway, DNS.
Inputs: no named parameters. Returns: object
pending_changesARead-onlyIdempotent
UCI changes this server has staged but not applied (normally none: every tool cleans up).
Inputs: no named parameters. Returns: object
port_forward_addADestructive
Forward a port (or range like 8000-8010) from the src zone (default wan) to a LAN host. proto: tcp, udp or "tcp udp". dest_port defaults to src_dport. Without confirm=true this only returns a preview of the UCI changes and changes nothing. With confirm=true it applies them with the router's rollback timer, checks the router still answers, and confirms; if the check fails, the router restores the old config by itself.
Inputs: name (required), dest_ip (required), src_dport (required), src, +5 more. Returns: object
port_forward_removeADestructive
Remove a port forward, by section id or name. Only ones this server created unless force=true. Without confirm=true this only returns a preview of the UCI changes and changes nothing. With confirm=true it applies them with the router's rollback timer, checks the router still answers, and confirms; if the check fails, the router restores the old config by itself.
Inputs: name, force, confirm, section. Returns: object
router_infoBRead-onlyIdempotent
Router model, firmware release, kernel, uptime, load and memory (ubus system board/info).
Inputs: no named parameters. Returns: object
static_lease_addADestructive
Reserve an IPv4 address for a device (a DHCP static lease). mac: aa:bb:cc:dd:ee:ff; ip: a free address in the LAN; name: a hostname (letters, digits, hyphens). Without confirm=true this only returns a preview of the UCI changes and changes nothing. With confirm=true it applies them with the router's rollback timer, checks the router still answers, and confirms; if the check fails, the router restores the old config by itself.
Inputs: ip (required), mac (required), name (required), confirm. Returns: object
static_lease_removeADestructive
Remove a static lease, by section id (see uci_show dhcp) or by MAC. Only leases this server created are removed unless force=true. Without confirm=true this only returns a preview of the UCI changes and changes nothing. With confirm=true it applies them with the router's rollback timer, checks the router still answers, and confirms; if the check fails, the router restores the old config by itself.
Inputs: mac, force, confirm, section. Returns: object
system_logARead-onlyIdempotent
The last lines lines of the system log (1-1000, default 100). With contains, only the
lines containing that text (case-insensitive), searched in the last 1000.
Inputs: lines, contains. Returns: object
uci_showARead-onlyIdempotent
One UCI config as a list of sections. config: network, dhcp, firewall, system or wireless. Secret options (key, password, psk ...) are shown as ***.
Inputs: config (required). Returns: object
wifi_clientsARead-onlyIdempotent
Associated Wi-Fi stations on every radio, with signal, rates, and hostname/IP from DHCP.
Inputs: no named parameters. Returns: object
wifi_statusCRead-onlyIdempotent
Each Wi-Fi interface: SSID, mode, channel, frequency, TX power, signal/noise, encryption type.
Inputs: no named parameters. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Most tools have clearly distinct targets: DHCP leases, Wi-Fi status, Wi-Fi clients, interfaces, firewall config, and router info are separable. The main overlap is that uci_show exposes raw configs that partially duplicate firewall_config, interfaces, and DHCP lease views, but its generic raw-UCI purpose is still clear.
All names use snake_case, but there are mixed conventions: read tools are noun phrases such as wifi_status and router_info, while mutating tools use entity_action order such as static_lease_add and port_forward_remove. The pattern is readable and semantically grouped, but it is not a single predictable verb_noun convention.
Fifteen tools is well-scoped for a router-management MCP server, with a balanced set of read-only inspection tools and paired add/remove operations. Each tool appears to earn its place without excessive surface area.
The set covers the core lifecycle well: inspect router/network/Wi-Fi/firewall state, add and remove static leases, port forwards, and firewall rules, with preview/confirm safety. Minor gaps remain, such as updating existing rules or leases in place and broader Wi-Fi or DHCP server configuration changes.
Maintenance
Related MCP Connectors
Remote streamable-HTTP MCP server running on a single Cloudflare Worker. Your assistant gets live Airbnb, Amazon, Booking.com, Google Flights, Maps and Reddit data, social search on X, Instagram and TikTok, the Meta Ad Library, and image/video generation without any keys. Connect your own accounts to let it send WhatsApp or Telegram messages, work an IMAP inbox, manage Meta Ads campaigns and publish to X and LinkedIn. OAuth 2.1 with PKCE; stored credentials are AES-256-GCM encrypted.
Router default logins, compliance index, MAC/OUI lookup. Reads free; submit_correction is Pro.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
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
- FlicenseAqualityDmaintenanceEnables management and control of OpenWrt devices via a simple API, including reboot, status checks, log reading, and LED control.51-
- 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
- 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-


