MCP Code Executor

Real-Time Multi-Model Consultation via Model Context Protocol

Back to AI Review Board Architecture

Request/Response Flow

Claude Code CLI Opus 4.5 dispatch_to_reviewboard() swarm_health() MCP Code Executor localhost:9091 /reviewboard/dispatch /reviewboard/health mcp-net (Docker Network) reviewboard-gemini Gemini 2.5 Flash :8080/execute PRIMARY reviewboard-codex OpenAI ChatGPT :8080/execute ALTERNATE reviewboard-claude Claude Sonnet 4.5 :8080/execute DEEP ANALYSIS FastAPI HTTP Adapters Wraps CLI tools (gemini, codex, claude) as HTTP services /workspace (Read-Only Volume) Mounted from: $HOME/projects All nodes can read project files but cannot modify 1. MCP Request 2. HTTP POST 3. JSON Response 4. MCP Response Flow Legend Request flow Response flow Alternative target Default Timeout 15 minutes 900 seconds

Dispatch Sequence

1

Claude Code Invokes MCP Tool

User asks Claude a question. Claude decides to consult an external AI and calls dispatch_to_reviewboard with a prompt and target.

mcp__code-executor__dispatch_to_reviewboard({ "prompt": "Review /workspace/reviewboard/server.py for security issues", "target": "gemini", "timeout": 900 })
2

MCP Server Receives Request

The MCP code-executor server (localhost:9091) receives the request via stdio transport and parses the JSON parameters.

// executor.ts - /reviewboard/dispatch endpoint const SWARM_NODES = { gemini: 'http://reviewboard-gemini:8080', codex: 'http://reviewboard-codex:8080', claude: 'http://reviewboard-claude:8080' };
3

HTTP POST to Swarm Node

MCP server sends HTTP POST to the target container via Docker's internal DNS (mcp-net network).

POST http://reviewboard-gemini:8080/execute Content-Type: application/json { "prompt": "Review /workspace/reviewboard/server.py...", "working_dir": "/workspace" }
4

FastAPI Adapter Executes CLI

The FastAPI adapter inside the container spawns the CLI tool (gemini/codex/claude) with the prompt and captures output.

# adapter.py - gemini example proc = await asyncio.create_subprocess_exec( "gemini", "-p", prompt, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, cwd=working_dir ) stdout, stderr = await proc.communicate()
5

AI Reads Files & Responds

The AI model reads files from /workspace (if requested), processes the prompt, and generates a response. The adapter captures the output.

6

JSON Response Returned

The response flows back through the chain: Adapter -> MCP Server -> Claude Code CLI. Claude presents the result to the user.

{ "target": "gemini", "success": true, "result": "After reviewing server.py, I found the following...", "metrics": { "executionTime": 12500, "model": "gemini-2.5-flash" } }

MCP API Endpoints

POST /reviewboard/dispatch

Dispatch a prompt to an AI Board node for execution.

// Request Body { "prompt": string, // The task/question to send "target": "gemini" | "codex" | "claude", "timeout": number, // Seconds (default: 900) "working_dir": string // Default: /workspace } // Response { "success": boolean, "result": string, "error": string | null, "metrics": { "executionTime", "model" } }
GET /reviewboard/health

Check health status of all swarm nodes.

// Response { "swarm": { "gemini": { "status": "healthy", "node_type": "gemini" }, "codex": { "status": "healthy", "node_type": "codex" }, "claude": { "status": "healthy", "node_type": "claude" } }, "healthyNodes": 3, "totalNodes": 3 }

Usage Patterns

Code Review

// Ask Gemini to review code dispatch_to_reviewboard({ prompt: "Review the code in /workspace/myproject/src/ for security issues. Read the files first.", target: "gemini" })

Second Opinion

// Get alternate perspective dispatch_to_reviewboard({ prompt: "Gemini suggested using Redis. What's your perspective on Redis vs PostgreSQL for session storage?", target: "codex" })

Internet Research

// Gemini has web access dispatch_to_reviewboard({ prompt: "Search for the latest Docker security best practices in 2025", target: "gemini" })

Deep Analysis

// Complex reasoning with Claude dispatch_to_reviewboard({ prompt: "Analyze the architecture in /workspace/reviewboard and suggest improvements for scalability", target: "claude" })

Which Node to Use?

Need External Opinion? Need internet search? Gemini answer satisfactory? Need complex reasoning? Use Gemini Primary consultant + Internet access Use Gemini Code review Second opinion Use Codex Alternate view 3rd opinion Use Claude Deep analysis Architecture Yes Yes No Yes Pattern: Gemini first -> If unsatisfactory, try Gemini again -> If still stuck, ask Codex -> Claude for deep analysis