Skip to main content
Glama

keenetic-mcp

Python License: MIT MCP keenetic-mcp MCP server

An MCP server that lets an AI assistant (Claude, or any MCP client) manage your Keenetic router in plain language — list connected devices, pin static DHCP leases, rename devices, check WAN status, and reboot.

It talks to the router's built-in RCI JSON API over HTTP, so there's no cloud, no third-party service, and nothing leaves your network. You run it yourself against your own router.

Tested against a Keenetic Hopper DSL (KN-3610). The RCI API is shared across the Keenetic line (Giga, Viva, Hopper, Ultra, …), so other models should work too. If you confirm one, please open an issue/PR to grow the list.

Why

Keenetic's RCI API is powerful but poorly documented, and its auth is a fiddly two-step MD5-challenge + SHA256 dance that trips people up for hours. This wraps the common device/lease/WAN operations behind clean MCP tools so you can just say "pin the Raspberry Pi to a static IP" and it happens.

Related MCP server: keenetic-mcp

Tools

Tool

Type

What it does

list_devices()

read

Active DHCP lease table (ip / mac / name / remaining time)

list_static_leases()

read

Static reservations (ip dhcp host in running-config)

find_free_ip(start=100, end=149)

read

Suggest a free IP for a new static reservation

wan_status()

read

WAN/internet status, WAN IP, uptime, CPU/memory

list_port_forwards()

read

Port-forward / static NAT rules (ip static)

set_static_lease(mac, ip, name="")

write

Assign a fixed IP to a MAC (low-level — you supply the MAC)

pin_device(identifier, ip="")

write

⭐ Find a device by IP/MAC/name and pin its current (or a given) IP in one step. Conflict-guarded.

rename_device(identifier, name)

write

⭐ Set a device's persistent display name (the name shown in the web UI)

remove_static_lease(mac)

write

Remove a reservation

reboot(confirm=True)

write

Reboot the router (only with confirm=True; internet drops ~1-2 min)

Safety: write tools are off by default

Read tools always work. Write tools are disabled until you set KEENETIC_ENABLE_WRITES=1 in the server environment. This means a fresh install can look but not touch — no accidental reboots or lease changes while you explore. Even once enabled, write tools are guarded:

  • pin_device refuses if the target IP is already active on, or statically reserved to, a different device.

  • Address-like identifiers ("66") never fuzzy-match a device name (e.g. Room-66-Cam).

  • Every write reads the RCI response back and reports status:error instead of silently "succeeding".

  • reboot requires an explicit confirm=True.

Install

Requires Python 3.10+.

The easy way — no clone, no venv. With uv installed, run it straight from GitHub; your MCP client launches it on demand (see Connecting an MCP client). To install it as a command instead:

uv tool install "git+https://github.com/karyaboyraz/keenetic-mcp"
# or: pipx install "git+https://github.com/karyaboyraz/keenetic-mcp"

Then set your router password in the environment (KEENETIC_PASS) and run keenetic-router-mcp. By default it speaks stdio — the transport desktop MCP clients expect.

The installed command is keenetic-router-mcp. The GitHub repo is keenetic-mcp.

From source (for development or the systemd service):

git clone https://github.com/karyaboyraz/keenetic-mcp.git
cd keenetic-mcp
python3 -m venv .venv
.venv/bin/pip install .

cp .env.example .env
# edit .env: set KEENETIC_PASS (and KEENETIC_ENABLE_WRITES=1 if you want write tools)
.venv/bin/keenetic-router-mcp

Configuration

All configuration is via environment variables (see .env.example):

Variable

Default

Notes

KEENETIC_URL

http://192.168.1.1

Your router's web-admin address

KEENETIC_USER

admin

Admin username

KEENETIC_PASS

—

Required. Admin password

KEENETIC_ENABLE_WRITES

0

Set to 1 to enable write tools

KEENETIC_TRANSPORT

stdio

stdio (client-launched) · http / sse (network service)

KEENETIC_HOST

0.0.0.0

Bind address for http/sse (use 127.0.0.1 for local-only)

KEENETIC_PORT

8905

Bind port for http/sse

Connecting an MCP client

