Polyphonia MCP
by Shichaoxx
README.md
# Polyphonia
A local console and MCP server for coordinating coding agents across your machine and SSH GPU servers.
English | [简体中文](README_zh.md)
---
Polyphonia lets you inspect, switch, and dispatch work across coding agents (`Codex`, `Antigravity`, `Claude Code`, `Kimi Code`, `QCoder`, `dsh`, `Gemini CLI`, `Pi`, `Hermes`, or your own CLI tools) running on both your laptop and remote SSH servers — without installing any remote daemon.
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/console-dark.png">
<img alt="Polyphonia local console" src="docs/assets/console-light.png">
</picture>
## What It Does
- **Runs over plain SSH**: Connects to lab and GPU servers via `ssh -o BatchMode=yes` with no background service or open ports on remote hosts.
- **Keeps your existing tools**: Reuses each agent's own login, sandbox, and local session files (read-only SQLite `?mode=ro` and `rollout.jsonl` for Codex; local `ConversationService` for Antigravity; headless CLI flags for everything else).
- **Checks policy before dispatch**: Enforces sandbox mode (`read_only` by default), live `nvidia-smi` free-GPU counts (`forbid` / `allow` / `require_free`), and directory allowlists (with remote `realpath` checks), logging every run and block to a local SQLite ledger.
- **Web console + MCP**: Use the browser console at `http://127.0.0.1:7842`, or plug `polyphonia mcp` into Antigravity, Codex, or Claude Code so your main agent can coordinate the rest.
- **Minimal runtime**: Python 3.11+ standard library and `PyYAML` only.
## Architecture
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/architecture.en.dark.svg">
<img alt="Polyphonia architecture" src="docs/assets/architecture.en.light.svg">
</picture>
See [docs/architecture.md](docs/architecture.md) for module layout, REST endpoints, MCP tools, and security boundaries.
## Try the Demo
Explore the console with simulated hosts, 4× RTX 3090 telemetry, sample sessions, and live guardrail checks without touching your config or SSH hosts:
```sh
python3 -m pip install -e .
polyphonia ui --demo
```
Open `http://127.0.0.1:7842`.
## Quick Start
```sh
# Launch the local console (defaults to local host + 9 built-in adapters)
polyphonia ui
# Inspect hosts, GPUs (with process owners), and sessions from the terminal
polyphonia doctor
polyphonia hosts --probe
polyphonia gpus
polyphonia sessions
# Simulate a policy check before running anything
polyphonia dispatch \
--host gpu-lab \
--adapter codex \
--cwd /srv/projects/eval-suite \
--gpu-policy require_free \
--min-free-gpus 2 \
--dry-run \
"Run evaluation sweep"
# Request a read-only cross-model review
polyphonia cross-review \
--host local \
--adapter codex \
--cwd /path/to/repo \
--question "Check concurrency locks, path handling, and missing tests."
# Print an MCP config snippet for your primary agent
polyphonia snippet antigravity
polyphonia snippet codex
polyphonia snippet claude
```
To configure SSH hosts, remote proxies, custom `PATH` prefixes, or directory allowlists, copy [polyphonia.example.yaml](polyphonia.example.yaml) to `~/.config/polyphonia/config.yaml` (or set `POLYPHONIA_CONFIG`).
## Supported Adapters
| Adapter | Driver | Session Discovery & Peek | Dispatch | Spec |
| :--- | :--- | :--- | :--- | :--- |
| **Codex** | `codex` | Read-only `state_5.sqlite` + `rollout.jsonl` | `codex queue --resume` or `codex exec` | Built-in |
| **Antigravity** | `antigravity` | Local `ConversationService` RPC | `CreateConversation` | Built-in |
| **Claude Code** | `generic_cli` | — | `claude -p [--permission-mode plan]` | [claude-code.yaml](adapters/claude-code.yaml) |
| **Kimi Code** | `generic_cli` | — | `kimi --print [--plan]` | [kimi-code.yaml](adapters/kimi-code.yaml) |
| **QCoder** | `generic_cli` | — | `qcoder --approval-mode plan\|auto-edit` | [qcoder.yaml](adapters/qcoder.yaml) |
| **dsh** | `generic_cli` | — | `dsh --profile headless --permission-mode ...` | [dsh.yaml](adapters/dsh.yaml) |
| **Gemini CLI** | `generic_cli` | — | `gemini` | [gemini-cli.yaml](adapters/gemini-cli.yaml) |
| **Pi** | `generic_cli` | — | `pi` | [pi.yaml](adapters/pi.yaml) |
| **Hermes** | `generic_cli` | — | `hermes` | [hermes.yaml](adapters/hermes.yaml) |
| **Custom CLIs** | `generic_cli` | — | Add from the UI or YAML | `~/.config/polyphonia/config.yaml` |
## MCP Tools
`polyphonia mcp` exposes 7 tools over stdio JSON-RPC (both newline-delimited and `Content-Length` framing):
`list_hosts_and_gpus` · `list_adapters` · `list_sessions` · `peek_session` · `dispatch_task` · `await_dispatch` · `cross_review`
## Tests
```sh
PYTHONPATH=src python3 -m unittest discover -s tests -v
```
## License
MIT — see [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues