Skip to main content
Glama
mcp-zyxel
by hugil

zyxel-mcp

An MCP server that lets AI clients safely read and configure Zyxel GS1900 series smart-managed switches.

The GS1900 has no REST API or SSH — only a JavaScript-heavy web GUI. This server reverse-engineers that GUI into 26 typed MCP tools, wrapped in guardrails that make it safe to point an LLM at production network hardware.

Verified against a GS1900-24E, firmware V2.40(AAHK.1).

Why it needs guardrails

An LLM reconfiguring a switch can trivially cut its own management path — one wrong PVID on the uplink port and the device is only reachable by physically plugging into it. This server therefore refuses, at the HTTP layer, any operation that could sever connectivity.

Hard lock-outs (no override):

  • management IP / DNS / gateway / management-VLAN changes

  • user accounts and authentication methods

  • disabling HTTP/HTTPS or TELNET/SSH management services

  • configuration restore, factory reset, firmware upload

  • deleting VLAN 1, or any VLAN that still has member ports

  • disabling a port whose link is currently up

  • any write to a port listed in ZYXEL_PROTECTED_PORTS (uplinks, AP trunks)

Additional safety:

  • Dry-run by default — every write tool takes dry_run (default true) and returns a current-vs-target diff without touching the switch

  • Auto-backup — running config is exported before any write

  • Audit log — append-only JSONL of every read and write

  • Save-on-write — successful writes are persisted running → startup

Related MCP server: Zyxel Switch MCP Server

Install

Requires Python 3.10+.

git clone git@github.com:hugil/zyxel-mcp.git
cd zyxel-mcp
cp .env.example .env      # then edit .env
uv run mcp-zyxel

Register with an MCP client over stdio, e.g. .vscode/mcp.json:

{
  "servers": {
    "zyxel": {
      "command": "uv",
      "args": ["--directory", "/path/to/zyxel-mcp", "run", "mcp-zyxel"],
      "env": {
        "ZYXEL_HOST": "192.168.1.1",
        "ZYXEL_USER": "admin",
        "ZYXEL_PASSWORD": "...",
        "ZYXEL_PROTECTED_PORTS": "1,4"
      }
    }
  }
}

Configuration

All configuration is environment-based; see .env.example.

Variable

Required

Purpose

ZYXEL_HOST

yes

Switch management IP

ZYXEL_USER

Username (default admin)

ZYXEL_PASSWORD

yes

Password, or use ZYXEL_PASSWORD_FILE

ZYXEL_SCHEME

http (default) or https

ZYXEL_PROTECTED_PORTS

Ports where writes are always refused

ZYXEL_AUDIT_LOG

Audit log path

ZYXEL_BACKUP_DIR

Pre-write backup directory

ZYXEL_SYNC_DIR

for sync

Where snapshots are written

ZYXEL_SYNC_REMOTE

for sync

Git remote receiving snapshots

ZYXEL_DHCP_LEASES

DHCP lease file for MAC → hostname

Snapshots, backups and audit logs are operator data, not part of this tool. ZYXEL_SYNC_DIR has no default so they never land in this source tree — point it somewhere outside the repository.

Tools (26)

Reads — get_system_info, get_port_status, get_port_counters, list_vlans, get_vlan_membership, get_mac_table, get_pvids, get_stp_config, get_lag_config, get_loopguard_config, get_lldp_config, get_port_security_config, get_syslog_config, get_mirror_config, get_running_config_text

Writes (dry-run default, auto-backup, auto-save) — set_port_vlan_membership, set_pvid, set_port_config, set_system_info, create_vlan, delete_vlan

Maintenance — backup_config, save_running_to_startup, reboot(ack='REBOOT')

Snapshot / sync — sync_snapshot, sync_to_github

Config snapshots

sync_snapshot writes a deterministic, rebuild-ready description of the switch to ZYXEL_SYNC_DIR; sync_to_github also commits and pushes it to ZYXEL_SYNC_REMOTE.

