AI Hub MCP Server
Orchestrates OpenAI Codex CLI for read-only architecture planning, chunked backend/script/test implementation, and blocking L2 reviews, including blind-mode runs, session resume, worktree isolation, test commands, and token usage tracking.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AI Hub MCP Server scout the repo read-only, then run a blind L2 review on the diff"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
AI Hub
English | 简体中文
AI Hub is a local-first, zero-polling Multi-CLI AI Orchestrator, MCP Server & Real-Time Data Hub.
It lets a lead coding agent (such as Antigravity) delegate read-only codebase scouting to DSH CLI and heavy backend planning, chunked implementation, and double-blind L2 reviews to Codex CLI — while tracking real token usage across all three agents, enforcing local security boundaries, and persisting versioned interface contracts in SQLite.
Why AI Hub?
Save expensive lead-agent quota: Offload high-volume read-only codebase scans to fast, low-cost CLI inspectors (
dsh_inspect) and chunked backend/script/test work to dedicated backend CLIs (codex_exec_backend).True double-blind planning & review: Run independent architecture proposals (
codex_plan_backend(blind_mode=true)) and blocking L2 reviews (codex_review(blind_mode=true)) without leaking lead-agent bias.Zero-polling async wakeup: Long tasks automatically detach (
async: trueorsoft_wait_sec) and return a shell-safewait-run.mjsSSE waiter — no MCP 3-minute timeouts, nosleeppolling loops.Honest, real token accounting: Collects exact token usage from all three agents (Codex JSONL, DSH multi-frame Zstandard sessions, and Antigravity transcripts) with explicit
reportedvsunknownsemantics and strict isolation of demo runs.Local security floor by default: Loopback-only HTTP server with per-instance random session tokens, zero wildcard CORS, strict
Host/Originenforcement, CSRF-resistant writes, child env allowlists, secret redaction, and single-instance SQLite ownership locking.
Related MCP server: Agent Squad Bridge
Architecture
flowchart TB
Lead["Lead Agent (Antigravity / MCP Host)"]
MCP["AI Hub MCP Server (stdio JSON-RPC)"]
Disp["Unified Dispatcher\n(Concurrency + Canonical Workdir Write Mutex)"]
DB[("SQLite WAL + PRAGMA user_version\nruns / run_logs / contracts / contract_revisions")]
HTTP["Loopback HTTP + SSE Server (127.0.0.1)\nRandom Token Auth + Host/Origin Guard"]
UI["Live Dashboard\n(Embedded MCP App & Standalone Browser)"]
Wait["wait-run.mjs\n(Zero-Polling SSE Wakeup)"]
Codex["Codex CLI Adapter\n(plan / exec / L2 review)\nEnv Allowlist + JSONL Usage"]
DSH["DSH CLI Adapter\n(L1 Read-Only Scout + Git Guard)\nMulti-Frame Zstd Usage"]
Usage["Usage Collectors\n(Transcript + Zstd + Backfill)"]
Lead <-->|MCP Tools & App| MCP
MCP --> Disp
Disp --> Codex
Disp --> DSH
Codex --> DB
DSH --> DB
Usage --> DB
MCP --> DB
DB --> HTTP
HTTP <-->|X-AI-Hub-Token / SSE| UI
HTTP <-->|Bearer Token / SSE| WaitKey Features (v2.0.0)
1. Multi-CLI Orchestration & Adapter Registry
Formal adapter descriptors in
src/adapters.mjs(antigravity,codex,dsh) declaring capabilities, sandbox policy, allowed child env prefixes, and usage sources, exposed viaGET /api/adapters.Canonical worktree write mutex in
src/dispatch.mjsprevents concurrent write jobs from colliding in the same repository (including subdirectories and symlinks), while exempting isolated--worktreeruns.Configurable Persona Presets (
defaultneutral open-source labels vsneon-trio) switchable from Dashboard Settings orAI_HUB_PERSONA.
2. Real Token Usage Across All 3 Agents
Agent | Usage Source | Accounting Semantics |
Codex CLI | Native JSONL stream | Distinguishes explicitly reported |
DSH CLI | Local | Sums |
Antigravity | Local | Sums |
Idempotent historical backfill runs on primary startup and on-demand via
POST /api/usage/backfill(app_backfill_usage).Query aggregated usage & delegation ratio via
GET /api/usage?window=24h|7d|30d|allor MCPhub_get_usage. Demo runs are isolated intototals.demo_runs.
3. Versioned Contracts & Decision / Pitfall Log
Transactional SQLite schema migrations (
PRAGMA user_version0 → 1 → 2).Categorize shared project knowledge by
kind:contract|decision|pitfall|guardrail, scoped byworkspace_id.Immutable
contract_revisionshistory with optimistic concurrency control (expected_revision→409 CONFLICT).
4. Security Floor
Loopback HTTP Auth: Generates a 32-byte random hex token written atomically (
0600) to<dataDir>/hub-auth.json. RemovesAccess-Control-Allow-Origin: *, validatesHostandOrigin(403 FORBIDDEN), requiresAuthorization: BearerorX-AI-Hub-Tokenon allPOSTendpoints (CSRF-resistant), and aborts>1 MBpayloads with413+ graceful socket close.Subprocess Isolation & Redaction:
src/security.mjspasses only an explicit environment allowlist per runner (never leaking unrelated host credentials) and redacts API keys, Bearer tokens, and PEM private keys before SQLite persistence.Single-Instance Ownership Lock:
<dataDir>/hub.lockprevents a secondary MCP instance from erroneously failing liverunningtasks owned by an active instance.
Requirements
Node.js
^22.15.0 || >=23.8.0(uses built-innode:sqliteand nativenode:zlibZstandard decompression; zero native C++ addons to compile).Optional CLIs on
PATH(or configured via Settings /extraPaths/AI_HUB_EXTRA_PATHS):codex(OpenAI Codex CLI)dsh(DeepSeek Harness CLI)Or toggle Demo Mode to explore the full hub workflow without local CLIs.
Quick Start
git clone https://github.com/Siq5005/ai-hub.git
cd ai-hub
npm install
npm run build
npm test
npm run check:releaseVerification & Release Commands
Command | What It Does |
| Bundles the single-file Dashboard HTML and stages the complete plugin into |
| Runs all 28 live end-to-end mechanical guard checks ( |
| Verifies version alignment, required OSS files, staged artifacts, and zero personal paths/secrets |
| Atomically deploys |
Configuration
Copy and adapt config.example.json into your data directory (default ~/.gemini/config/plugins/ai-hub/data/config.json, or override via AI_HUB_DATA_DIR).
Key environment overrides (never written back into config.json):
AI_HUB_DATA_DIR— custom SQLite/config directoryAI_HUB_HTTP_PORT— preferred loopback HTTP port (default19889, auto-fallback if occupied)AI_HUB_PERSONA—defaultorneon-trioAI_HUB_EXTRA_PATHS— delimiter-separated absolute directories appended to CLI lookupPATHAI_HUB_DEPLOY_DIR— custom plugin install target fornpm run deploy
MCP Tools & HTTP API Reference
MCP Tools
Tool | Description |
| Open the real-time Dashboard ( |
| Report lead agent state ( |
| Run strictly read-only L1 codebase scouting, style, or security audits |
| Run read-only architecture planning (supports |
| Run chunked backend/script/test implementation ( |
| Run L2 blocking review ( |
| Create or revise a versioned contract, decision, pitfall, or guardrail ( |
| List compact contracts filtered by |
| Return multi-agent status, CLI health, and recent runs |
| Return real usage & delegation analytics ( |
Loopback HTTP Endpoints (127.0.0.1:<port>)
GET /health— minimal liveness probe ({ ok, service, version }, unauthenticated)GET /— standalone Dashboard (setsHttpOnly; SameSite=Strictcookie +<meta name="ai-hub-token">)GET /api/state·GET /api/events(SSE) ·GET /api/adapters·GET /api/usage?window=7dGET /api/runs/:id·GET /api/contracts·GET /api/contracts/:idPOST /api/dispatch·POST /api/runs/:id/kill·POST /api/config·POST /api/contracts·POST /api/usage/backfill·POST /api/clear
Roadmap
v2.1 · Dashboard Visual & UX Overhaul (Next): Redesign the Dashboard UI with richer visual hierarchy, interactive run diff/log viewer, contract revision diff view, responsive layout polish, and smoother motion.
v2.2 · Pluggable External CLI Adapters: Declarative custom CLI adapter definitions (Claude Code, Gemini CLI, OpenCode, etc.) via config without code changes.
v2.3 · Workspace Context Packs: One-click export/injection of active contracts, decisions, and pitfall guardrails when starting fresh agent sessions.
Contributing & License
Contributions, bug reports, and ideas are warmly welcome — see CONTRIBUTING.md.
Released under the MIT License.
Available Tools
18 toolsapp_backfill_usageApp: Backfill Historical Token UsageA
App-only tool to backfill unreported DSH and Antigravity token usage from local session logs.
Inputs: no named parameters.
app_clear_historyApp: Clear Completed RunsB
App-only tool to clear completed runs and logs.
Inputs: no named parameters.
app_get_contractApp: Fetch Full Contract DetailB
App-only tool returning full contract content by ID.
Inputs: id (required).
app_get_dashboard_stateApp: Fetch Live Dashboard StateB
App-only tool returning the latest full AI Hub snapshot.
Inputs: no named parameters.
app_get_run_logsApp: Fetch Run Detail & LogsB
App-only tool returning detailed output and streaming logs for a specific run.
Inputs: run_id (required).
app_kill_runApp: Force Kill Running TaskB
App-only tool to terminate an active Codex or DSH background task.
Inputs: run_id (required).
app_quick_dispatchApp: Quick Dispatch TaskC
App-only tool to trigger a background DSH inspection or Codex plan directly from the dashboard UI.
Inputs: kind (required), prompt (required), title, workdir, +3 more.
app_update_configApp: Save CLI & Hub ConfigurationC
App-only tool updating CLI paths, runner settings, demo mode, or agent persona.
Inputs: dsh, codex, persona, demoMode, +4 more.
codex_exec_backendDispatch Backend Execution to CodexA
Dispatch a self-contained, interface-locked backend implementation and unit-testing task to the local Codex CLI (GPT 6.2-sol) using --sandbox workspace-write. Supports resume_session_id, use_worktree, and auto-detaches before MCP timeout with wait_cmd for reactive wakeup.
Inputs: prompt (required), async, title, workdir, +6 more.
codex_plan_backendDispatch Backend Planning to CodexB
Dispatch a read-only backend architecture/implementation planning task to the local Codex CLI (GPT 6.2-sol) using --sandbox read-only. Set blind_mode=true for independent double-blind planning from the user original words (no orchestrator draft/bias). Auto-detaches before MCP timeout with wait_cmd for reactive wakeup.
Inputs: prompt (required), async, title, workdir, +5 more.
codex_reviewDispatch L2 Blocking / Double-Blind Review to CodexA
Run independent L2 red-line review or double-blind code/document/RFC review via Codex CLI (GPT 6.2-sol). Set blind_mode=true for strict double-blind review (pass only objective target/background, never orchestrator findings or bias). Use scope="files" + target_paths to blind-review specific files, docs, or RFCs even outside git repos. Auto-detaches before MCP timeout with wait_cmd.
Inputs: async, scope, title, prompt, +8 more.
dsh_inspectDispatch Read-Only Inspection to DSHB
Dispatch a fast, strictly read-only inspection, code review, security check, or pre-flight codebase scout task to the local DSH CLI (DeepSeek v4.1 Flash). Streams progress into the AI Data Hub and verifies no files were modified.
Inputs: prompt (required), async, title, workdir, +4 more.
hub_create_contractCreate or Update Shared API ContractB
Create or revise a shared contract, decision, pitfall, or guardrail. Pass expected_revision to guard against concurrent edits.
Inputs: title (required), content (required), id, kind, +5 more.
hub_get_summaryGet AI Hub Status SummaryA
Return a concise status summary of all three agents, CLI health, recent runs, and active contracts.
Inputs: no named parameters.
hub_get_usageGet AI Hub UsageB
Return real run and token usage, with a separate demo run count.
Inputs: window.
hub_list_contractsList Shared Contracts and Decision LogsC
List compact contract and decision log entries. Filter by workspace, kind, or status.
Inputs: kind, status, workspace_id.
hub_sync_agent_statusSync Orchestrator / Frontend Agent StatusB
Report Antigravity (氖基米) live working status, current frontend/orchestration task, or model tier into the AI Data Hub. Automatically creates/closes real run records and logs so 氖基米 appears live on the dashboard and accumulates run metrics.
Inputs: status (required), notes, workdir, tokens_in, +3 more.
open_ai_hubAI 中台B
Open the live AI Data Hub dashboard displaying status, streaming logs, contracts, and metrics for Antigravity, Codex, and DSH.
Inputs: tab.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
The four dispatch tools (dsh_inspect, codex_plan_backend, codex_exec_backend, codex_review) are well separated by agent and sandbox mode, but the app_* and hub_* families overlap heavily: hub_get_summary vs app_get_dashboard_state, hub_list_contracts vs app_get_contract, app_quick_dispatch vs dsh_inspect/codex_plan_backend, and hub_get_usage vs app_backfill_usage. The 'app-only' label helps an agent exclude some tools, but boundaries between read/status tools remain fuzzy.
Names use several prefixes (hub_, app_, codex_, dsh_) plus a bare open_ai_hub, and verbs are mostly verb_noun but not uniformly (hub_sync_agent_status vs codex_plan_backend vs app_kill_run). The grouping by prefix is readable and intentional, but it is a mixed convention rather than a single predictable pattern.
18 tools is on the heavy side, and roughly half are app-only UI helpers (dashboard state, logs, config, kill, clear) that inflate the surface for an agent. The dispatch and contract tools each earn their place, but the set is borderline for the stated scope.
The domain (agent dispatch, review, status reporting, contracts, usage, run control) is broadly covered: dispatch in read-only and write modes, review, contract create/revise and list, summaries, usage, config, kill and clear. Minor gaps exist, such as no general (non-app) tool to fetch a single contract by ID or to list runs individually.
Maintenance
Related MCP Connectors
Context, runtime and review for AI coding agents. One local install.
Coordination hub for AI coding agents: message teammates, ask humans, audit every event.
The team layer for AI coding agents: shared contracts, collision alerts, E2EE sessions.
Command center for developers coordinating AI coding agents across projects.
Related MCP Servers
- AlicenseBqualityBmaintenanceLocal-first Agent OS that wraps Claude Code, Codex CLI, and other coding agents in a replayable Seed → Ledger → Runtime contract, driven by an interview → seed → execute → evaluate → evolve workflow loop.3421,848 PyPI6,405MIT
- AlicenseNot gradedqualityDmaintenanceEnables multiple AI coding CLIs (Claude Code, Gemini/Antigravity, Codex, and OpenCode) to collaborate as a coordinated team by routing cross-agent prompts, sharing messages and review tickets, tracking tasks on a shared store, and isolating each agent in its own Git worktree with turn-budget safeguards—all inspectable and steerable from a local web dashboard.MIT
- AlicenseNot gradedqualityCmaintenanceEnables users to delegate coding tasks in a chosen project to the official Codex and Claude CLI agents from within an existing chat, then convene a council of configured models to gather independent opinions and review the resulting files and test runs. It also manages multi-provider API connections, model catalogs, and per-task token, time, and cost limits.MIT
- AlicenseNot gradedqualityBmaintenanceFile ownership for the coding agents you already run: claims, port and install locks, and checked integration. Local MCP server and CLI, no hosted service.551 npm4MIT