connectors
# connector-hub
One small local process that lets an AI agent control the devices in your home.
The agent talks to the hub over [MCP](https://modelcontextprotocol.io) (stdio) and sees six
tools, no matter how many kinds of device you add. The hub finds devices on your network,
keeps them connected, remembers them by hardware identity, and refuses to touch anything you
have not approved. Support for a new kind of device is a drop-in folder
([writing a driver](docs/WRITING_A_DRIVER.md)).
Included driver: **`android_adb`** for Android TVs, projectors and streaming boxes with
network debugging enabled.
```
agent ──MCP──▶ hub ──▶ driver: android_adb ──▶ projector, TV box, ...
│──▶ driver: (yours) ──▶ ...
└── ~/.connectors/devices.json (identity, names, approval)
```
## Quick start
Requires Python 3.12+, [uv](https://docs.astral.sh/uv/), and for `android_adb` the Android
platform-tools (`adb`). On the device, enable *Developer options → Network/wireless debugging*.
```sh
git clone <this repo> && cd connectors
uv sync
uv run connectors scan # find devices on your network
uv run connectors approve android-0a1b2c3d4e5f --name projector
uv run connectors list
```
Then register the hub with your MCP client (below) and ask your agent to "pause the projector".
## Registering with an MCP client
The server command is `connectors serve` (stdio). For the Claude Code CLI:
```sh
scripts/install.sh # runs: claude mcp add --scope user connectors -- <repo>/.venv/bin/connectors serve
scripts/install.sh --dry-run # only print the commands
```
For any other client, add an entry equivalent to:
```json
{ "mcpServers": { "connectors": { "command": "/path/to/connectors/.venv/bin/connectors", "args": ["serve"] } } }
```
The hub lives as long as the client keeps it running; discovery and health checks run in the
background for that whole time. stdout carries only MCP; logs go to stderr and
`~/.connectors/hub.log`.
## Tools
| Tool | What it does |
| --- | --- |
| `devices()` | Every known device: id, friendly name, driver, reachable, approved, capabilities and their actions. |
| `state(device)` | Awake/asleep, foreground app, now playing (title, playing/paused), volume. |
| `act(device, capability, action, args?)` | Control the device using the shared vocabulary below. |
| `observe(device)` | Screenshot, returned as a downscaled JPEG image. |
| `run(device, command, confirm?, timeout?)` | Raw escape hatch (`adb shell <command>` for `android_adb`): stdout, stderr, exit code. Guarded, see [Safety](#safety). |
| `rescan()` | Run discovery now. |
`device` is an id or a friendly name; matching is case-insensitive and forgiving
("the Projector", "proj").
## Capability vocabulary
The same words mean the same thing on every device. A device supports a subset, listed by
`devices()`.
| Capability | Actions | Arguments |
| --- | --- | --- |
| `power` | `on` `off` `sleep` `wake` | |
| `volume` | `set` `up` `down` `mute` | `level` 0-100 for `set`; `steps` for `up`/`down` |
| `media` | `play` `pause` `toggle` `seek` `next` `previous` `stop` | `seconds` (±) for `seek` |
| `navigate` | `up` `down` `left` `right` `ok` `back` `home` `menu` | `times` |
| `apps` | `list` `open` `close` | `app`: a name ("netflix", "prime", "youtube") or a package id |
| `text` | `type` | `text`, `enter` |
| `open` | `url` `search` | `url` or `query`, optional `app` |
Examples: `act("projector", "media", "pause")`,
`act("projector", "volume", "set", {"level": 30})`,
`act("projector", "open", "search", {"query": "lofi beats", "app": "youtube"})`.
## Connections are the hub's job
The agent never connects, pairs or handles addresses.
- **Discovery** runs in the background per driver. `android_adb` re-probes remembered devices,
then sweeps the local /24 for TCP 5555 (override with `CONNECTORS_SUBNETS=10.0.0.0/24,...`).
- **Identity** is a stable hardware id (the device's MAC address), not its IP. When DHCP moves
a device, the hub finds it again and keeps its name and approval.
- **Health checks** run every ~25 s, reconnecting with exponential back-off.
- **Every tool call** first makes sure the device is connected, re-discovering it if needed.
If that fails the agent gets a plain reason: *"projector is not reachable on the network —
it may be powered off, asleep or disconnected."*
## Safety
- **Approval.** A newly discovered device is listed but unusable (`state`, `act`, `observe`
and `run` all refuse) until you approve it from a terminal:
`connectors approve <id> --name <name>`. The agent has no tool that can approve a device.
- **Guarded `run`.** Commands matching a denylist of destructive patterns (factory reset /
wipe, recursive delete, uninstalling or disabling apps, reboot, `dd` / `mkfs`, turning
debugging or networking off, ...) are refused unless called with `confirm=true`, and the tool
description instructs the agent to get your spoken yes first. The list is in
[`safety.py`](src/connector_hub/safety.py). It is a seat belt against mistakes, not a
sandbox: treat an approved device as fully controllable by the agent.
- **Risky actions.** A driver can mark vocabulary actions as risky in its manifest; `act`
refuses those without `args.confirm=true`.
- **Local only.** The hub opens no listening ports. State lives in `~/.connectors/`
(override with `CONNECTORS_HOME`).
Network adb has no authentication beyond the device's own "Allow debugging?" prompt, so only
enable it on a network you trust.
## CLI
```
connectors serve run the MCP server on stdio
connectors scan discover devices now
connectors list show known devices
connectors approve <id> --name NAME allow the agent to use a device
connectors add <host:port> register a device discovery cannot see (a paired phone)
connectors forget <id> remove a device
```
## android_adb notes
- `adb` is located on `PATH`, then `$ANDROID_HOME/platform-tools`, then common install paths.
- `power.off` and `power.sleep` both put the device in standby, so it can be woken again.
- `media.seek` sends fast-forward / rewind key presses; how far each one jumps is up to the app.
- `open.search` uses deep links for apps that have one (YouTube, Netflix); with no `app` it
tries the system search, then a web search.
- `text.type` handles single-line ASCII.
- `observe` shows black where an app plays protected video.
- A device that shows "unauthorized" needs its on-screen debugging prompt accepted once.
## Phones and tablets
A phone is one more `android_adb` device. Pair it once, then add it by address:
1. On the phone: Developer options → Wireless debugging → *Pair device with pairing code*.
2. On this computer: `adb pair <pairing address>` and type the code.
3. `connectors add <IP address & port shown under Wireless debugging>`, then `connectors approve <id> --name phone`.
Differences from a TV or projector:
- **Its port changes** whenever Wireless debugging is switched back on. The hub follows it: it
looks the phone up by hardware address and sweeps for the new port. After a phone reboot you
still have to turn Wireless debugging on again yourself.
- **It gets the `touch` capability** (tap, long press, swipe). Coordinates are fractions of the
screen (0–1), so they match what `observe` returns at any size.
- **It is `strict`.** Every raw `run` command needs the user's yes, not only destructive ones,
and the agent is told to get a yes before anything that sends, calls, pays, deletes or installs.
Taps cannot be classified mechanically, so that last rule relies on the agent and on your MCP
client's own confirmation gate. Toggle with `connectors approve <device> --strict` / `--no-strict`.
Pairing keys live in `~/.android`, and the device registry in `~/.connectors` (owner-only).
Neither belongs in this repository.
## Adding a driver
Create a folder with a `manifest.toml` and a `driver.py` in `~/.connectors/drivers/` (or in
`src/connector_hub/drivers/` to contribute it). See
[docs/WRITING_A_DRIVER.md](docs/WRITING_A_DRIVER.md).
## Development
```sh
uv run pytest # no device needed: a fake driver and a scripted adb
uv run ruff check . && uv run ruff format --check .
uv run mypy
```
## License
MIT
TDQS
Scored across 6 tools
Each tool targets a distinct facet: discovery (devices/rescan), structured state, action control, visual observation, and a raw escape hatch. Minor overlap exists between devices and rescan (both return device lists) and between state and observe (both inspect current device status), but the descriptions clarify when to use each.
All names are single lowercase words, but the set mixes nouns (devices, state) with verbs (act, observe, rescan, run), so there is no single predictable convention. It remains readable and intuitive, but not a consistent verb_noun pattern.
Six tools is well-scoped for a device-control server: discovery, rescan, state inspection, action, screenshot, and an escape hatch. Each tool has a clear, non-redundant role and earns its place.
The surface covers discovery, state, control (via a rich capability vocabulary), visual verification, and raw command fallback, which handles most workflows. Minor gaps remain around managing device approval/pairing and removing or forgetting devices, which the tools reference but do not expose.