MCPOrchestrator
# MCPOrchestrator
[](https://github.com/engineertechlabs/MCPOrchestrator/actions/workflows/ci.yml)
[](https://pypi.org/project/mcporch/)
[](LICENSE)
[](https://www.python.org/)
[](https://modelcontextprotocol.io/)
**MCPOrchestrator** (`mcporch`) is a local-first AI orchestration bridge that connects your **Web AI browser sessions** (**ChatGPT**, **Claude**, and **Gemini**) with **any MCP-compatible coding agent** (**Antigravity**, **Cursor**, **Claude Code**, **Windsurf**, **Cline**, and more).
Instead of copy-pasting prompts back and forth between your browser and your IDE, MCPOrchestrator lets your Web AI act as an **independent planner and verifier** while your coding agent **writes code, runs tests, asks follow-up questions, and fixes defects** in a continuous loop.
---
## Dashboard Preview

---
## How to Use
### Step 1 — Install the Package
Install `mcporch` using `pip` (this installs the local FastAPI server, web dashboard, and MCP server):
```bash
pip install mcporch
```
<br>
### Step 2 — Run Setup & Load the Browser Extension
Run the setup command to extract the ready-to-load **Chromium** and **Firefox** extensions into `~/.mcporchestrator/extensions/`:
```bash
mcporchestrator setup
```
Then load the extension into your browser:
- **Chrome / Brave / Edge:**
1. Open `chrome://extensions` (or `brave://extensions`).
2. Turn on **Developer mode** in the top-right corner.
3. Click **Load unpacked** and select `~/.mcporchestrator/extensions/chromium`.
- **Firefox:**
1. Open `about:debugging#/runtime/this-firefox`.
2. Click **Load Temporary Add-on...**.
3. Select `~/.mcporchestrator/extensions/firefox/manifest.json`.
<br>
### Step 3 — Start the Local Server
Start MCPOrchestrator on `http://127.0.0.1:18421/`:
```bash
mcporchestrator start
```
Or install it as a background service that starts automatically on login:
```bash
mcporchestrator install-service
```
<br>
### Step 4 — Connect Your MCP Coding Agent
Add `mcporchestrator-mcp` to your IDE's MCP client configuration (Antigravity, Cursor, Claude Code, Windsurf, etc.):
```json
{
"mcpServers": {
"mcporchestrator": {
"command": "mcporchestrator-mcp"
}
}
}
```
<br>
### Step 5 — Open Your Web AI Tab & Start Orchestrating
1. Open **https://chatgpt.com**, **https://claude.ai**, or **https://gemini.google.com** and log in.
2. Keep that tab open with an empty message box.
3. Ask your coding agent to read your open chat (`mcporch_read_chat`), create a task (`mcporch_create_task`), or pick up a task from the dashboard (`http://127.0.0.1:18421/`).
4. Your Web AI plans the work, your coding agent implements & tests it, and your Web AI verifies every acceptance criterion before marking the task **Completed**.
---
## Architecture
```mermaid
flowchart LR
Agent["MCP Coding Agent\n(Antigravity, Cursor, Claude Code, etc.)"] <-->|"stdio (MCP)\n10 Tools"| MCP["FastMCP Server\n(mcporch_mcp / mcp-server/server.py)"]
MCP <-->|"HTTP + SSE\n127.0.0.1:18421"| Backend["FastAPI + SQLite Orchestrator\n(backend/app.py)"]
UI["Web Dashboard\n(mcporchestrator.html)"] <-->|"REST + SSE"| Backend
Backend <-->|"HTTP Leases & Progress\n/bridge/*"| Ext["Browser Extension\n(Chromium & Firefox MV3)"]
Ext <-->|"DOM Automation\n+ Open Chat Reader"| WebAI["Web AI Tabs\nChatGPT · Claude · Gemini"]
```
---
## Task Lifecycle & Continuous Loop
```mermaid
flowchart TD
Create["Create Task (POST /tasks or MCP)"] -->|"depends_on_task_id active"| WaitDep["waiting_dependency"]
WaitDep -->|"Parent completes"| Plan["planning\n(Web AI generates plan)"]
Create -->|"No pending dependency"| Plan
Plan -->|"Extension submits plan"| Pending["agent_pending\n(Ready for Coding Agent)"]
Pending -->|"mcporch_get_task"| Exec["executing\n(Agent edits code & runs tests)"]
Exec -->|"mcporch_ask_followup"| Followup["Active Web AI Follow-Up\n(Same open conversation)"]
Followup --> Exec
Exec -->|"mcporch_submit_result"| Verify["verifying\n(Web AI checks acceptance criteria)"]
Verify -->|"PASS (all criteria met)"| Complete["complete"]
Verify -->|"NEEDS_REWORK (retries < max)"| Pending
Verify -->|"FAIL / max retries / stalled"| Review["manual_review / failed"]
```
---
## MCP Tools Reference (`mcporchestrator-mcp`)
| Tool | Purpose | Key Parameters |
| --- | --- | --- |
| `mcporch_read_chat` | Instantly read the last `N` messages from your open ChatGPT/Claude/Gemini tab without sending a prompt | `last_n=10`, `host="any"`, `timeout_seconds=15` |
| `mcporch_create_task` | Create a new task and queue its planning prompt | `title`, `project_path`, `objective`, `acceptance_criteria` |
| `mcporch_wait_for_task` | Wait in 20s-safe slices (`still_working=True` + live `bridge_progress` when Web AI is still typing) | `task_id`, `target_statuses`, `timeout_seconds=20` |
| `mcporch_ask_followup` | Ask a follow-up question inside the active Web AI thread and receive its reply | `task_id`, `question`, `context`, `wait_for_reply=True` |
| `mcporch_get_task` | Lease the next `agent_pending` task (optionally filtered by `project_path`) | `project_path=None` |
| `mcporch_heartbeat` | Extend the active execution lease during long builds or test runs | `task_id`, `lease_token` |
| `mcporch_submit_result` | Submit execution summary, test results, `exit_code`, and `diff_summary` for verification | `task_id`, `lease_token`, `summary`, `wait_for_verdict=False` |
| `mcporch_task_status` | Inspect current status, plan, follow-ups, `bridge_progress`, and verification verdict | `task_id` |
| `mcporch_list_tasks` | List recent tasks across the queue | `limit=20` |
| `mcporch_cancel_task` | Cancel an active task (`manual_review`) and free its queue | `task_id`, `reason` |
---
## Key Features
- **Read Open Chat Context (`mcporch_read_chat`):** Pull the last `N` messages directly from your open ChatGPT, Claude, or Gemini tab before writing a single line of code.
- **No More 20–30s Timeout Drops:** `content.js` streams live progress pings (`POST /bridge/progress` with character counts and elapsed seconds), while `mcporch_wait_for_task` returns in safe `20s` slices with `still_working=True` so IDE agents never give up early.
- **Cross-Model Routing:** Choose `Any Open Tab`, `chatgpt.com`, `claude.ai`, or `gemini.google.com` separately for `planner_host` and `verifier_host` (e.g., plan with Claude, verify independently with ChatGPT).
- **Task Dependency Chaining:** Pass `depends_on_task_id` on `POST /tasks` to hold follow-up tasks in `waiting_dependency` until the parent task reaches `complete`.
- **Automatic Stall Recovery:** If a browser AI tab hits a network error banner or stalls after submission, `POST /bridge/stalled` immediately requeues or escalates to `manual_review` instead of waiting 15 minutes for lease expiry.
- **Dashboard Productivity Tools:** Includes one-click **Task Templates** (*Feature Build*, *Bug Fix*, *Code Review*, *Security Audit*), **Clone Task**, **Export `.md`** report, live **SSE streaming** in the Inspect modal, and an interactive **Follow-Up** composer.
- **Webhook & Desktop Notifications:** Browser notifications on plan/verdict completion plus optional `MCPORCH_WEBHOOK_URL` JSON alerts.
---
## CLI Commands
```bash
mcporchestrator setup # Extract extensions + open setup guide
mcporchestrator start [--port 18421] # Start the FastAPI server + dashboard
mcporchestrator status # Check backend health
mcporchestrator watch <TASK_ID> # Stream live SSE status & progress in terminal
mcporchestrator install-service # Install user-level systemd / launchd / Windows task
mcporchestrator uninstall-service # Remove background service
```
---
## Project Structure
```text
MCPOrchestrator/
├── backend/
│ ├── app.py # FastAPI orchestrator, SQLite state, SSE, security middleware
│ ├── cli.py # CLI: start, setup, status, watch, install-service
│ └── mcporchestrator.html # Full-width dark glass dashboard & How to Use guide
├── mcp-server/
│ └── server.py # FastMCP stdio server exposing all 10 mcporch_* tools
├── chromium-extension/ # Manifest V3 extension for Chrome, Brave, Edge
├── firefox-extension/ # Manifest V3 extension for Firefox
├── scripts/
│ └── package_extensions.py # Builds Chromium & Firefox .zip archives into dist/
├── docs/
│ └── dashboard-preview.png # Live dashboard screenshot
└── tests/ # Python unittest + Node.js bridge test suites
```
---
## API Reference
| Method & Path | Consumer | Purpose |
| --- | --- | --- |
| `GET /` | Browser | Serves the MCPOrchestrator web dashboard |
| `GET /health` | Diagnostics | Health check (`ok`, `service`, `version`, `auth_required`) |
| `POST /tasks` | User / MCP | Create a task (`planner_host`, `verifier_host`, `depends_on_task_id`) |
| `GET /tasks` | User / UI | List recent tasks (`?limit=20`) |
| `GET /tasks/{task_id}` | User / UI / MCP | Get full task snapshot, `bridge_progress`, and `followups` |
| `GET /tasks/{task_id}/events` | User / UI | Get ordered event audit trail |
| `GET /tasks/{task_id}/stream` | UI / CLI | Server-Sent Events (SSE) live stream |
| `POST /tasks/{task_id}/followup` | User / MCP | Queue a follow-up prompt in the active Web AI thread |
| `POST /tasks/{task_id}/cancel` | User / MCP | Cancel an active task (`manual_review`) |
| `POST /tasks/{task_id}/reset-bridge-lease` | User / UI | Return a `delivered` bridge item back to `pending` |
| `GET /bridge/next` | Extension | Lease next pending prompt (`?worker_id=...&host=...`) |
| `POST /bridge/progress` | Extension | Report live Web AI generation stage & character count |
| `POST /bridge/stalled` | Extension | Immediately requeue or escalate stalled browser responses |
| `POST /bridge/release` | Extension | Release a pre-submission lease back to `pending` |
| `POST /bridge/response` | Extension | Submit Web AI response (idempotent on exact replay) |
| `POST /bridge/chat-read-request` | MCP Server | Request visible messages from an open Web AI tab |
| `GET /agent/next` | MCP Server | Lease next `agent_pending` task (`?project_path=...`) |
| `POST /agent/heartbeat` | MCP Server | Extend active `executing` agent lease |
| `POST /agent/report` | MCP Server | Submit implementation report (`exit_code`, `diff_summary`) |
---
## Testing & Validation
```bash
# 1. Run Python backend, CLI, and MCP tool tests
.venv/bin/python -m unittest discover -s tests -v
# 2. Run browser extension bridge & adapter tests
node --test tests/bridge.test.js
# 3. Package Chromium & Firefox extension zips into dist/
.venv/bin/python scripts/package_extensions.py
```
---
## Troubleshooting
- **Extension does not pick up prompts:** Make sure your ChatGPT, Claude, or Gemini tab is open, logged in, and its message input box is empty (MCPOrchestrator never overwrites unsent user drafts).
- **Task stuck in `planning` or `verifying`:** Open **Tasks** → click **Reset** on the task row (or **Inspect** to view live SSE `bridge_progress` and events).
- **Running with token auth:** Set `MCPORCH_API_TOKEN=<secret>` before starting the server, then paste the same token into the dashboard **Settings** tab and the extension popup.
---
## Important Boundaries & Security Model
> [!IMPORTANT]
> MCPOrchestrator is built for **safe, local-first orchestration** with clear boundaries between your browser, server, and coding workspace.
- **No API keys scraped or stored:** The browser extension operates inside your own logged-in **ChatGPT** (`chatgpt.com`), **Claude** (`claude.ai`), or **Gemini** (`gemini.google.com`) tab.
- **Local-first by design:** The orchestrator binds to `127.0.0.1:18421` with Host-header DNS-rebinding protection, Content Security Policy headers, restricted system-path checks, and optional bearer authentication (`MCPORCH_API_TOKEN`).
- **Strict separation of duties:** The backend server **never** executes shell commands or modifies files directly — only your local MCP coding agent touches your repository.
- **Per-project queue isolation:** Only one active task runs per `project_path` at a time, preventing concurrent agents from overwriting each other's changes.
---
## License
MIT — see [LICENSE](LICENSE).
TDQS
Scored across 10 tools
Most tools map to distinct lifecycle actions: create, list, status, cancel, wait, lease, heartbeat, submit, follow-up, and chat read. A few boundaries require careful reading, especially task_status vs. wait_for_task and get_task vs. list_tasks, but descriptions make them distinguishable.
All tools use a consistent mcporch_ snake_case prefix and mostly follow verb_noun naming. Deviations like mcporch_task_status and mcporch_heartbeat are readable but less predictable than the rest.
Ten tools is well-scoped for an orchestration lifecycle spanning task creation, leasing, monitoring, follow-up, cancellation, and result submission. Each tool appears to earn its place without obvious redundancy.
The set covers the core task lifecycle from creation through planning, leasing, heartbeat, submission, and cancellation, plus chat read/follow-up. Minor gaps exist around explicit retry/requeue, cleanup/deletion, or direct task result retrieval, but status likely covers the main inspection needs.