openwrt-luci-mcp
This server provides a read-only MCP interface to an OpenWrt/LuCI router over its native /ubus/ JSON-RPC API, exposing status and diagnostic data without SSH, without installing router-side agents, and without any configuration-changing tools.
Read router system info: board, firmware, kernel, uptime, load, memory, LuCI version, local time, and time services.
Inspect network state: logical interfaces, interface details, network devices, port status, VLAN/Switch config, active routes, neighbors, and policy rules.
Query DHCP and DNS: current DHCPv4/v6 leases, hostname/IP/MAC hints, dnsmasq/odhcpd settings, and DNS records.
Inspect Wi-Fi: configured radios/networks, radio status, associated clients, and on-demand scanning of nearby Wi-Fi.
Read firewall and nftables state: firewall zones, rules, forwardings, redirects, and filtered/paginated active nftables rules.
View system activity: procd services, bounded process lists, real-time interface/wireless/conntrack/load samples, conntrack connections, and bounded system/kernel logs.
Examine storage and packages: mounted filesystems with byte counts, installed/world package search, and LuCI installed/available package catalog browsing.
Run passive and active diagnostics: WAN/DNS/route consistency checks without probes, plus fixed non-configuring ping, traceroute, and DNS lookups with validated targets and immutable limits.
Perform security audit: checks for unsafe WAN input, management port forwards, HTTP-only LuCI, and SSH password authentication.
Produce a merged client inventory combining DHCP leases, host hints, and Wi-Fi associations.
List LuCI page coverage and allowed ubus method signatures via router_luci_pages and router_capabilities.
All tools return both JSON text and structuredContent; larger results support offset/limit pagination, and sensitive secrets (passwords, PSKs, tokens, keys) are hidden before returning data.
Provides read-only access to OpenWrt router status through the LuCI ubus JSON-RPC interface, including system info, network interfaces, routes, Wi-Fi clients and scans, DHCP leases, firewall status, logs, storage, packages, and security auditing.
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-luci-mcp Show me the current Wi-Fi clients and their signal strengths"
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 LuCI HTTP MCP
标准 OpenWrt LuCI Web 界面的只读 MCP 表达,通过 LuCI 原生 POST /ubus/ JSON-RPC 接口读取状态和运行其诊断页中的固定命令,不使用 SSH,也不在路由器上安装代理。
当前版本:0.4.0。以 OpenWrt 25.12.3 / LuCI openwrt-25.12 为 ground truth;可选方法不存在时返回明确的 supported: false,不会把权限或认证错误误报为不支持。
安全范围
使用现有 LuCI
root登录,不创建新账户。密码只从环境变量读取,不写入源码或日志。
不注册任意 ubus 调用、任意 shell、重启、固件升级或 UCI 写入工具。
ip、nft、dmesg、软件目录和网络诊断只执行代码中写死的程序与参数结构;不经过 shell。网络诊断只允许经过校验的目标,Ping 次数、Traceroute 超时和跳数均不可由调用者改变。
返回给模型前隐藏密码、PSK、community、令牌、会话标识、私钥、HTTP Authorization 和 URL 内嵌认证材料。
单次 LuCI 响应限制为 2 MiB,单个 MCP 结果限制为 256 KiB;超限返回有效 JSON 错误而非截断内容。
这只是 Demo。root 密码通过普通 HTTP 发送时没有传输加密,只应在可信 LAN 中临时测试。长期使用应开启 LuCI HTTPS,并改为受限 rpcd 账户。
Related MCP server: openwrt-mcp
环境要求
Node.js 20 或更高版本
OpenWrt/LuCI 可通过局域网访问
uhttpd-mod-ubus与rpcd正常工作
安装
cd C:\absolute\path\to\openwrt-luci-mcp-demo
npm install不要复制 .env.example 后把真实密码提交到 Git。推荐直接在 MCP 客户端的进程环境中设置变量:
OPENWRT_URL=http://router.example.invalid
OPENWRT_USERNAME=root
OPENWRT_PASSWORD=<LuCI root 密码>
OPENWRT_ALLOW_INSECURE_HTTP=1OPENWRT_ALLOW_INSECURE_HTTP=1 是显式风险确认。若 LuCI 已启用 HTTPS,请使用 https://... 并删除该变量。
运行
npm startstdio 是 MCP 协议通道;程序日志只写入 stderr。通常由 MCP 客户端启动本程序,而不是手动交互。
参考 mcp-config.example.json 配置客户端,并把其中的 Node 与 src/index.mjs 路径改为绝对路径。
工具
router_capabilitiesrouter_luci_pagesrouter_system_inforouter_interfacesrouter_interface_detailsrouter_routing_configrouter_network_devicerouter_port_statusrouter_vlan_configrouter_dhcp_leasesrouter_dhcp_configrouter_dns_configrouter_known_hostsrouter_wifi_overviewrouter_wifi_detailsrouter_wifi_clientsrouter_servicesrouter_processesrouter_realtime_statsrouter_routesrouter_neighborsrouter_firewall_statusrouter_firewall_configrouter_nftables_rulesrouter_wifi_scanrouter_logsrouter_connectionsrouter_storagerouter_packagesrouter_package_catalogrouter_time_statusrouter_system_settingsrouter_network_diagnosticsrouter_network_consistencyrouter_run_diagnosticrouter_security_auditrouter_client_summary
每个工具同时返回兼容的文本 JSON 和 MCP structuredContent。路由、DHCP/DNS、Firewall、VLAN、大型规则和软件目录使用 offset、limit 分页。
v0.4.0 增加 LuCI 网络配置控制面的只读表达:静态路由与策略规则、dnsmasq/odhcpd、DNS 记录、Firewall 关系、DSA/swconfig VLAN、基础 System 设置,以及配置与运行态一致性检查。工具只读取已提交配置;不会读取其他 LuCI 会话中尚未应用的 UCI 暂存变更。
router_network_diagnostics 只分析现有状态。router_run_diagnostic 对应 LuCI Network → Diagnostics 页面,会产生 Ping、Traceroute 或 DNS 流量,但不修改配置。router_package_catalog 只调用 LuCI package manager 的 list-installed 和 list-available,不更新软件源。
LuCI 页面覆盖
LuCI 页面 | MCP 工具 | 状态 |
Status → Overview |
| supported |
Status → Realtime Graphs |
| supported |
Status → Routes |
| supported |
Status → System Log |
| supported |
Status → Processes |
| supported |
Status → Firewall |
| supported |
Network → Interfaces |
| supported |
Network → Switch/VLAN |
| supported/conditional |
Network → Wireless |
| supported |
Network → Routing |
| supported |
Network → DHCP |
| supported |
Network → DNS |
| supported |
Network → Diagnostics |
| supported |
Network → Firewall Configuration |
| supported |
System → System |
| supported |
System → Software |
| supported |
System → Mount Points |
| supported |
同一矩阵可由 router_luci_pages 读取。Switch/VLAN 仅在 DSA bridge-vlan 或旧 swconfig 配置存在时支持。WireGuard、SQM、UPnP 等可选 LuCI 应用不在 v0.4.0 范围内。
没有提供以下能力:
uci.set / uci.delete / uci.apply
任意 file.exec / file.write / file.remove
system.reboot
luci.setPassword
hostapd.*.del_client测试
27 项测试使用本机模拟 /ubus/ 服务,不连接或修改真实路由器:
npm test一次性真实连接检查
在 PowerShell 中使用安全密码提示,不把密码写入文件:
$secure = Read-Host 'LuCI root password' -AsSecureString
$ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
try {
$env:OPENWRT_PASSWORD = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($ptr)
$env:OPENWRT_URL = 'http://router.example.invalid'
$env:OPENWRT_USERNAME = 'root'
$env:OPENWRT_ALLOW_INSECURE_HTTP = '1'
npm run check:live
}
finally {
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr)
Remove-Item Env:OPENWRT_PASSWORD -ErrorAction SilentlyContinue
}该检查只调用 system.board、system.info 和 luci.getVersion。
目标路由器核验范围
通过已登录 LuCI 页面确认以下模块在目标路由器上存在且可正常读取,没有出现 RPC access denied:
活动 IPv4/IPv6 路由、策略规则和邻居表
nftables
fw4运行时状态系统日志
Wi-Fi 信道分析
软件包管理器
网络诊断
静态路由、DHCP/DNS 与 Firewall 配置
DSA/bridge-vlan 与基础 System 设置
实现方法与 OpenWrt 25.12 使用的 LuCI/rpcd 接口保持一致;若将来更换固件或裁剪 LuCI 软件包,可调用 router_capabilities 和 router_luci_pages 核对实际支持情况。
Available Tools
30 toolsrouter_capabilitiesARead-onlyIdempotent
List method signatures for the read-only ubus objects allowed by this MCP server.
Inputs: no named parameters.
router_client_summaryARead-onlyIdempotent
Merge DHCP leases, LuCI host hints, and Wi-Fi associations into one client inventory.
Inputs: no named parameters.
router_connectionsARead-onlyIdempotent
Get a bounded snapshot of active conntrack entries.
Inputs: limit.
router_dhcp_leasesARead-onlyIdempotent
Get current DHCPv4 and DHCPv6 leases.
Inputs: no named parameters.
router_firewall_statusARead-onlyIdempotent
Get a read-only summary of firewall defaults, zones, forwardings, redirects, and rules from UCI.
Inputs: no named parameters.
router_interface_detailsARead-onlyIdempotent
Get the read-only LuCI interface status view for one logical interface.
Inputs: interface (required).
router_interfacesARead-onlyIdempotent
Get the current status of all logical network interfaces.
Inputs: no named parameters.
router_known_hostsARead-onlyIdempotent
Get LuCI host hints that correlate hostnames, IP addresses, and MAC addresses.
Inputs: no named parameters.
router_logsARead-onlyIdempotent
Read a bounded tail of system or kernel logs. Kernel access uses only the fixed command /bin/dmesg -r.
Inputs: source (required), lines.
router_luci_pagesARead-onlyIdempotent
List the standard LuCI pages represented by this MCP server and their implementation status.
Inputs: no named parameters.
router_neighborsARead-onlyIdempotent
Get the current IPv4 ARP and IPv6 NDP neighbor tables using two fixed read-only ip commands.
Inputs: no named parameters.
router_network_deviceBRead-onlyIdempotent
Get status and counters for one network device such as eth0 or br-lan.
Inputs: name (required).
router_network_diagnosticsARead-onlyIdempotent
Perform passive diagnostics of WAN state, addressing, DNS, default routes, uptime, and Wi-Fi without sending probes.
Inputs: no named parameters.
router_nftables_rulesARead-onlyIdempotent
Get a filtered, paginated read-only view of the active nftables rules, sets, maps, and counters.
Inputs: chain, limit, table, family, +1 more.
router_package_catalogARead-onlyIdempotent
Browse the installed and available package catalog shown by LuCI without updating, installing, or removing packages.
Inputs: limit, query, scope, offset.
router_packagesARead-onlyIdempotent
Search the installed/world package list and return a bounded result.
Inputs: limit, query.
router_port_statusARead-onlyIdempotent
Get the LuCI overview port table with bridge/VLAN, link, counters, zones, and optional PoE state.
Inputs: no named parameters.
router_processesARead-onlyIdempotent
Get a bounded snapshot of running processes.
Inputs: limit.
router_realtime_statsBRead-onlyIdempotent
Get LuCI bandwidth, wireless, conntrack, or load samples.
Inputs: mode (required), device.
router_routesARead-onlyIdempotent
Get active IPv4/IPv6 routes and policy rules using fixed read-only ip commands.
Inputs: no named parameters.
router_run_diagnosticARead-onlyIdempotent
Run the fixed, non-configuring Ping, Traceroute, or DNS command used by the LuCI diagnostics page.
Inputs: target (required), operation (required), family.
router_security_auditARead-onlyIdempotent
Run a read-only audit for unsafe WAN input, management port forwards, HTTP-only LuCI, and SSH password authentication.
Inputs: no named parameters.
router_servicesARead-onlyIdempotent
Get procd service status. This tool cannot start, stop, or restart services.
Inputs: no named parameters.
router_storageARead-onlyIdempotent
Get mounted filesystems with total, available, and free byte counts.
Inputs: no named parameters.
router_system_infoARead-onlyIdempotent
Get board, firmware, kernel, load, memory, uptime, and LuCI version information.
Inputs: no named parameters.
router_time_statusARead-onlyIdempotent
Get router local time, uptime, timezone-related system configuration, and time service status.
Inputs: no named parameters.
router_wifi_clientsARead-onlyIdempotent
List clients associated with one wireless interface, for example phy1-ap0.
Inputs: device (required).
router_wifi_detailsARead-onlyIdempotent
Get the LuCI wireless status view including radio details, frequencies, and associated clients.
Inputs: device.
router_wifi_overviewARead-onlyIdempotent
Get configured wireless radios and networks without returning UCI secrets.
Inputs: no named parameters.
router_wifi_scanARead-onlyIdempotent
Scan nearby Wi-Fi networks on one interface or every interface reported by iwinfo without changing wireless configuration.
Inputs: device.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 30 tools
Most tools target distinct network/system domains (routes, neighbors, firewall, WiFi, DHCP, packages), and descriptions are precise. The only mild confusions are `router_wifi_details` vs `router_wifi_clients` and `router_network_diagnostics` vs `router_run_diagnostic`, but the descriptions make the differences clear.
All tools share a consistent `router_` prefix and use snake_case noun phrases organized by domain. The convention is uniform; `router_run_diagnostic` introduces a verb but still follows the same overall pattern.
With 30 tools, the set exceeds the practical limit for easy agent selection and includes many low-level status endpoints that could be consolidated into grouped retrieval tools. Although the domain is broad, 30 tools is too many for a cohesive MCP surface.
The tool surface covers all major read-only OpenWrt/LuCI domains: interfaces, routes, WiFi, firewall, logs, system stats, packages, clients, diagnostics, and security. No obvious dead ends or missing core read-only operations exist for a status/diagnostics MCP server.
Maintenance
Related MCP Connectors
Read-only Linux server and Docker monitoring for AI assistants: CPU, memory, disk, network.
Router default logins, compliance index, MAC/OUI lookup. Reads free; submit_correction is Pro.
Read-only access to your MetaTrader 4 and 5 accounts for AI agents: balances, open positions, trade history with win rate, live quotes, symbol specs and candles. It cannot place, modify or close orders.
Read-only server insight: why a Linux server or K8s cluster is slow, failing or changed.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables management and control of OpenWrt devices via a simple API, including reboot, status checks, log reading, and LED control.51-
- AlicenseNot gradedqualityCmaintenanceProvides full administrative control of OpenWRT routers via SSH, with a preview-confirm safety model for mutating operations.6 npmMIT
- 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
- AlicenseNot gradedqualityDmaintenanceAllows you to interact with an OpenWrt router via SSH, enabling command execution, file operations, and system info retrieval.ISC