Most clients (Claude Desktop, Claude Code, Cursor, …) start the server themselves and talk over stdio. With uv installed, no prior install step is needed — uvx fetches from GitHub and runs it. Add to your client's MCP config (claude_desktop_config.json, ~/.mcp.json, etc.):

{
  "mcpServers": {
    "keenetic": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/karyaboyraz/keenetic-mcp", "keenetic-router-mcp"],
      "env": {
        "KEENETIC_URL": "http://192.168.1.1",
        "KEENETIC_PASS": "your-router-admin-password",
        "KEENETIC_ENABLE_WRITES": "0"
      }
    }
  }
}

If you installed it as a command (uv tool install / pipx), use "command": "keenetic-router-mcp" with no args. Restart the client (MCP config isn't hot-reloaded), then ask: "list my router's devices".

http — connect to a running network service

If you run it as a long-lived service (KEENETIC_TRANSPORT=http, see Running as a service), point the client at the URL instead:

{
  "mcpServers": {
    "keenetic": {
      "type": "http",
      "url": "http://127.0.0.1:8905/mcp"
    }
  }
}

Running as a service (Linux)

A keenetic-mcp.service systemd unit is included — it runs the server over HTTP (KEENETIC_TRANSPORT=http) so clients connect to it by URL. Put the repo at /opt/keenetic-mcp, create the venv there (python3 -m venv .venv && .venv/bin/pip install .), fill in .env, then:

sudo cp keenetic-mcp.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now keenetic-mcp

How the auth works

For anyone reusing the RCI API directly, this is the part that's hard to find. Keenetic uses a two-step challenge:

  1. GET /auth → returns 401 with X-NDM-Realm and X-NDM-Challenge headers.

  2. Compute md5 = MD5("<user>:<realm>:<pass>"), then sha = SHA256(challenge + md5).

  3. POST /auth with {"login": user, "password": sha} → sets a session cookie.

  4. POST /rci/ with a list[dict] command tree, using that cookie.

Write commands must be followed by [{"system":{"configuration":{"save":{}}}}] or they're lost on reboot. See server.py for the full, working implementation.

Security notes

  • The server has full admin control of your router. Bind it to 127.0.0.1 (or a trusted LAN only) — never expose port 8905 to the internet.

  • Your password lives only in .env (gitignored). Nothing is sent anywhere except your own router.

  • This is not affiliated with or endorsed by Keenetic. Use at your own risk.

License

MIT — see LICENSE.

Available Tools

10 tools
find_free_ipA
Read-onlyIdempotent

Suggest up to 5 unused IPs on the LAN for a new static reservation (read-only; changes nothing). Use before set_static_lease or pin_device(ip=...) to avoid conflicts. Excludes active leases, existing static reservations, the gateway and broadcast. start/end are last octets (e.g. 100 and 149 → 192.168.1.100-149); pick a range outside the router's dynamic DHCP pool. start > end is accepted and swapped.

Inputs: end, start. Returns: result

list_devicesA
Read-onlyIdempotent

List devices currently holding a DHCP lease: ip, mac, name, remaining lease time (live, read-only). Use this to find a device's IP/MAC before pin_device or rename_device. For fixed reservations (including offline devices) use list_static_leases instead.

Inputs: no named parameters. Returns: result

list_port_forwardsA
Read-onlyIdempotent

List port-forwarding / static NAT rules as raw 'ip static' lines from the running-config (read-only). Use to see which ports are exposed to the internet and to which LAN host. This server cannot add or remove port forwards; change them in the router's web UI.

Inputs: no named parameters. Returns: result

list_static_leasesA
Read-onlyIdempotent

List static DHCP reservations (MAC → fixed IP) from the router's running-config (read-only). Use this to check which IPs are already reserved before set_static_lease/pin_device, or to find the MAC to pass to remove_static_lease. Includes offline devices; for currently connected devices use list_devices.

Inputs: no named parameters. Returns: result

pin_deviceA
Idempotent

Turn a connected device's current IP into a static reservation in one step (no need to know the MAC), then save the config. Preferred way to give a device a fixed IP; use set_static_lease only for devices that are offline (not in list_devices). A name fragment must match exactly one device; an address-like identifier must be the full IP or MAC and never matches names ("66" won't hit "Room-66-Cam"). Passing ip moves the device there at its next lease renewal — get a candidate from find_free_ip. Refuses (changes nothing) if the target IP is active on or reserved to another device. Examples: pin_device("192.168.1.66") · pin_device("PS5", "192.168.1.154")

