Codex Gemini Delegator V2
Allows delegation of coding tasks to Google Gemini (Antigravity) workers, managing isolated Git worktrees, monitoring execution, and applying their results.
Click on "Install 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., "@Codex Gemini Delegator V2Delegate the API refactor to Gemini and apply the result when ready."
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.
Codex Gemini Delegator V2
A robust, production-ready MCP (Model Context Protocol) server that allows OpenAI Codex to supervise and delegate tasks to Google Gemini (Antigravity) workers as subordinate agents.
Unlike other bridges, this delegator treats Gemini workers as resilient background jobs. It orchestrates isolated Git worktrees, enforces strict security boundaries, monitors stream-json for infinite loop failures, and auto-nudges stuck workers to unblock them.
Key Features
True Git Worktree Isolation: When Codex delegates a task, the delegator automatically spawns an invisible Git worktree (
.worktrees/wt-<uuid>). Gemini executes its code changes strictly inside this isolated environment. Your main branch remains completely untouched until Codex explicitly applies the run.First-Party API Alignment: This MCP server exposes the exact tool names and signatures expected by mainstream Codex delegators (
delegate_to_agent,apply_agent_run,get_agent_run_report, etc.).Loop Detection & Auto-Nudging: Built-in state heuristics actively monitor the
stream-jsonoutput of the Gemini worker. If the worker gets stuck in an infinite tool failure loop or tries the exact same broken command 3 times in a row, the Supervisor forcefully restarts it with a recursive--session-idand a strict system nudge to change strategies.Symlink-Resistant Security Boundaries: Subordinate workers are hardened against path traversal and symlink vulnerabilities. A custom hook (
enforce_boundaries.py) prevents them from executing destructive commands (rm -rf,git reset) and strictly jails their write access to their delegated scope.SQLite WAL Persistence: All runs, PIDs, and logs are tracked in a lightning-fast SQLite WAL ledger. If you close your Codex session, the Gemini workers keep running in the background and their state is fully recoverable.
Related MCP server: unlimited-mcp
Prerequisites
Google Antigravity (
geminiCLI) installed globally.Python 3.10+
Codex CLI (
codex)
Installation & Bootstrapping
Clone the repository:
git clone https://github.com/psychofanplays/gemini4codex-mcp.git cd gemini4codexRegister the MCP Server in Codex using
uv: Add the following to your~/.codex/config.toml(or equivalent Codex MCP configuration). We highly recommend usinguvto automatically manage the environment and dependencies:[mcp.servers.gemini-delegator] command = "uv" args = [ "--directory", "/ABSOLUTE/PATH/TO/gemini4codex", "run", "-m", "server.gemini_delegator" ]Provide Codex with the Bootstrapping Instructions: Once connected, you must instruct Codex to read the
BOOTSTRAP.mdfile located in this repository. This file provides Codex with the explicit instructions on how to structure the Multi-Agent Hierarchy and how to leveragegemini-3.1-proandgemini-3.6-flashas subordinate agents.Example Prompt for Codex:
"I have just connected the gemini-delegator MCP server. Please read the
BOOTSTRAP.mdfile in the gemini4codex repository and apply the agent synergy patterns to your global memory."
How It Works
When Codex is connected to the MCP server, it gains access to the following tools:
list_agent_backends: Verifies the Gemini CLI and DB are healthy.list_agent_runs: Displays all active, idle, and failed background workers.delegate_to_agent: Spawns a new Gemini worker inside a new UUID Git Worktree.continue_agent_run: Sends a follow-up instruction to an existing worker.get_agent_run_report: Returns the worker's JSON logs, execution status, and importantly, the raw Git diff of what the worker changed inside its worktree.apply_agent_run: Performs a squash merge of the worker's temporary worktree into your main branch.cleanup_agent_run: Cancels a running worker and deletes its isolated worktree.
Example Workflow (From Codex's Perspective)
Codex: "I need to refactor the database schema, but I don't want to break the app. I'll delegate this to a Gemini worker."
Codex calls
delegate_to_agent(worker_id="db-refactor", workspace_path=".")Delegator Server creates
.worktrees/wt-5f8a9b2cand runs thegoogle.antigravitySDK in-process inside it.Gemini works in the background, modifying files. If it loops or gets stuck, the Supervisor auto-nudges it.
Codex periodically calls
get_agent_run_report("db-refactor").Codex reads the
git diffreturned by the report. "Looks good, the tests passed."Codex calls
apply_agent_run("db-refactor").Delegator Server squash merges the changes cleanly into the main branch but explicitly leaves them staged (no auto-commit), allowing Codex or the human user to review and finalize the commit.
Security
This plugin aggressively restricts the Gemini subordinate worker:
True OS Sandboxing: The Delegator explicitly prevents subordinate workers from bypassing the Antigravity OS sandbox, meaning they are natively isolated from the filesystem at the kernel level and cannot modify files outside the delegated scope.
Git Sandboxing: Workers are forbidden from running structural git commands (
git commit,git push,git merge) or destructive operations (rm -rf).Profile Segregation: You can delegate a
scoutorreviewerprofile, which disables all write tools completely.
Architecture Map
The project is structured into three main layers:
gemini4codex/
├── pyproject.toml # Python packaging and dependency config
├── BOOTSTRAP.md # Essential instructions for Codex on how to use these agents
└── server/
├── gemini_delegator.py # The FastMCP Server exposing endpoints to Codex
├── supervisor.py # Async execution engine; parses stream-json & detects loops
├── worktree.py # Git worktree isolation and squash-merge orchestrator
├── security.py # Dynamic SDK hooks to jail the worker
└── ledger.py # SQLite WAL state manager for robust persistenceLayer 1: The Codex Interface (
gemini_delegator.py) handles all incoming MCP requests.Layer 2: The Orchestrator (
worktree.py&supervisor.py) spins up the isolated environment and runs the process asynchronously via the Antigravity SDK.Layer 3: The Jailed Subordinate (
security.py) restricts the worker's context natively so it cannot harm the host system or primary branch.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityBmaintenanceAn MCP server that wraps the OpenAI Codex SDK to deploy multiple specialized AI agents with individual configurations for models, sandboxing, and behavior. It enables users to manage dedicated tools for tasks like code review and test writing through a customizable agent factory.22517ISC
- Alicense-qualityBmaintenanceAn MCP server that delegates coding and sysops work to cheaper agents via durable background queues, with git worktree isolation, safety policies, and clarification rounds to avoid hitting limits of frontier models.2Apache 2.0
- AlicenseAqualityCmaintenanceA local MCP server that lets Claude delegate scoped work to Codex with structured results and guardrails, supporting planning, code review, build, reverse engineering, and long-running background tasks.11MIT
- Alicense-qualityBmaintenanceMCP server wrapping OpenAI Codex SDK to run Codex agents for code generation, debugging, and more, authenticating via ChatGPT OAuth.38MIT
Related MCP Connectors
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
An MCP server that gives your AI access to the source code and docs of all public github repos
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/psychofanPLAYS/gemini4codex-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server