$ZYXEL_SYNC_DIR/
  README.md              generated topology: VLAN table, port map,
                         membership matrix, MAC/device inventory
  running-config.cfg     full CLI config, secrets redacted
  annotations.json       hand-edited MAC -> hostname/role/notes,
                         never overwritten by a snapshot
  system.json  vlans.json  ports.json  membership.json
  mac-table.json  inventory.json  lldp-neighbors.json
  running-config.raw.cfg unscrubbed, git-ignored — never committed

Snapshots are idempotent: volatile data (uptime, wall clock, CPU/memory load, MAC-table ordering) is stripped or sorted, so a commit appears only when the configuration genuinely changed.

Redacted before commit: admin password hashes, SNMP community strings, RADIUS/TACACS keys. Serial number and MAC range are kept for RMA purposes.

The generated README is designed so that if the switch dies, someone can buy the same model and rebuild the network from the committed files alone.

How it works

The GS1900 web GUI is driven entirely through /cgi-bin/dispatcher.cgi:

  1. Login — the password is obfuscated by the login page's JavaScript into a 320-character string (characters placed in reverse at every 7th index, length digits at fixed offsets 123 and 289, remainder random). This is reimplemented in encode_password().

  2. Session — poll login_chk=1 until OK, then scrape the XSSID token from the cmd=1 bootstrap page. It must be sent as both a cookie and a hidden form field on every write. Only one web session exists per user, so the client clears stale sessions before authenticating.

  3. Pages — every feature is an integer cmd id, e.g. 799 port status, 1283 VLAN list (ajax), 1290/1291/1292 PVID list/edit/apply, 1293/1294 VLAN membership view/apply, 2049 MAC table, 5899 save running→startup.

  4. Membership writes must echo every row's current selection plus the hidden vlanMode_N fields, or unsubmitted rows silently reset.

contrib/ holds small standalone scripts used while reverse-engineering the GUI; they are reference material, not part of the server.

Layout

src/mcp_zyxel/
  server.py        MCP tool + resource definitions
  zyxel_client.py  auth, session, XSSID handling, locked-cmd enforcement
  zyxel_ops.py     typed reads/writes per feature page
  safety.py        connectivity lock-outs, protected ports, audit, backups
  sync.py          snapshot, scrubbing, topology README, git push
contrib/           standalone probing scripts (reference)
probe.py           dump dispatcher pages and their form fields

Disclaimer

Not affiliated with Zyxel. Driving an undocumented web GUI is inherently fragile — verify behaviour against your own firmware version, and keep the dry-run defaults on until you trust it.

License

MIT

Available Tools

26 tools
backup_configB

Download a backup over HTTP into the backup dir. content: running|startup|backup|flash_log|buffer_log|tech_support.

Inputs: content. Returns: result

create_vlanB

Create a VLAN. dry_run=true (default) previews; auto-backup on apply.

Inputs: name (required), vlan_id (required), dry_run. Returns: result

delete_vlanA

Delete a VLAN. Refuses VLAN 1 and any VLAN with member ports. dry_run=true (default) previews.

Inputs: vlan_id (required), dry_run. Returns: result

get_lag_configC

Link Aggregation (LACP) global configuration.

Inputs: no named parameters. Returns: result

get_lldp_configC

LLDP configuration.

Inputs: no named parameters. Returns: result

get_loopguard_configC

Loop guard (RLDP) configuration.

Inputs: no named parameters. Returns: result

get_mac_tableB

Learned MAC addresses, optionally filtered by VLAN.

Inputs: vlan_id. Returns: result

get_mirror_configC

Port mirroring configuration.

Inputs: no named parameters. Returns: result

get_port_countersC

Per-port MIB counters (octets, packets, discards, errors).

Inputs: port (required). Returns: result

get_port_security_configC

Port Security configuration.

Inputs: no named parameters. Returns: result

get_port_statusA

Get per-port link status (up/down, speed, duplex).

Inputs: no named parameters. Returns: result

get_pvidsA

Get the PVID (port VLAN ID) for every port.

Inputs: no named parameters. Returns: result

get_running_config_textA

