tplinkctl
Autonomous agent-ready CLI and stdio FastMCP server for local TP-Link router management.
tplinkctl turns stateful, slow, and browser-dependent router admin interfaces into a high-speed, local-first API interface designed for humans, shell scripts, and autonomous AI coding agents (Hermes, Claude Code, Cursor, Codex, OpenClaw).
Key Highlights
- 🛡️ Autonomous Mutation Safety: Plan-before-execute via
--plan/--dry-run, mandatory--yesconfirmations on destructive actions, noise-filtered state snapshot diffing (state diff), and rollback contracts. - 🤖 Agent-First Discovery: Full CLI Spec v0.2 compliance via
tplinkctl schema, structured semantic exit codes, JSON error envelopes onstderr, and built-incapabilities,AGENTS.md, andllms.txt. - ⚡ Dual Transport (CLI + MCP): 50+ CLI subcommands paired with 30 stdio JSON-RPC MCP tools in
tplinkctl-mcpwith zero heavy SDK dependencies. - 🔒 Granular Policy Profiles: 4 security tiers (
read-only,device-admin,network-admin,dangerous) to safely constrain autonomous agents in long-running sessions. - 📡 Deep Hardware Coverage: 55+ reverse-engineered endpoints covering Wi-Fi 7 (OFDMA, TWT, DFS, Smart Connect), EasyMesh, WireGuard VPN, QoS bandwidth limits, NAT ALG/DMZ/UPnP, IPTV/VLAN, USB storage sharing, and power eco schedules.
Quick Start
1. Install
# From source (or via uv / pip)
git clone https://github.com/JithendraNara/tplinkctl.git
cd tplinkctl
python3 -m venv .venv
.venv/bin/pip install -e .
2. Configure
Set non-secret router defaults and export your password in the environment:
tplinkctl config set --host http://192.168.0.1 --username admin --client sg
export TPLINK_PASSWORD="your-local-router-password"
3. Inspect
# Verify connection & readiness
tplinkctl doctor
tplinkctl --json status
# Introspect machine-readable CLI contract
tplinkctl schema
Command Surface & Tool Matrix
| Category | CLI Command | MCP Tool | Description | Mutating |
|---|---|---|---|---|
| System & Health | status |
router_status |
Summary of router, WAN, Wi-Fi, speed, and clients | No |
health |
— | Health analysis, memory/CPU load, WAN state | No | |
doctor [--deep] |
doctor_deep |
Reachability probe & full authenticated API health | No | |
firmware |
— | Active firmware version & hardware model | No | |
firmware-check |
firmware_audit |
Audit update availability without installing | No | |
power |
power_status |
Eco mode status, power profile, and power-saving schedule | No | |
time |
time_status |
System time, timezone, and NTP configuration | No | |
led status |
led_status |
LED indicator state and nightly schedule | No | |
led on|off|schedule |
led_plan / led_set |
Toggle LEDs or configure nightly schedule | ⚠️ Yes | |
reboot |
— | Reboot the router (--yes required) |
⚠️ Yes | |
| Devices & Access | devices [--active] |
device_list |
Connected devices, IP/MAC, link rate, and usage | No |
device <query> |
device_show |
Search device by hostname, IP, or MAC | No | |
device reserve |
device_plan |
Create permanent DHCP reservation | ⚠️ Yes | |
device release |
device_plan |
Remove DHCP reservation | ⚠️ Yes | |
device block |
device_block |
Add device to Access Control blacklist (--enforce) |
⚠️ Yes | |
device unblock |
device_unblock |
Remove device from Access Control blacklist | ⚠️ Yes | |
device access |
— | Access Control mode (blacklist / whitelist) | ⚠️ Yes | |
speed |
— | Router-reported throughput per device | No | |
| Wi-Fi & Wireless | wifi-info |
— | SSIDs, bands, channel state, redacted keys | No |
wifi-status |
— | Radio enablement for 2.4G / 5G / 6G / Guest / IoT | No | |
wifi-advanced |
wifi_advanced |
OFDMA, TWT, DFS channel availability, schedule | No | |
wifi-config |
wifi_config_plan / wifi_config |
Configure radio channel, width, txpower, SSID | ⚠️ Yes | |
wifi <net> on|off |
— | Toggle Wi-Fi band or guest network | ⚠️ Yes | |
| Network & NAT | wan |
— | WAN IP, gateway, DNS, uptime, connection type | No |
ipv4 |
— | WAN and LAN IPv4 network status | No | |
ipv6 |
ipv6_status |
Dual-stack WAN/LAN IPv6 configurations | No | |
leases |
— | Active DHCP leases | No | |
reservations |
— | Current DHCP address reservations | No | |
port-forward |
port_forward_list |
NAT virtual servers / port forwarding rules | No | |
nat |
nat_status |
NAT ALG passthrough, DMZ, and UPnP status | No | |
ports |
port_speed |
Physical Ethernet link speed & capabilities | No | |
qos |
qos_status |
Quality of Service bandwidth limits and priorities | No | |
ddns |
ddns_status |
Dynamic DNS provider configuration & status | No | |
iptv |
iptv_status |
IPTV/VLAN, IGMP snooping, and port mapping | No | |
storage |
storage_status |
USB disks, Samba/FTP sharing, Time Machine | No | |
| Mesh & VPN | mesh |
mesh_devices |
EasyMesh network topology and node roles | No |
wireguard |
wireguard_status |
WireGuard server configuration & status | No | |
vpn-status |
— | OpenVPN / PPTP VPN server status | No | |
vpn-client-status |
— | VPN client routing status | No | |
| Agent & Ops | schema |
— | Machine-readable clispec v0.2 contract | No |
capabilities |
— | Agent capability manifest with risks & quirks | No | |
tools |
— | JSON tool schemas for CLI wrappers | No | |
events |
audit_tail |
Append-only local audit log for agent actions | No | |
state save|diff |
state_snapshot / state_diff |
Redacted router state snapshots and noise-filtered diffs | No | |
watch |
watch |
Repeated read-only monitoring samples | No | |
demo |
— | Safe agent workflow demo report | No |
Agent Safety & Policy Profiles
tplinkctl provides four security profile envelopes to restrict agent execution permissions:
| Profile | Allowed Commands | Allowed Operations | Denied Operations |
|---|---|---|---|
read-only |
All read commands | Discovery & inspection | All mutations (device.*, wifi.*, reboot) |
device-admin (Default) |
Read + device |
Inventory, DHCP reservations, Blacklist block/unblock | Router-wide toggles (wifi.*, vpn.*, reboot, raw) |
network-admin |
Read + device, wifi, vpn, reboot |
Everything except raw escape hatches | advanced.raw |
dangerous |
All (*) |
All (*) |
None (unrestricted) |
Set policy profiles via CLI flag or environment variable:
# Per-command profile
tplinkctl --json --profile read-only status
tplinkctl --json --profile device-admin device block Pixel --dry-run
# Session-wide profile
export TPLINK_PROFILE=device-admin
The Plan → Execute → Verify → Audit Loop
Autonomous agents should follow this standard mutation lifecycle:
# 1. Plan the change (dry-run preview with rollback instructions)
tplinkctl --json --reason "pause guest device" --no-input device block Pixel --plan --enforce
# 2. Execute with explicit confirmation
tplinkctl --json --reason "pause guest device" --no-input device block Pixel --yes --enforce
# 3. Verify state diff (rate/timestamp noise is filtered automatically)
tplinkctl --json --no-input state save --name after-block
tplinkctl --json state diff --before before-block --after after-block
# 4. Review audit trail
tplinkctl --json events --tail 5
FastMCP Server Integration
tplinkctl-mcp exposes 30 router tools over standard JSON-RPC stdio. Mutating MCP tools require confirm=true in tool arguments.
Add tplinkctl-mcp to your agent configuration:
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"tplink": {
"command": "tplinkctl-mcp",
"env": {
"TPLINK_HOST": "http://192.168.0.1",
"TPLINK_USERNAME": "admin",
"TPLINK_PASSWORD": "your-router-password",
"TPLINK_CLIENT": "sg",
"TPLINK_MCP_PROFILE": "device-admin"
}
}
}
}
Hermes Agent / Cursor / OpenClaw
mcp_servers:
tplink:
command: "tplinkctl-mcp"
env:
TPLINK_HOST: "http://192.168.0.1"
TPLINK_PASSWORD: "${TPLINK_PASSWORD}"
TPLINK_MCP_PROFILE: "device-admin"
The CLI Spec (clispec v0.2) & Exit Codes
tplinkctl fully implements The CLI Spec v0.2:
Introspection
Agents can discover all commands, arguments, types, defaults, and mutation contracts offline without executing network calls:
# Entire command tree
tplinkctl schema
# Subtree narrowing (token-efficient)
tplinkctl schema device
tplinkctl schema wifi-config
Semantic Exit Codes
Failures write a single-line JSON error envelope as the last line of stderr:
{"error": {"kind": "confirmation_required", "message": "Refusing to block without --yes.", "hint": "Re-run with --plan or --dry-run first, then add --yes."}}
| Exit Code | Error Kind | Description |
|---|---|---|
0 |
success |
Successful execution |
1 |
router / conflict / internal |
Router returned an error or unreadable payload |
2 |
usage |
Invalid arguments or unknown profile |
3 |
not_found |
Target device, MAC, or state snapshot not found |
4 |
permission |
Action blocked by policy profile or allowlist/denylist |
5 |
confirmation_required |
Mutating action invoked without --yes |
6 |
auth |
Password missing or authentication failed |
Router & Hardware Compatibility
tplinkctl is built on tplinkrouterc6u (>=5.30.0) and includes an active payload normalizer for TP-Link's SG authentication protocol.
| Router Model | Firmware Tested | SG Protocol | Notes |
|---|---|---|---|
| Archer BE3500 v1.0 | 1.3.3 Build 20260618 / 1.1.3 Build 20251120 |
✓ | Primary target; full 55+ endpoint coverage |
| Archer BE220 / BE230 / BE3600 | SG-generation firmwares | ✓ | Compatible via --client sg |
| Archer AX72 / AX12 / C6U | Modern RSA-OAEP / SG firmwares | ✓ | Compatible |
Development & Verification
# Run unit test suite (86 tests)
make test
# Run offline smoke suite
make smoke
# Run agent workflow demo
make demo
# Deep health verification against live router
tplinkctl --json --no-input doctor --deep
Documentation Links
AGENTS.md— Operational instructions, discovery guidelines, and playbooks for AI agents.llms.txt— LLM-optimized summary and context index.docs/ENDPOINTS.md— Complete reverse-engineered endpoint and payload reference.docs/INSTALL_AGENT.md— Detailed agent integration and MCP configuration guide.examples/agent-runbook.md— End-to-end agent operational runbook.CHANGELOG.md— Version history and release notes.
License
GNU GPLv3 or later © Jithendra Nara
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tplink_admin_cli-0.5.1.tar.gz.
File metadata
- Download URL: tplink_admin_cli-0.5.1.tar.gz
- Upload date:
- Size: 74.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6da4b44a418a80567f0714963d175a63e40b207970eb91ffcf21fa6a21e7eea2
|
|
| MD5 |
25700ef156a591b4ceb25441f2157fb1
|
|
| BLAKE2b-256 |
a0b0d7b1d6d63cdeca2f086ad4f05dcaf0c2dfa88d2498a5a08516ba48fdc69d
|
Provenance
The following attestation bundles were made for tplink_admin_cli-0.5.1.tar.gz:
Publisher:
publish.yml on JithendraNara/tplinkctl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tplink_admin_cli-0.5.1.tar.gz -
Subject digest:
6da4b44a418a80567f0714963d175a63e40b207970eb91ffcf21fa6a21e7eea2 - Sigstore transparency entry: 2467503330
- Sigstore integration time:
-
Permalink:
JithendraNara/tplinkctl@9504067cc9fa8263a42205c0334ee4525a1ee93f -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/JithendraNara
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9504067cc9fa8263a42205c0334ee4525a1ee93f -
Trigger Event:
release
-
Statement type:
File details
Details for the file tplink_admin_cli-0.5.1-py3-none-any.whl.
File metadata
- Download URL: tplink_admin_cli-0.5.1-py3-none-any.whl
- Upload date:
- Size: 59.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d102153841d1fdf0270157d9e9e611b5f1558eecec608e21f2ea4a0e9ff3c29b
|
|
| MD5 |
6b76227fc6b5470efa08dde9058325d2
|
|
| BLAKE2b-256 |
c1f7006f1f0fe02b43f49f2c76e5c2392fef07eb373284bf2a4c39bbc279c33a
|
Provenance
The following attestation bundles were made for tplink_admin_cli-0.5.1-py3-none-any.whl:
Publisher:
publish.yml on JithendraNara/tplinkctl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tplink_admin_cli-0.5.1-py3-none-any.whl -
Subject digest:
d102153841d1fdf0270157d9e9e611b5f1558eecec608e21f2ea4a0e9ff3c29b - Sigstore transparency entry: 2467503346
- Sigstore integration time:
-
Permalink:
JithendraNara/tplinkctl@9504067cc9fa8263a42205c0334ee4525a1ee93f -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/JithendraNara
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9504067cc9fa8263a42205c0334ee4525a1ee93f -
Trigger Event:
release
-
Statement type: