gpt-codex-handoff
The gpt-codex-handoff server provides an MCP tool (ask_gpt_next_step) for Codex or any MCP-compatible client to request structured next-step recommendations from an OpenAI-powered reviewer during long-running coding tasks.
Inputs accepted:
summary(required) — current state of workchanged_files,test_results,open_questions,recent_log,diff— session contextconstraints— rules or restrictions to guide the reviewer
Structured JSON output includes:
next_step,priority,reason,should_continue,max_minutes,commands_to_run,files_to_inspect,risk_level,handoff_note
Modes:
Fake mode (
GPT_HANDOFF_REVIEWER_MODE=fake): Returns valid recommendation JSON without contacting OpenAI — useful for testing wiring.Real mode (
GPT_HANDOFF_REVIEWER_MODE=real): Uses a configuredOPENAI_API_KEYfor live AI-powered reviews.
Safety preflight: Before sending any context to the API, the tool checks for credentials, high-risk changes, ambiguous product decisions, or repeated failures. If any are detected, it returns a conservative should_continue: false response without calling OpenAI.
Integration: Register the server with Codex via a setup script so Codex can discover and call the tool directly. A diagnostic script is also available to verify the setup without exposing secrets.
Provides a tool for Codex to call an OpenAI-powered reviewer that returns structured recommendations (next step, priority, commands to run, etc.) during long-running work.
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., "@gpt-codex-handoffRecommend next step: implemented API endpoint, tests pass."
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.
GPT Codex Handoff
An MVP MCP server that gives Codex a tool named ask_gpt_next_step. Codex can call it during long-running work to ask an OpenAI-powered reviewer for a structured recommendation about what to do next.
Flow:
Codex -> MCP tool ask_gpt_next_step -> OpenAI API reviewer -> strict JSON recommendationWindows Setup
From a fresh checkout on Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"Run the tests:
python -m pytest --basetemp=".venv\pytest-tmp"PowerShell can treat brackets as wildcard syntax in some contexts, so keep ".[dev]" quoted.
Related MCP server: Codex MCP Server
Environment
Fake reviewer mode is for local wiring tests. It returns valid recommendation JSON without importing the OpenAI client, without requiring OPENAI_API_KEY, and without contacting OpenAI:
$env:GPT_HANDOFF_REVIEWER_MODE = "fake"Live reviewer calls require OPENAI_API_KEY and must not use fake mode.
Copy .env.example to .env for your own notes, or set variables in the shell that launches Codex:
$env:OPENAI_API_KEY = "sk-..."
$env:OPENAI_REVIEWER_MODEL = "gpt-4.1-mini"For Codex desktop on Windows, the most reliable real-mode setup stores OPENAI_API_KEY in .codex\.env, which is ignored by Git:
OPENAI_API_KEY=...Do not paste secrets into tool inputs, logs, diffs, or test fixtures.
Codex MCP Registration
After installing the package in the same environment Codex will use, write the repo-local Codex MCP configuration with:
python scripts\setup_codex_mcp.py --mode fakeThe script creates .codex\config.toml and points Codex at this checkout's .venv\Scripts\python.exe.
For fake mode, the generated config looks like:
[mcp_servers.gpt_codex_handoff]
command = "C:\\Users\\jiash\\OneDrive\\Documents\\GPT CodeX integration\\.venv\\Scripts\\python.exe"
args = ["-m", "gpt_codex_handoff.mcp_server"]
env = { GPT_HANDOFF_REVIEWER_MODE = "fake" }Restart Codex after changing MCP configuration so it can discover ask_gpt_next_step.
Then type /mcp in Codex chat. You should see gpt_codex_handoff as enabled. Some Codex UI versions show only the server row rather than an expandable tool list.
After /mcp shows the server, you can safely ask Codex to call the tool:
Call ask_gpt_next_step with summary="Fake-mode wiring test", changed_files=[], test_results="not run", open_questions=[], recent_log="", diff="", constraints=["Do not call OpenAI."]The response should include a handoff_note saying fake reviewer mode is enabled and no OpenAI API call was made.
Fake mode is only for wiring tests. It does not evaluate the session with a real model.
Real Mode Registration
When you are ready for real reviewer calls on Windows, run:
python scripts\setup_codex_mcp.py --mode real --write-local-envThe script reads OPENAI_API_KEY from the current shell if it is set. If it is missing, it prompts securely without echoing. It writes the key to ignored .codex\.env, never prints the key, and never writes the key value into config. In real mode, Codex still forwards the existing Windows environment variable by name when available.
The real-mode config sets:
env = { GPT_HANDOFF_REVIEWER_MODE = "real", GPT_HANDOFF_DOTENV_PATH = "C:\\absolute\\path\\to\\.codex\\.env" }
env_vars = ["OPENAI_API_KEY"]Restart Codex after running the command so the MCP process starts with the updated configuration.
Diagnose Reviewer Setup
To check local reviewer wiring without printing secrets, run:
python scripts\diagnose_reviewer_setup.pyThe diagnostic reports only safe status values, such as whether the package imports, whether real or fake mode is configured, whether OPENAI_API_KEY is present, whether GPT_HANDOFF_DOTENV_PATH is configured, whether the dotenv file exists, and whether the MCP server module is importable. It does not print the API key, dotenv path, or dotenv file contents.
Run Tests
python -m pytest --basetemp=".venv\pytest-tmp"Or, without installing the optional test runner:
$env:PYTHONPATH = "src"
python -m unittest discover -s tests -vThe tests validate schema handling and safety behavior without making real API calls.
Windows Test Troubleshooting
Use python -m pytest instead of bare pytest on Windows. It avoids PATH issues where the pytest launcher is installed in .venv\Scripts but the shell cannot find it.
If pytest reports PermissionError: Access is denied under a temp path such as AppData\Local\Temp\pytest-of-..., point pytest at a repo-local temp directory:
python -m pytest --basetemp=".venv\pytest-tmp"If .venv\pytest-tmp itself becomes locked, close stale Python or Codex processes and rerun the command, or use a fresh repo-local temp directory such as .venv\pytest-tmp-trial.
Tool
ask_gpt_next_step accepts:
summarychanged_filestest_resultsopen_questionsrecent_logdiffconstraints
It returns strict JSON:
{
"next_step": "inspect failing tests",
"priority": "high",
"reason": "The current failure blocks verification.",
"should_continue": true,
"max_minutes": 15,
"commands_to_run": ["pytest -q"],
"files_to_inspect": ["tests/test_example.py"],
"risk_level": "medium",
"handoff_note": "Focus on the failing test before editing more code."
}Example Usage
Safe Fake Reviewer
This example uses GPT_HANDOFF_REVIEWER_MODE=fake and does not need OPENAI_API_KEY:
python examples\fake_reviewer.pyThe same pattern is useful in tests:
import os
from gpt_codex_handoff.context import ReviewContext
from gpt_codex_handoff.reviewer import OpenAIReviewer
os.environ["GPT_HANDOFF_REVIEWER_MODE"] = "fake"
reviewer = OpenAIReviewer()
print(reviewer.review(ReviewContext(summary="Local dry run.")))Live Reviewer
Unset GPT_HANDOFF_REVIEWER_MODE and set OPENAI_API_KEY first. Live calls send the provided context to the OpenAI API after the local safety preflight passes.
from gpt_codex_handoff.reviewer import OpenAIReviewer
from gpt_codex_handoff.context import ReviewContext
reviewer = OpenAIReviewer()
recommendation = reviewer.review(
ReviewContext(
summary="Implemented first MCP server skeleton.",
changed_files=["src/gpt_codex_handoff/mcp_server.py"],
test_results="pytest passes",
open_questions=[],
recent_log="No errors.",
diff="",
constraints=["Do not commit."]
)
)
print(recommendation)Safety
The local preflight check stops before sending context to the API when it sees likely credentials, ambiguous product decisions, high-risk changes, or repeated failures. In those cases the tool returns a conservative JSON recommendation with should_continue: false.
Available Tools
1 toolask_gpt_next_stepC
Ask the GPT reviewer for a strict JSON next-step recommendation.
| Name | Required | Description | Default |
|---|---|---|---|
| summary | Yes | ||
| changed_files | No | ||
| test_results | No | ||
| open_questions | No | ||
| recent_log | No | ||
| diff | No | ||
| constraints | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden. It states the output is 'strict JSON' but does not disclose whether the tool is read-only, requires authentication, has rate limits, or other behavioral traits. The description is insufficient for an agent to understand side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is very concise at one sentence, but it lacks structure and critical information. It is not verbose, but conciseness should not sacrifice completeness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 7 parameters, no schema coverage, and no output schema details, the description is severely incomplete. It does not explain input parameters, output format, or how the tool fits into a workflow.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description does not mention any parameters. The agent must rely solely on parameter names and types, which may be ambiguous (e.g., 'diff', 'recent_log'). The description adds no semantic value.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool asks GPT for a strict JSON next-step recommendation. The verb+resource is specific, and there are no sibling tools to differentiate. However, it could be more precise about what constitutes a 'next-step recommendation.'
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. The description lacks context about prerequisites, typical scenarios, or when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v0.1.0- First observed
ask_gpt_next_step
TDQS
Scored across 1 tool
With only one tool, there is no possibility of confusion with other tools. The tool's purpose is distinct by default.
The single tool name is clear and uses a verb_noun pattern, but with no other tools to establish a pattern, consistency cannot be fully assessed.
A single tool is insufficient for a handoff workflow; it suggests a trivial surface that is likely to cause agent dead ends.
The server provides only a next-step recommendation tool, missing obvious related operations like context retrieval, output handling, or workflow control.
Maintenance
Related MCP Connectors
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Goal and task planning MCP for Codex and AI agents, with evidence-backed completion.
Human-in-the-loop for AI coding agents — ask questions, get approvals via Slack.
Deterministic AI code review, with an audit record. Governance inside the agent loop.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables Claude Code to delegate tasks to OpenAI's Codex CLI (GPT-5.4) with structured execution traces, parallel execution, session persistence, and adversarial code review.15MIT
- AlicenseNot gradedqualityDmaintenanceEnables Talon agents to delegate autonomous coding tasks to OpenAI Codex, supporting multi-step code operations with configurable sandboxing and approval policies.MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude Code to call OpenAI Codex for read-only design, deep reasoning, and code review tasks.20 npmMIT
- AlicenseAqualityCmaintenanceEnables Claude to delegate tasks to external coding agents (Codex or Antigravity) for independent reviews, separate quota usage, and async processing.6MIT