Fetch the running configuration as text (diffing/auditing).

Inputs: no named parameters. Returns: result

get_stp_configC

Spanning Tree global configuration.

Inputs: no named parameters. Returns: result

get_syslog_configC

Syslog configuration.

Inputs: no named parameters. Returns: result

get_system_infoA

Get switch system information (model, firmware, uptime, IP).

Inputs: no named parameters. Returns: result

get_vlan_membershipB

Get 802.1Q VLAN port membership for a VLAN (tagged/untagged/ forbidden/excluded per port).

Inputs: vlan_id. Returns: result

list_vlansB

List all VLANs configured on the switch.

Inputs: no named parameters. Returns: result

rebootA

Reboot the switch (drops management ~1 min, discards unsaved changes). Requires ack='REBOOT'. A config backup is taken first.

Inputs: ack. Returns: result

save_running_to_startupB

Copy the running configuration to the startup configuration.

Inputs: no named parameters. Returns: result

set_port_configA

Configure a port (speed: auto|10M|100M|1000M, duplex: auto|half|full). Refuses protected ports and disabling any port with link Up. dry_run=true (default) previews current vs target.

Inputs: port (required), speed, duplex, dry_run, +3 more. Returns: result

set_port_vlan_membershipA

Set port membership in a VLAN (mode: tagged|untagged|forbidden|excluded). Protected ports (uplink 1, AP trunk 4) are refused. Auto-backs up current state before applying; running config is saved to startup on success. dry_run=true (default) previews without applying.

Inputs: mode (required), ports (required), vlan_id (required), dry_run. Returns: result

set_pvidA

Set a port's PVID. Protected ports (1, 4) are refused. dry_run=true (default) previews without applying.

Inputs: port (required), pvid (required), dry_run. Returns: result

set_system_infoA

Set system name/location/contact. dry_run=true (default) previews.

Inputs: name, contact, dry_run, location. Returns: result

sync_snapshotA

Write a rebuild-ready snapshot of the switch into the directory given by ZYXEL_SYNC_DIR: scrubbed running config, JSON dumps of VLANs / ports / MACs / LLDP, a MAC-keyed inventory, and a generated topology README. Does NOT push to git.

Inputs: no named parameters. Returns: result

sync_to_githubB

Snapshot, then commit and push it to the operator's own repository. The target comes from remote or ZYXEL_SYNC_REMOTE; the snapshot directory comes from ZYXEL_SYNC_DIR. Neither has a built-in default.

Inputs: branch, remote, message. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 26 tools

    Disambiguation4/5

    Most tools target clearly distinct resources or actions (e.g., each get_*_config covers a different switch feature, and create/delete/list/set VLAN tools are well separated). Minor potential confusion between backup_config (running config as file) and get_running_config_text, or between sync_snapshot and sync_to_github, but descriptions clarify the difference.

    Naming Consistency4/5

    Names follow a consistent snake_case verb_noun pattern (get_*, set_*, create_*, delete_*, list_*), with readable abbreviations. Slight deviations like the bare 'reboot' and 'get_pvids' (plural noun rather than get_pvid) are minor and do not hinder predictability.

    Tool Count3/5

    26 tools is on the heavy side for a switch management server. Many read-only feature getters (get_lag_config, get_loopguard_config, get_lldp_config, etc.) could be consolidated into a parameterized config getter, though each does cover a distinct feature.

    Completeness3/5

    Core VLAN CRUD, port configuration, and backup/sync workflows are covered. However, many features (STP, LLDP, LAG, loop guard, syslog, mirror, port security) are read-only with no corresponding setters, which is a notable gap for a switch configuration server.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP-capable AI agents to observe, troubleshoot, and configure Aruba CX (AOS-CX) switches through REST and SSH, with safety controls, inventory management, and verification workflows.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to discover, configure, harden, and troubleshoot multi-brand home and homelab networks through MCP, backed by declarative Terraform/OpenTofu orchestration. Includes safety guardrails, drift detection, snapshots, rollback, and zero-trust device controls.
      MIT