
# troll
The port manager for one machine: permanent claims, expiring leases, and a live view of who listens where. One Rust binary providing the CLI, local HTTP API, embedded three-screen web console, and MCP stdio server across **Linux, macOS, and Windows**.
## Install
```sh
cargo install troll --locked
```
Prebuilt archives (`x86_64-linux`, `aarch64-macos`, `x86_64-macos`, `x86_64-windows` + `SHA256SUMS.txt`) are also published on [GitHub Releases](https://github.com/michelabboud/troll/releases/latest).
## Quick start
```sh
troll init
troll check 8123
troll claim 8123 --project demo --service web
troll lease --project demo --purpose preview --json
troll with --project demo -- sh -c 'printf "Leased port %s\n" "$PORT"'
troll explain 8123
troll list
troll doctor
troll serve
```
## Four surfaces, one locked registry
- **Command line (`troll ...`):** manage claims, leases, named `[pools]`, apps, red zones, 30-day removal `history` (with atomic restore), drift inspection, `explain`, and `doctor`. Add `--json` for machine output or `--llm-guide` for agent instructions.
- **Web console (`troll serve`):** local loopback HTTP API and embedded three-screen browser console (**Console**, **Apps**, **History**) with six themes, passive service detection, and one-click copy/restore actions.
- **MCP server (`troll mcp`):** Model Context Protocol server over stdio for coding agents (`troll setup claude` / `troll setup codex`).
- **Background service (`troll setup service`):** writes a systemd user unit on Linux, a `launchd` user agent plist on macOS, or a Task Scheduler XML definition on Windows.

## Guarantees
- **Never kills arbitrary processes:** sweeps remove only reclaimable leases from `registry.toml` and leave running processes alone (the sole documented signal exception is `troll with` forwarding a received stop signal unchanged to its own child).
- **Safe locked writes:** file-locked atomic updates with a backup copy on every change.
- **Loopback only:** `troll serve` binds `127.0.0.1`, enforces an exact `Host` allowlist, and requires a session token and matching `Origin` for mutations.
- **Zero `unsafe` code** across the workspace.
## Workspace crates
This binary crate is built on two companion library crates:
- **[`troll`](https://crates.io/crates/troll)** *(this crate)* — CLI, `troll serve` HTTP API + embedded web console, `troll mcp` stdio server, setup wizard, and OS service installers.
- **[`troll-core`](https://crates.io/crates/troll-core)** — platform-free registry model, file-locked atomic store, claims, leases, pools, red zones, 30-day history, drift, and sweep engine.
- **[`troll-probe`](https://crates.io/crates/troll-probe)** — read-only OS listener, ephemeral/excluded range, process liveness, and owner-classification probe for Linux, macOS, and Windows.
## Documentation
- [GitHub repository & full illustrated README](https://github.com/michelabboud/troll)
- [Command-line guide](https://github.com/michelabboud/troll/blob/main/docs/guides/command-line.md)
- [Console guide](https://github.com/michelabboud/troll/blob/main/docs/guides/console.md)
- [JSON, HTTP & MCP reference](https://github.com/michelabboud/troll/blob/main/docs/guides/json-output.md)
- [Runbook](https://github.com/michelabboud/troll/blob/main/RUNBOOK.md)
- [Architecture](https://github.com/michelabboud/troll/blob/main/ARCHITECTURE.md)
## Licence
MIT — see [LICENSE](https://github.com/michelabboud/troll/blob/main/LICENSE).