Skip to main content
Glama

huawei-cpe-mcp

A read-only Model Context Protocol server for Huawei HiLink 4G/5G CPE routers (H155-383 and the H168/H165 family).

  • Read-only. 10 tools: signal, carrier aggregation, neighbours, traffic, devices, operator, firmware — no configuration changes.

  • Zero runtime dependencies. Python 3.12+, standard library only.

  • SCRAM-SHA256 login. Works with firmware that rejects the old base64 HiLink clients (huawei-lte-api, most "Huawei MCP" projects).

  • Session-aware. The modem allows one admin session and rejects rapid re-logins; the server leases a session, yields to the web UI, and never retries a failed password.

Persian documentation: README.fa.md


Choose your path

You are…

Start at

New to modems / CPEs

Start here

A developer

Install

Building an AI agent

Tool contract and AGENTS.md


Related MCP server: UISP MCP Server

Start here (no experience needed)

You need the modem's address and its admin password.

1. Find the modem address. Huawei CPEs usually answer on http://192.168.8.1. Carrier-branded units sometimes use 192.168.0.1 or 192.168.1.1. That address is HUAWEI_CPE_HOST.

2. Pick how to store the password. Choose one:

# A) environment variable (simple, but visible to the process)
export HUAWEI_CPE_PASSWORD='your-admin-password'

# B) a 0600 file (recommended for daily use)
install -m 700 ~/.config/huawei-cpe-mcp
install -m 600 /dev/null ~/.config/huawei-cpe-mcp/password
printf '%s' 'your-admin-password' > ~/.config/huawei-cpe-mcp/password

# C) macOS Keychain
security add-generic-password -U -a admin -s huawei-cpe-mcp.admin -w

# D) Linux secret-tool
secret-tool store --label='huawei-cpe-mcp' service huawei-cpe-mcp.admin account admin

3. Self-test:

./bin/huawei-cpe-mcp --check

Expected: OK: authenticated read-only session, logged out plus the model and firmware version.

4. Add it to your AI client:

{
  "mcpServers": {
    "huawei": {
      "command": "/absolute/path/to/huawei-cpe-mcp/bin/huawei-cpe-mcp",
      "args": [],
      "env": { "HUAWEI_CPE_HOST": "192.168.8.1" }
    }
  }
}

Then ask:

  • "What is my signal quality and which bands are aggregated?"

  • "How much traffic did I use today and this month?"

  • "Which operator am I on, and is the SIM roaming?"

  • "How many devices are connected to the modem?"

None of these change anything.


Install (developers)

git clone https://github.com/mortezabahmani/huawei-cpe-mcp.git
cd huawei-cpe-mcp
python3 -m unittest discover -s tests     # 29 offline tests
./bin/huawei-cpe-mcp --check --simulate   # no modem needed
./bin/huawei-cpe-mcp                      # stdio MCP server

Optional installed entry point:

python3 -m venv .venv && . .venv/bin/activate
pip install -e .
huawei-cpe-mcp --check

Configuration

Variable

Default

Meaning

HUAWEI_CPE_HOST

192.168.8.1

Modem address

HUAWEI_CPE_BASE_URL

http://$HOST

Override the full base URL

HUAWEI_CPE_TIMEOUT

10

HTTP timeout (s)

HUAWEI_CPE_PASSWORD

—

Password via environment

HUAWEI_CPE_PASSWORD_FILE

~/.config/huawei-cpe-mcp/password

0600 file

HUAWEI_CPE_KEYCHAIN_SERVICE

huawei-cpe-mcp.admin

Keychain/secret-tool service

HUAWEI_CPE_SESSION_TTL

120

Reuse a login for this many idle seconds

HUAWEI_CPE_MIN_INTERVAL

20

Minimum gap between two sessions

HUAWEI_CPE_STATE_DIR

OS-specific

Session-gate timestamp only

HUAWEI_CPE_AUDIT

1

0 disables the JSONL audit log


Tools

Full schemas: docs/TOOLS.md.

Tool

Returns

telemetry

signal + status + traffic + operator in one snapshot

signal

band, PCI, EARFCN, RSRP/RSRQ/SINR, MCS, NR fields

carrier_aggregation

aggregated LTE/NR secondary cells

neighbor_cells

neighbouring LTE cells

network_mode

current mode + advertised bands

band_lock_status

LTE mask decoded to band numbers

traffic

session and monthly counters

devices

LAN clients (MACs masked)

plmn

registered operator and RAT

device_info

model, firmware, identity (masked)

What it will not do

  • Change bands, cells, APN, Wi-Fi, firewall or firmware.

  • Reboot or reconnect the modem.

  • Read or send SMS.

  • Return IMEI/IMSI/ICCID/serial/MAC values unless they are masked.

Band lock and cell lock are deliberately out of scope for 0.2. Cell lock is not supported by H155-383 firmware anyway (/api/ntwk/celllock returns 100002).


Modem behaviour you should know

Code

Meaning

Server behaviour

108001/108002/108006

wrong username/password

one attempt, then a 5-minute circuit breaker

108007

account locked

stop, human must unlock

108003/108005/108009