Inputs: identifier (required), ip. Returns: result

rebootA
Destructive

Reboot the router. All devices lose internet for ~1-2 minutes and this MCP server cannot reach the router until it is back. Use only as a last resort (e.g. WAN stuck down per wan_status); config and lease changes are already saved and never need a reboot. Call once with confirm=false to preview, then confirm=true to run.

Inputs: confirm. Returns: result

remove_static_leaseA
Destructive

Delete the static DHCP reservation for a MAC and save the router config. Irreversible (re-create it with set_static_lease). The device stays online but may get a different dynamic IP at its next lease renewal. Use list_static_leases to find the exact MAC first. To move a device to another IP, call set_static_lease/pin_device directly instead of removing first.

Inputs: mac (required). Returns: result

rename_deviceA
Idempotent

Give a device a persistent DISPLAY name on the router (Keenetic 'known host' entry = the device name in the web UI). identifier: the device's IP, MAC, or current name fragment (looked up in the active lease table). name: the new display name (spaces allowed; double quotes and non-printable characters are stripped). NOTE: set_static_lease / pin_device do NOT change the DISPLAY name — the display name is set ONLY by this tool. Examples: rename_device("192.168.1.66", "Pi5 Media") · rename_device("PS5", "PlayStation 5 Living Room")

Inputs: name (required), identifier (required). Returns: result

set_static_leaseA
Idempotent

Reserve a fixed IP for a MAC address (static DHCP lease) and save the router config. Use when you already know the MAC (e.g. a device that is offline); for a connected device prefer pin_device, which looks up the MAC for you and checks for IP conflicts. This tool does NOT check conflicts — call find_free_ip or list_static_leases first. Re-running with the same values is harmless. The optional name is only the dhcp-host label; to change the display name in the web UI use rename_device. Takes effect when the device next renews its lease (reconnect it to apply immediately).

Inputs: ip (required), mac (required), name. Returns: result

wan_statusA
Read-onlyIdempotent

Report internet (WAN) connectivity and router health: per-uplink connected/link state and WAN IP, plus router uptime, CPU load and memory. Read-only; queries the router live on every call (no caching). Use to diagnose "is the internet down?" or check the public IP; not for LAN devices (use list_devices).

Inputs: no named parameters. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.6/5.0

    Scored across 10 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes, and the descriptions cross-reference each other well. The main overlap is between pin_device and set_static_lease, but the descriptions clearly separate them by online/offline usage and conflict checking, so an agent should be able to choose correctly.

    Naming Consistency4/5

    Tool names mostly follow a consistent snake_case verb_noun pattern (list_devices, set_static_lease, remove_static_lease, rename_device). Minor deviations are reboot as a bare verb and wan_status as a noun phrase rather than a verb_noun name, but these do not create real confusion.

    Tool Count5/5

    Ten tools is well-scoped for a router-management server. Each tool covers a meaningful operation or read-only query, and the set is neither bloated nor too thin for the apparent domain.

    Completeness4/5

    The DHCP lease lifecycle is well covered: active leases, static leases, create via set_static_lease or pin_device, delete, rename, and free-IP lookup. The main gap is that port forwarding is read-only only, and the server explicitly cannot add or remove port-forward rules, which limits full network configuration coverage but does not break the core DHCP/status workflows.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      An MCP server that connects AI assistants to the ZONT heating system via the official REST API. It enables users to monitor device states, control heating modes, and perform diagnostics using natural language.
      38
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP agents to control Keenetic routers via plain language, providing network monitoring, device management, and safe configuration changes with backup and read-only options.
      20
      745 npm
      34
      MIT
    • A
      license
      C
      quality
      C
      maintenance
      MCP server that lets AI assistants monitor and manage TP-Link Omada controllers. It provides analytics and read-only queries plus write operations such as rebooting devices, blocking clients, and changing network or firewall settings.
      84
      MIT