Metadata-Version: 2.5
Name: deco-mcp
Version: 0.3.1
Summary: MCP server for TP-Link Deco mesh routers: clients, Wi-Fi, port forwarding, HomeShield, firmware, logs and diagnostics over the local web and app protocols, no cloud
Project-URL: Repository, https://github.com/oscnord/deco-mcp
Project-URL: Issues, https://github.com/oscnord/deco-mcp/issues
Author: Oscar Nord
License-Expression: MIT
License-File: LICENSE
Keywords: deco,home-network,mcp,mcp-server,mesh-wifi,model-context-protocol,router,tp-link
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: System :: Networking
Requires-Python: >=3.11
Requires-Dist: cryptography>=43
Requires-Dist: httpx2>=2.16
Requires-Dist: mcp>=2.3
Requires-Dist: pydantic>=2
Description-Content-Type: text/markdown

# deco-mcp

<!-- mcp-name: io.github.oscnord/deco-mcp -->

An [MCP](https://modelcontextprotocol.io) server for managing a TP-Link Deco mesh network from an AI assistant, so you rarely need the Deco app: see what the network is doing, find what is eating the bandwidth, block devices, hand out fixed IPs, forward ports, switch guest Wi-Fi on and off, check HomeShield, firmware and logs, and diagnose a slow connection.

It talks to the Deco directly on your home network, never through TP-Link's cloud. The Deco has two ways in, and the server uses both, with its own client for each (no third-party router library):

| | What it is | How it logs in | What it covers |
|---|---|---|---|
| **Web API** | The interface behind the Deco's admin page at `https://192.168.68.1` | The Deco's local admin password | Status, clients, blocking, fixed IPs, logs, firmware, reboot |
| **App protocol** | The connection the Deco mobile app makes to the Deco on your network (port 30001) | The Deco owner's TP-Link ID, the same email and password you use in the Deco app | Everything the admin page can't do: port forwarding, guest Wi-Fi, HomeShield, parental controls, QoS and other app-only settings |

Tools marked 📱 below use the app protocol, so they only work once the TP-Link ID is set up (see [Setup](#setup)). The rest need only the admin password.

Tested on a Deco BE25 running firmware 1.1.8. Other Deco models speak the same protocols but may support fewer features.

## Tools

Read-only tools are always available. Tools marked ✎ change something and only exist when the server runs with `DECO_ALLOW_WRITES=1`; ⚠ marks ones that delete something, expose a device or cut the network.

### Network and mesh

| Tool | |
|---|---|
| `deco_get_network` | Internet state, WAN/LAN addressing, IPv6, mode, main Deco CPU/memory |
| `deco_list_units` | Each Deco unit: role, IP, mesh/internet status, uplink signal, firmware |
| `deco_diagnose_path` | Packet loss/latency to the first hops and public resolvers, plus macOS `networkQuality`. Runs on your machine, needs no Deco login |
| `deco_list_port_forwards` 📱 | Port forwarding rules |
| `deco_add_port_forward` 📱✎⚠ / `deco_remove_port_forward` 📱✎⚠ | Expose a LAN device's port to the internet, or stop |
| `deco_reboot` ✎⚠ | Reboot one unit or the whole mesh |

### Wi-Fi

| Tool | |
|---|---|
| `deco_get_wifi` | Main, guest, IoT and MLO networks per band. Passwords are never returned |
| `deco_set_wifi_network` 📱✎ | Turn the guest, IoT or MLO network on or off |

### Clients

| Tool | |
|---|---|
| `deco_list_clients` | Devices with live download/upload rates in kbit/s, busiest first |
| `deco_list_blocked_clients` | Devices blocked from the internet |
| `deco_block_client` ✎ / `deco_unblock_client` ✎ | Block or restore a device's internet access |
| `deco_list_reservations` | Configured fixed IPs |
| `deco_add_reservation` ✎ / `deco_remove_reservation` ✎⚠ | Give a device a fixed IP, or remove it |
| `deco_list_dhcp_leases` 📱 | Addresses handed out right now |

### Security, parental controls and QoS

| Tool | |
|---|---|
| `deco_get_security` 📱 | HomeShield protections and recent security events |
| `deco_get_parental_controls` 📱 | Parental-control profiles |
| `deco_get_qos` 📱 | QoS mode, priorities and bandwidth limits |

### System and settings

| Tool | |
|---|---|
| `deco_get_system_log` | Recent log lines by severity, with optional search |
| `deco_check_firmware` | Installed firmware per unit and whether an update is available |
| `deco_get_speedtest` / `deco_run_speedtest` ✎ | The Deco's own internet speed test |
| `deco_get_time_settings` | Clock and time zone |
| `deco_get_setting` 📱 | One of: DHCP pool, UPnP, SIP ALG, LED, eco mode, Wi-Fi schedule, reboot schedule, auto-update, client isolation, access control, DDNS, IPTV, IPv6 firewall, static routes, VPN client/server, CWMP, WPS |
| `deco_set_switch` 📱✎ | Turn the status LEDs, UPnP or SIP ALG on or off |

Not covered yet: editing parental-control profiles, QoS, HomeShield, Wi-Fi names/passwords/schedules, and firmware upgrades.

## Safety

- **Read-only by default.** Write tools are not registered at all unless `DECO_ALLOW_WRITES=1` is set, and every tool carries MCP annotations (`readOnlyHint`, `destructiveHint`) so clients can ask before running one.
- **Preview first.** Write tools return a preview of what they would do and change nothing unless called with `confirm=true`. That flag is a convention for the assistant, not an approval step: keep your MCP client asking before each write tool call rather than auto-approving them. The app-protocol writes re-read the setting afterwards and say whether it took.
- **Untrusted names.** Device names, SSIDs and log lines are chosen by whoever owns the device, including guests. Treat them as data; the server's instructions tell the assistant the same.
- **No lockouts.** The Deco locks logins after repeated failures. After a refused login the server makes no further attempt until it is restarted, so fix the credentials and restart it. App-protocol requests are never resent after a failure, since a write may already have happened; web requests are only resent when the Deco says the session had expired, i.e. the request was not applied.
- **Secrets stay out.** Wi-Fi passwords are never returned; `deco_get_setting` removes passwords, keys, usernames and PINs; session tokens are kept out of error messages, and log lines that carry them are filtered out.
- **Privacy.** Tool results go to your AI provider like any other conversation content. They can include device names, IPs and MACs (who is home and what they own), your public IP, DDNS hostname, SSIDs, parental-control profiles and log lines.
- **TLS.** The Deco's web API uses a self-signed certificate, so that connection is not verified: someone able to intercept traffic on your LAN could capture the admin password. The app protocol authenticates both ends with SPAKE2+ instead, so it does not have this weakness. Only point `DECO_HOST` at your own Deco.
- **One admin session.** The Deco allows a single web admin login, so using the server signs you out of the Deco web page (and vice versa).

## Setup

You need [uv](https://docs.astral.sh/uv/) (or Python 3.11+), the Deco's **local admin password** (for `https://192.168.68.1`) and, for 📱 tools, the **Deco owner's TP-Link ID** (email and password, as used in the Deco app).

Store them in the macOS Keychain, from a regular terminal:

```sh
security add-generic-password -s deco-mcp -a admin -w
security add-generic-password -s deco-mcp-tplink -a you@example.com -w
```

Each prompts for the password, so it never lands in your shell history. Don't run them through an assistant's shell (such as Claude Code's `!`): with no terminal to read from they store an empty password.

On other systems, set `DECO_PASSWORD`, `DECO_TPLINK_EMAIL` and `DECO_TPLINK_PASSWORD` instead. They then sit in plain text in your MCP client's config.

### Claude Code

```sh
claude mcp add deco -- uvx deco-mcp
```

Add `-e DECO_ALLOW_WRITES=1` before `--` to enable the write tools.

### Other MCP clients

```json
{
  "mcpServers": {
    "deco": {
      "command": "uvx",
      "args": ["deco-mcp"],
      "env": { "DECO_ALLOW_WRITES": "0" }
    }
  }
}
```

## Configuration

| Variable | Default | |
|---|---|---|
| `DECO_HOST` | `https://192.168.68.1` | Main Deco, including the scheme |
| `DECO_ALLOW_WRITES` | unset | `1` registers the write tools |
| `DECO_PASSWORD` | | Local admin password; overrides the Keychain |
| `DECO_TPLINK_EMAIL` / `DECO_TPLINK_PASSWORD` | | Owner's TP-Link ID; overrides the Keychain |
| `DECO_KEYCHAIN_SERVICE` | `deco-mcp` | Keychain item for the admin password |
| `DECO_TPLINK_KEYCHAIN_SERVICE` | `deco-mcp-tplink` | Keychain item for the TP-Link ID |

`deco_diagnose_path` needs `ping` and, for the hop list, `traceroute` (macOS or Linux).

## Development

```sh
python3 -m venv .venv && .venv/bin/pip install -e .
.venv/bin/python -m unittest discover -s tests
npx @modelcontextprotocol/inspector .venv/bin/deco-mcp
```

The app-protocol client was written from a clean-room description of the protocol, not from any existing implementation.

## License

MIT
