Parley Term
# Parley Term
Peer-to-peer [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for orchestrating interactive coding CLI agents across native terminal tabs.
Parley lets any MCP-capable coding agent (**Codex**, **Claude Code**, **Antigravity**, **OpenCode**, **Grok Build**) open real interactive tabs in your terminal, delegate tasks, read structured replies directly from local session logs instead of screen-scraping, and collaborate peer-to-peer while you watch every turn live and step in whenever you want.
> [!NOTE]
> Parley imposes no forced `git worktree` layout, no hardcoded default "leader" agent, and no model overrides. Any agent can orchestrate any other agent in your active working directory, passing custom CLI arguments through verbatim.
## Why Parley
- **Visible, interactive collaboration**: Agents run inside real terminal tabs you can click into at any moment rather than hidden background subprocesses.
- **Structured session log reading**: `wait_for_reply` and `read_history` read native local session files (JSONL / structured storage) instead of parsing ANSI terminal scrollback.
- **Multi-terminal native drivers**: Auto-detects your host terminal and supports **Ghostty 1.3+**, **iTerm2**, **WezTerm**, **Kitty**, and **tmux**.
- **Safe by default**: Uses bracketed/paste input with calibrated pre-Enter delays, blocks self-loop messages, and refuses to close pre-existing tabs you opened yourself.
## Supported Terminals
| Terminal | Platform | Control Mechanism | Auto-Detection Signal |
| :--- | :--- | :--- | :--- |
| **Ghostty (1.3+)** | macOS | Native AppleScript (`Ghostty.sdef`) | `TERM_PROGRAM=ghostty` |
| **iTerm2** | macOS | Native AppleScript | `TERM_PROGRAM=iTerm.app` |
| **WezTerm** | macOS / Linux / Windows | `wezterm cli` JSON + stdin | `WEZTERM_PANE` |
| **Kitty** | macOS / Linux | `kitty @` remote control | `KITTY_WINDOW_ID` |
| **tmux** | macOS / Linux / SSH | `load-buffer` + `paste-buffer -p` | `TMUX` |
> [!TIP]
> Override auto-detection anytime with `PARLEY_DRIVER=ghostty|iterm2|wezterm|kitty|tmux` or `parley-term --driver <name>`.
## Supported CLI Agents
| Agent | Default Command | Session Log Source |
| :--- | :--- | :--- |
| `codex` | `codex` | `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` |
| `claude` | `claude` | `~/.claude/projects/<project-slug>/*.jsonl` |
| `antigravity` | `agy` | `~/.gemini/antigravity-cli/brain/<id>/.system_generated/logs/transcript.jsonl` |
| `opencode` | `opencode` | `~/.local/share/opencode/storage/` |
| `grok` | `grok` | `$GROK_HOME` or `~/.grok/sessions/` |
| `custom` | User-specified | Tab control only (`send_message`, `send_key`) |
## Quick Start
### CC Switch / Standard MCP Client Config
Add `parley-term` as a standard `stdio` MCP server in **CC Switch**, Claude Code, Codex, Antigravity (`~/.gemini/config/mcp_config.json`), OpenCode, or Grok:
```json
{
"mcpServers": {
"parley": {
"command": "npx",
"args": ["-y", "parley-term@latest"]
}
}
}
```
To force a specific terminal driver:
```json
{
"mcpServers": {
"parley": {
"command": "npx",
"args": ["-y", "parley-term@latest", "--driver", "ghostty"]
}
}
}
```
<details>
<summary>Alternative: Claude Code & Codex CLI one-liners</summary>
```bash
# Claude Code
claude mcp add parley -- npx -y parley-term@latest
# Codex CLI
codex mcp add parley -- npx -y parley-term@latest
```
</details>
## Tools Reference
| Tool | Purpose | Key Parameters |
| :--- | :--- | :--- |
| `list_agents` | Discover active terminal tabs and bound session files | — |
| `open_agent` | Open a new tab running a CLI agent without touching existing tabs | `agent`, `cwd`, `label?`, `command?`, `args?`, `env?` |
| `send_message` | Paste a prompt safely and press Enter after calibrated delay | `target`, `message`, `sender?`, `includeHeader?`, `pressEnter?` |
| `wait_for_reply` | Wait on local session logs until turn completion, stall, exit, or timeout | `target`, `timeoutSeconds?`, `stallWarningSeconds?`, `sessionPath?` |
| `read_history` | Read recent structured user/assistant messages from session logs | `target`, `limit?`, `sessionPath?` |
| `send_key` | Send a control key (`enter`, `escape`, `ctrl-c`, `ctrl-d`, `tab`, `up`, `down`) | `target`, `key` |
| `close_agent` | Close a Parley-opened tab (external tabs require `allowExternal: true`) | `target`, `allowExternal?` |
## Development
```bash
npm install
npm run validate
```
### Environment Variables
| Variable | Description |
| :--- | :--- |
| `PARLEY_DRIVER` | Override detected terminal driver (`ghostty`, `iterm2`, `wezterm`, `kitty`, `tmux`) |
| `PARLEY_TMUX_SOCKET` | Custom tmux socket path |
| `PARLEY_SELF_TAB_ID` | Override caller tab ID for self-loop protection |
| `PARLEY_DEBUG=1` | Emit diagnostic logs to `stderr` (never `stdout`) |
TDQS
Scored across 7 tools
Each tool maps to a distinct action on the agent-tab resource: discovery, creation, teardown, text input, key input, waiting, and history reading. The only potential overlap is send_message vs send_key, since both inject input into the same tab, but the descriptions clearly separate text prompts from control/navigation keys.
All seven names follow a strict snake_case verb_noun pattern (list_agents, open_agent, send_message, wait_for_reply, read_history, send_key, close_agent). The verb choice is also semantically precise (send vs read vs wait vs open/close), so the pattern is both consistent and informative.
Seven tools is a tight, well-scoped surface for driving a set of terminal agent tabs, with no redundant or filler operations. Each tool covers a necessary step in the interaction loop (discover → open → prompt → wait → read → clean up).
The full lifecycle is covered: listing, spawning, prompting, key input, polling for completion, history retrieval, and guarded teardown. Minor gaps remain—no broadcast/multi-agent fan-out, no tool to inspect whether a tab is idle without waiting on a turn, and no explicit way to query raw screen state if the session log is unavailable.