huawei-ont-mcp

huawei-ont-mcp

Reads LAN devices and WAN status from a Huawei GPON ONT fiber modem.

Category
访问服务器

README

huawei-ont-mcp

An MCP server for reading status off a Huawei GPON ONT (fiber modem) — connected devices and WAN status — in plain language.

Inspired by Karya Boyraz's keenetic-mcp, but for a different device family. Reverse-engineered from a TTNET2-branded HG8245X6 (Türk Telekom fiber modem) web UI's own JavaScript, by capturing the real network requests a logged-in browser session makes (via Chrome DevTools MCP) and matching them against the router's own RndSecurityFormat.js/safelogin.js source.

Login (solved 2026-07-16)

Unlike Keenetic's documented, stateless RCI auth flow, this ONT's /login.cgi flow (token from /asp/GetRandCount.asp + base64(password)) looked simple on paper but rejected every faithful reimplementation for a while — headers matched byte-for-byte against a real successful browser request, still failed. The missing piece: the one-time token is bound to the specific TCP connection it was issued on. GetRandCount.asp and the login.cgi submission have to be sent on the exact same socket (http.client.HTTPConnection kept open across both calls) — separate requests.post() calls, even inside the same requests.Session(), open a new connection often enough that the router silently rejects the login. Confirmed by capturing a real browser login with Chrome DevTools MCP (a genuine <form> navigation, not an XHR — that's also why it carries navigation-only headers like Upgrade-Insecure-Requests: 1 and a full Accept: text/html,... string) and then replicating it on one persistent connection: worked on the first try.

The web UI still enforces a 5-strikes lockout on failed logins — but per the device's own login.asp source (errloginlockNum/LockLeftTime, and the Turkish string "Fazla deneme, lütfen N sn bekleyin."), it's a temporary, seconds-scale cooldown on the admin panel only, not a device reset and not an internet outage. server.py's _login() deliberately does not retry in a loop, out of respect for that lockout — a failed login raises immediately.

No write tools yet — this is still read-only, just no longer login-blocked.

Tools

Tool Type What it does
list_devices() read LAN devices (DHCP + static): IP, MAC, hostname, ETH/WIFI, Online/Offline
wan_status() read Each WAN connection (INTERNET/VOICE/IPTV/MANAGEMENT/MOBILE BACKUP): connected?, public IPv4, PPPoE username

Install

Requires Python 3.9+.

cd Agents/mcp-servers/huawei-ont-mcp
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt

Setting the admin credential

The server logs in automatically on first use and re-logs-in automatically if the session expires — no manual browser login or cookie copying needed anymore. It just needs the admin password, stored as base64(password) (exactly the form the router's own login form sends, so the raw plaintext never has to pass through this script either):

security add-generic-password -a "admin" -s "huawei-ont-password-b64" -w "<base64 of your admin password>" -U

(never in a file, never in shell history where it lingers). On non-macOS, set HUAWEI_ONT_PASSWORD_B64 as a fallback env var instead.

Run

.venv/bin/python server.py

Starts a streamable-HTTP MCP server on http://0.0.0.0:8906/mcp (configurable via HUAWEI_ONT_HOST/HUAWEI_ONT_PORT).

Connecting an MCP client

Claude Code

{
  "mcpServers": {
    "huawei-ont": {
      "type": "http",
      "url": "http://127.0.0.1:8906/mcp"
    }
  }
}

Restart Claude Code after adding (MCP config isn't hot-reloaded). Ask: "list devices on my router" or "is my internet connected?".

How the login actually works

TTNET2 config mode uses the scheme in login.asp's Submit(), confirmed by capturing a real successful browser login:

  1. POST /asp/GetRandCount.asp (no body) → response text is a one-time token (strip a leading BOM byte).
  2. On the same TCP connection: POST /login.cgi with UserName=admin&PassWord=<base64(password)>&Language=turkish&x.X_HW_Token=<token>, header Cookie: Cookie=body:Language:turkish:id=-1 (only on this second request, not the token fetch).
  3. Success sets Set-Cookie: Cookie=sid=<hex>:Language:turkish:id=1.

Step 2's connection reuse is the part that isn't optional -- see _login() in server.py.

Security notes

  • The server has read access to router status. No write tools exist yet.
  • Only base64(admin password) lives in Keychain; the session cookie itself is cached in memory for the running process only, never written to disk.
  • Nothing is sent anywhere except your own router.
  • This is not affiliated with or endorsed by Huawei or Türk Telekom. Use at your own risk.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选