another admin session

yield; do not retry

125001/125002/125003

token/session invalid

refresh once, then fail

100002

endpoint unsupported

report, do not retry

The firmware also rejects a login that follows another session too closely with 108006. To avoid mistaking that for a wrong password, the client:

  1. reuses one session for HUAWEI_CPE_SESSION_TTL seconds;

  2. refuses a new login within HUAWEI_CPE_MIN_INTERVAL seconds;

  3. logs out at idle and at process exit.

If the modem's web UI is open, the server yields instead of kicking you out.


Compatibility

Device / firmware

Status

Huawei H155-383, 4.0.0.5

verified

Huawei H168-383 / H165-383 family

expected (same SCRAM flow)

Older HiLink (base64 login)

not supported by this client

huawei-lte-api based tools

do not work on this firmware

The SCRAM implementation was compared line by line with the device's own JavaScript (emui-crypto.js) and pinned with regression vectors.


Test without a modem

python3 -m unittest discover -s tests     # fake transport + pinned vectors
./bin/huawei-cpe-mcp --check --simulate   # full stdio, synthetic modem

The simulator (src/huawei_cpe_mcp/sim.py) performs a real SCRAM handshake against a fake transport. The local check script uses it; tests never touch a device.

Or run everything at once (lint is skipped if ruff is not installed):

./scripts/check.sh

Continuous 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

no modem password found

no secret configured

set env/file/keychain (see above)

authentication failed with code 108006

wrong password or two logins too close

confirm the password in the web UI, wait, retry once

another admin session is active

web UI open

close it or wait

not supported by this firmware (100002)

endpoint absent

expected for cell lock

server signature mismatch

unexpected device response

the session is aborted; check the network path

connection refused

wrong host/port

set HUAWEI_CPE_HOST


Security

  • Secrets come from env, a 0600 file, or the OS keychain — never from the repo.

  • The password is never placed in a command-line argument.

  • Output is masked (IMEI/IMSI/ICCID/serial/MAC) and capped at 12,000 characters.

  • Audit log: ~/Library/Logs/huawei-cpe-mcp/ on macOS, XDG state on Linux.

See SECURITY.md.

License

MIT — see LICENSE.

Available Tools

10 tools
band_lock_statusA

Read-only: current network mode and the LTE band lock mask decoded to band numbers.

Inputs: no named parameters.

carrier_aggregationA

Read-only: aggregated LTE/NR secondary cells (band, bandwidth, PCI, signal).

Inputs: no named parameters.

device_infoB

Read-only: model, firmware and identity (masked).

Inputs: no named parameters.

devicesA

Read-only: LAN clients known to the modem. MAC addresses masked.

Inputs: no named parameters.

neighbor_cellsB

Read-only: neighbouring LTE cells reported by the modem.

Inputs: no named parameters.

network_modeB

Read-only: network mode plus the bands the modem advertises as supported.

Inputs: no named parameters.

plmnB

Read-only: registered operator and radio access type.

Inputs: no named parameters.

signalB

Read-only: serving cell signal and radio parameters.

Inputs: no named parameters.

telemetryB

Read-only: one snapshot of signal, status, traffic and operator.

Inputs: no named parameters.

trafficB

Read-only: current session and monthly traffic counters.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 10 tools

    Disambiguation3/5

    Most tools target distinct data (traffic counters, neighbor cells, PLMN), but several overlap: telemetry bundles signal, status, traffic and operator, duplicating signal/traffic/plmn; band_lock_status and network_mode both report bands; device_info (the CPE itself) vs devices (LAN clients) invites confusion. Descriptions do help disambiguate, so an attentive agent can pick correctly, but boundaries are not crisp.

    Naming Consistency4/5

    All names follow a consistent noun/read-only-attribute style (signal, traffic, plmn, neighbor_cells), with no mixed verb conventions. Minor deviation: device_info uses an '_info' suffix while its sibling 'devices' does not, and band_lock_status mixes a state concept into a name that could imply an action.

    Tool Count4/5

    Ten read-only tools is a well-scoped count for a CPE monitoring surface, and each exposes a distinct telemetry facet. The only redundancy is the composite telemetry tool that re-bundles data available from other tools.

    Completeness3/5

    Read-only coverage of the modem's status domain is reasonably thorough (identity, signal, CA, neighbors, bands, traffic, clients, operator). However, the surface is entirely observational: there is no way to set band lock, change network mode, reboot, or configure anything, and band_lock_status implies a setter that does not exist.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables 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.).
      31
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to monitor Ubiquiti UISP network infrastructure through read-only REST API access to sites, devices, outages, logs, data links, gateways, background tasks, firmware, and speed tests.
      27
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to interact with Xiaomi/Redmi routers, providing read-only queries and management capabilities such as device listing, port forwarding, DHCP reservations, and reboot control.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to safely inspect fleets of MikroTik RouterOS devices and SNMP v2c endpoints through deny-by-default read-only tools, batch queries, and one-call diagnosis recipes for NOC work. Returns redacted, auditable results so routers can be observed without any risk of configuration changes.
      22 npm
      Apache 2.0