MCPOrchestrator
MCPOrchestrator is a local-first AI orchestration bridge that connects:
- ChatGPT Web (for planning and independent verification) via a Manifest V3 browser extension,
- Any MCP-compatible AI coding agent (any MCP-compatible AI coding client, etc.) via a standard stdio FastMCP server, and
- A FastAPI + SQLite orchestrator that manages tasks, leases, retries, and event history on
127.0.0.1:18421.
Architecture
+-------------------+ HTTP (127.0.0.1:18421) +------------------------+
| FastAPI Backend | <-------------------------------> | Browser Extension |
| + SQLite Queue | GET /bridge/next | (Chromium / |
| (backend/app.py) | POST /bridge/response | Firefox/Safari) |
+-------------------+ POST /bridge/release +-----------+------------+
^ |
| HTTP (httpx) | DOM Automation
v v
+-------------------+ stdio (MCP) +------------------------+
| FastMCP Server | <-------------------------------> | https://chatgpt.com/ |
| (mcp-server/ | mcporch_get_task | (Logged-in Session) |
| server.py) | mcporch_heartbeat +------------------------+
+-------------------+ mcporch_submit_result
^
|
v
+-------------------+
| MCP AI Client |
| (Any MCP-Enabled |
| Coding Agent) |
+-------------------+
Task Lifecycle
- Create task (
POST /tasks): Stores the task in SQLite (status = planning) and queues aplanprompt inbridge_queue. - ChatGPT planning: The browser extension polls
GET /bridge/next, injects the prompt into an open, emptychatgpt.comcomposer, submits it, waits for streaming completion, and posts the plan toPOST /bridge/response(status = agent_pending). - Agent execution: Your MCP-enabled AI tool calls
mcporch_get_task(GET /agent/next), receives the plan and a 15-minutelease_token, implements and tests the work locally, optionally extends the lease viamcporch_heartbeat, and submits evidence viamcporch_submit_result(POST /agent/report,status = verifying). - Independent verification: MCPOrchestrator queues a
verifyprompt for ChatGPT containing the acceptance criteria and execution report. ChatGPT returns a structured JSON verdict:PASS(all criteria explicitlyPASS) →completeNEEDS_REWORK→ incrementsretry_count(up toMAX_RETRIES, default3) and returns toagent_pendingwith corrective instructions; exceeds max retries →failedFAIL/ unparseable verdict →manual_review
Important Boundary
- The browser extension automates the
https://chatgpt.com/web UI; it is not an official ChatGPT API and relies on page DOM selectors. - Keep one
chatgpt.comtab open, logged in, visible, and with an empty composer when running tasks. - Do not use this tool to bypass authentication, CAPTCHAs, rate limits, or security prompts.
Project Structure
MCPOrchestrator/
├── mcp-server/
│ ├── requirements.txt # MCP server Python dependencies (mcp, httpx)
│ └── server.py # Stdio FastMCP server exposing MCPOrchestrator tools
├── backend/
│ ├── __init__.py
│ └── app.py # FastAPI orchestrator, SQLite schema, lease & retry logic
├── chromium-extension/ # Manifest V3 extension for Chromium browsers (v1.0.0)
│ ├── background.js # Service worker: localhost API proxy & tab lock cleanup
│ ├── bridge_utils.js # ProseMirror extraction, prompt verification, state machine
│ ├── content.js # ChatGPT DOM lifecycle, insertion, submission, capture
│ ├── coordinator.js # Serialized cross-tab lock & bounded retry/backoff tracker
│ └── manifest.json
├── firefox-extension/ # Manifest V3 extension for Firefox 109+ (v1.0.0)
│ ├── background.js
│ ├── bridge_utils.js
│ ├── content.js
│ ├── coordinator.js
│ └── manifest.json
├── tests/
│ ├── bridge.test.js # Extension unit tests (Node.js built-in node:test)
│ └── test_backend.py # Backend API & lease tests (Python unittest)
├── CONTRIBUTING.md
├── LICENSE # MIT License
├── README.md
└── requirements.txt # Backend Python dependencies
Prerequisites
- OS: Linux, macOS, or Windows
- Python: 3.11 or newer (
python3 --version/python --version) - Node.js: 20 or newer (
node --version) — only needed to run extension unit tests and syntax checks - Browser:
- Chromium-based: any Chromium-based browser
- Firefox 109+
- Safari (macOS, via Apple's web extension converter)
- AI Client: Any tool supporting MCP over stdio (any MCP-compatible AI coding client, etc.)
Step 1 — Backend Setup
1.1 Clone the repository
git clone https://github.com/engineertechlabs/MCPOrchestrator.git
cd MCPOrchestrator
1.2 Create a Python virtual environment and install dependencies
Linux / macOS:
# Create an isolated virtual environment inside .venv/
python3 -m venv .venv
# Activate the virtual environment in your current shell
source .venv/bin/activate
# Install FastAPI, Uvicorn, Pydantic, and HTTPX
pip install -r requirements.txt
Windows (PowerShell):
# Create an isolated virtual environment inside .venv\
python -m venv .venv
# Activate the virtual environment in PowerShell
.\.venv\Scripts\Activate.ps1
# Install FastAPI, Uvicorn, Pydantic, and HTTPX
pip install -r requirements.txt
1.3 Start the FastAPI backend (CLI or OS background service)
You can run the generalized CLI directly via python -m backend.cli (or install mcporchestrator into your venv with pip install -e .):
# Start in the foreground (Linux, macOS, Windows)
python -m backend.cli start
Or install it as a native user-level background service (no sudo or Administrator rights required):
- Linux:
~/.config/systemd/user/mcporchestrator.service(systemd --user) - macOS:
~/Library/LaunchAgents/com.mcporchestrator.server.plist(launchd) - Windows:
MCPOrchestratorServerin Task Scheduler (ONLOGONviapythonw.exe)
# Install and start the background service
python -m backend.cli install-service
# Check server health
python -m backend.cli status
# Stop and remove the background service
python -m backend.cli uninstall-service
(You can also pass --port, --host, --reload, or --dry-run on install-service / uninstall-service.)
Optional environment variables:
| Variable | Default | Purpose |
|---|---|---|
MCPORCH_DB |
backend/mcporchestrator.sqlite3 |
Custom path for the SQLite database file |
MCPORCH_PORT |
18421 |
Local HTTP port for the backend |
MCPORCH_API_TOKEN |
(empty) | Optional shared secret token (X-MCPOrchestrator-Token / Bearer) |
MCPORCH_MAX_RETRIES |
3 |
Maximum automatic NEEDS_REWORK retries per task |
1.4 Verify the backend is running
curl -s http://127.0.0.1:18421/health
Expected output:
{"ok":true,"service":"mcporchestrator","version":"1.0.0"}
Interactive Swagger API docs are also available at http://127.0.0.1:18421/docs.
Step 2 — Browser Extension Setup
Option A: Chromium-based browsers (any Chromium-based browser)
- Open your browser's extension page:
- Chromium:
chrome://extensions(orbrave://extensions/edge://extensions) - Brave:
brave://extensions - Edge:
edge://extensions
- Chromium:
- Enable Developer mode (top-right toggle).
- Click Load unpacked and select the
chromium-extension/folder insideMCPOrchestrator. - Open
https://chatgpt.com/, log in, and open a conversation with an empty composer.
Option B: Firefox (109+)
- Open
about:debugging#/runtime/this-firefox. - Click Load Temporary Add-on....
- Select
firefox-extension/manifest.jsoninsideMCPOrchestrator. - Open
https://chatgpt.com/, log in, and keep that tab visible with an empty composer.
Option C: Safari (macOS)
Convert the Chromium extension into a Safari Web Extension Xcode project:
xcrun safari-web-extension-converter chromium-extension/
Build and enable the resulting extension in Safari Settings → Extensions, granting access to chatgpt.com and 127.0.0.1.
Multi-Tab & Draft Safety Behavior
- Only one
chatgpt.comtab can acquire the processing lock (chrome.storage.session, 60s TTL, 20s heartbeat) at a time. - Hidden/background tabs and tabs with an existing user draft or attachment are skipped automatically and never overwritten.
- Closing, reloading, or navigating away from the active tab releases the lock immediately.
Step 3 — MCP Server Setup (Any MCP-Compatible AI Tool)
3.1 Install MCP server dependencies
With your .venv activated:
pip install -r mcp-server/requirements.txt
3.2 Add MCPOrchestrator to your AI tool's MCP configuration
Replace /ABSOLUTE/PATH/TO/MCPOrchestrator with the full path to your cloned folder.
Linux / macOS:
{
"mcpServers": {
"mcporchestrator": {
"command": "/ABSOLUTE/PATH/TO/MCPOrchestrator/.venv/bin/python",
"args": ["/ABSOLUTE/PATH/TO/MCPOrchestrator/mcp-server/server.py"],
"env": {
"MCPORCH_URL": "http://127.0.0.1:18421"
}
}
}
}
Windows (use double backslashes \\ in JSON):
{
"mcpServers": {
"mcporchestrator": {
"command": "C:\\ABSOLUTE\\PATH\\TO\\MCPOrchestrator\\.venv\\Scripts\\python.exe",
"args": ["C:\\ABSOLUTE\\PATH\\TO\\MCPOrchestrator\\mcp-server\\server.py"],
"env": {
"MCPORCH_URL": "http://127.0.0.1:18421"
}
}
}
}
Where to place this config:
- Claude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json(macOS) or%APPDATA%\Claude\claude_desktop_config.json(Windows) - Cursor / Windsurf / Cline / Claude Code: Add the
mcporchestratorblock to your tool'smcpServersJSON configuration.
Restart or reload your AI tool's MCP servers and confirm these 8 tools appear:
mcporch_create_task— Create a new task and queue its planning promptmcporch_wait_for_task— Wait until a task reachesagent_pendingor a terminal statusmcporch_task_status— Check task status, plan, report, and verification verdictmcporch_list_tasks— List recent tasksmcporch_cancel_task— Cancel an active task (manual_review)mcporch_get_task— Lease the nextagent_pendingtask (optionally filtered byproject_path)mcporch_heartbeat— Extend the active execution leasemcporch_submit_result— Submit execution summary and test evidence for verification
Step 4 — End-to-End Usage Walkthrough
4.1 Create a task
Linux / macOS:
curl -X POST http://127.0.0.1:18421/tasks \
-H 'Content-Type: application/json' \
-d '{
"title": "Add authentication",
"project_path": "/home/USER/projects/example",
"objective": "Implement registration, login, logout and password reset.",
"acceptance_criteria": [
"Registration validates email and password",
"Login creates a secure session",
"Logout invalidates the session",
"Automated tests cover success and failure cases"
]
}'
Windows (PowerShell):
$body = @{
title = "Add authentication"
project_path = "C:\Users\USER\projects\example"
objective = "Implement registration, login, logout and password reset."
acceptance_criteria = @(
"Registration validates email and password",
"Login creates a secure session",
"Logout invalidates the session",
"Automated tests cover success and failure cases"
)
} | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:18421/tasks" -ContentType "application/json" -Body $body
4.2 Let ChatGPT plan
Keep your chatgpt.com tab visible with an empty composer. Within ~3 seconds, the extension injects the planning prompt, submits it, waits for ChatGPT to finish generating, and posts the plan back to MCPOrchestrator (status becomes agent_pending).
4.3 Execute with your MCP AI agent
Prompt your MCP-connected AI agent:
Check the MCPOrchestrator MCP tools. Call
mcporch_get_taskand follow the returned task, plan, and acceptance criteria. Inspect the project before editing, create a Git checkpoint before changes, implement the task, run real tests, and callmcporch_submit_resultwith the summary, test evidence, unresolved issues, and changed files. Usemcporch_heartbeatif execution takes longer than 10 minutes.
4.4 Inspect task state and event history
# List recent tasks
curl -s http://127.0.0.1:18421/tasks | python3 -m json.tool
# Inspect a specific task (including plan, execution_report, and verification verdict)
curl -s http://127.0.0.1:18421/tasks/<TASK_ID> | python3 -m json.tool
# Inspect the full event audit trail
curl -s http://127.0.0.1:18421/tasks/<TASK_ID>/events | python3 -m json.tool
API Reference
| Method & Path | Consumer | Purpose |
|---|---|---|
GET /health |
Diagnostics | Health check ({"ok": true, "service": "mcporchestrator", "version": "1.0.0"}) |
POST /tasks |
User / CLI | Create a new task (409 if another task is still active) |
GET /tasks |
User / UI | List recent tasks (?limit=20) |
GET /tasks/{task_id} |
User / UI | Get task details (strips agent_lease_token) |
GET /tasks/{task_id}/events |
User / UI | Get ordered event log for a task |
GET /tasks/{task_id}/stream |
User / UI / CLI | Server-Sent Events (SSE) live stream of status and bridge_progress |
POST /tasks/{task_id}/followup |
User / MCP Server | Queue a follow-up question in the task's active Web AI thread |
POST /tasks/{task_id}/cancel |
User / CLI | Cancel an active task (manual_review) and free the queue |
POST /tasks/{task_id}/reset-bridge-lease |
User / CLI | Return a delivered queue item back to pending |
GET /bridge/next |
Extension | Reclaim expired leases and lease next pending prompt (?worker_id=...&host=...) |
POST /bridge/progress |
Extension | Report live Web AI generation progress (stage, chars, detail) |
POST /bridge/stalled |
Extension | Immediately requeue or escalate stalled Web AI responses |
POST /bridge/release |
Extension | Release a pre-submission lease back to pending |
POST /bridge/response |
Extension | Submit ChatGPT/Claude/Gemini response (idempotent on exact replay) |
GET /agent/next |
MCP Server | Reclaim expired agent leases and lease next agent_pending task |
POST /agent/heartbeat |
MCP Server | Extend active executing agent lease by 15 minutes |
POST /agent/report |
MCP Server | Submit implementation report (exit_code, diff_summary) and queue verify prompt |
Continuous Communication & Advanced Features
- Read Open Chat Context (
mcporch_read_chat): Instantly read the lastNmessages from your currently open ChatGPT/Claude/Gemini tab without sending a prompt. - 20s-Safe Wait Slices + Live Progress:
mcporch_wait_for_taskwaits in safe slices (default20s, max45s) and returnsstill_working=Truewith livebridge_progress(stage,chars) so IDE agents never give up on slow responses. - Multi-Turn Follow-Up (
mcporch_ask_followup): Coding agents (and the dashboard Inspect modal) can ask follow-up questions in the active Web AI thread, with fullfollowupshistory returned byGET /tasks/{task_id}. - Closed-Loop Verification: Pass
wait_for_verdict=True,exit_code, anddiff_summarytomcporch_submit_resultto receive ChatGPT's verification verdict directly. - Cross-Model Routing: Set
planner_hostandverifier_host(any,chatgpt.com,claude.ai,gemini.google.com) onPOST /tasksor in the New Task UI to plan with one AI and verify with another. - Task Dependency Chaining: Pass
depends_on_task_idonPOST /tasksto hold a task inwaiting_dependencyuntil the parent task reachescomplete. - CLI Live Watch & Extension Packaging:
.venv/bin/python -m backend.cli watch <TASK_ID>streams live SSE updates in your terminal.python3 scripts/package_extensions.pybuildsdist/mcporchestrator-chromium.zipanddist/mcporchestrator-firefox.zip.- Set
MCPORCH_WEBHOOK_URLto receive JSON webhook notifications oncomplete,manual_review, orfailed.
Testing & Validation
Run all backend and extension checks locally without modifying the live SQLite database:
# 1. Run Python backend unit tests (uses isolated temporary SQLite databases)
.venv/bin/python -m unittest discover -s tests -v
# 2. Check JavaScript syntax for both Chromium and Firefox extensions
node --check chromium-extension/*.js firefox-extension/*.js
# 3. Validate extension manifests
python3 -m json.tool chromium-extension/manifest.json > /dev/null
python3 -m json.tool firefox-extension/manifest.json > /dev/null
# 4. Run extension unit tests (normalization, verification, state machine, cross-tab lock, retries)
node --test tests/bridge.test.js
Troubleshooting
409 Conflict: Task ... is still active: The MVP intentionally allows one active task at a time so ChatGPT conversations don't cross-wire. Wait for the current task to reachcomplete,failed, ormanual_review.[MCPOrchestrator] Skipping queue poll because ChatGPT composer contains an existing draft: Clear any leftover draft or attachment in your visiblechatgpt.comtab. MCPOrchestrator will never overwrite user-authored drafts.Extension context invalidatedin browser console: Normal after clicking Reload in your browser extensions page — the old content script stops automatically; just refresh thechatgpt.comtab.- MCP tools not appearing: Verify
mcp-server/requirements.txtis installed in the exact Python interpreter referenced bycommandinmcp_config.json, then restart your MCP client.
Safety & Limitations
- Local development orchestrator: keep bound to
127.0.0.1and never expose publicly without authentication. - ChatGPT web DOM selectors may require updates if OpenAI changes
chatgpt.comfrontend markup. - Always work on a disposable Git branch or checkpoint when letting an agent modify code.
License
Released under the MIT License.
Metadata
Release files for mcporch 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcporch-1.1.0.tar.gz | 59.8 kB | Without provenance | Details for mcporch-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcporch-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for mcporch-1.1.0-py3-none-any.whl |
Total release size: 108.6 kB
Release files / mcporch-1.1.0.tar.gz
| Download URL | mcporch-1.1.0.tar.gz |
|---|---|
| Size | 59.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a14d74f179280446c21d8f90887265b19d995c9189c077f0509399e346cafc1
|
|
BLAKE2b-256 checksum How to use checksums |
4df71a618acef0aa76f0467501c516f0814469b6fa624d1010f76128a3bb21ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / mcporch-1.1.0-py3-none-any.whl
| Download URL | mcporch-1.1.0-py3-none-any.whl |
|---|---|
| Size | 48.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6de32e7fa5b26b2913551183764f9888dde0998162bfa862b3e9dd7db448999a
|
|
BLAKE2b-256 checksum How to use checksums |
5c1e8e0c6307d0a52ff43b8287669521a6ed59cc6d70dc19dde9a3cb9b3c763e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for mcporch 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.