Add a bounded `codex mcp check <server>` diagnostic command for MCP startup and tool discovery failures
Problem
MCP failures are currently hard for users to report in an actionable way. Many issues include variants of:
handshaking with MCP server failed: connection closed: initialize response- server works when initialized manually, but fails when launched by Codex
/mcpor the app/extension does not expose tools even though the configured server starts- stderr/log output is difficult to capture in a concise, redacted support report
codex doctor --json already helps with install/config/auth/network/local-state diagnostics, and its MCP check catches important static problems such as missing commands, missing env vars, invalid cwd, and HTTP reachability. However, it intentionally does not start stdio MCP servers or perform a protocol-level startup/tool-discovery check.
That leaves a gap between:
codex mcp list/get, which shows configured/effective MCP entries, and- a full Codex session, which may fail with a generic startup or handshake error.
Evidence / related reports
Related examples include:
- #6020: broad
initialize responsestartup failures with many comments - #17024: local stdio server starts and manually initializes, but Codex startup fails
- #6465: MCP works in CLI but not in the VS Code extension
- #21903: Streamable HTTP MCP handshake failure after initialize
- #14242 / #16689: MCP server starts but tools are not discovered or exposed
- #7155: stderr-heavy MCP servers can fail on Windows
- #1454: older, closed request mentioning MCP debugging and hidden stderr
Proposal
Add a bounded diagnostic command, for example:
codex mcp check <server>
codex mcp check <server> --json
The command would inspect one configured MCP server and perform a safe protocol-level check without starting a full Codex session.
For stdio servers, the MVP could:
- Resolve the effective config for
<server>. - Validate the same local inputs already covered by doctor where possible.
- Launch only that MCP server with a bounded startup timeout.
- Send MCP
initialize. - Send
notifications/initialized. - Call
tools/list. - Capture a small redacted stderr/stdout diagnostic excerpt.
- Terminate the subprocess cleanly.
- Report whether tools were discovered, how many, and where startup failed.
For Streamable HTTP servers, the command could start with the existing reachability probe and, if feasible, perform the equivalent bounded initialize/tools-list path.
MVP scope
- One server at a time.
- No MCP tool execution.
- No config mutation.
- No secret storage.
- No persistent MCP process.
- Human output plus
--json. - Redact paths/secrets consistently with
codex doctor --json. - Keep timeouts bounded and explicit.
Out of scope
- Lazy-loading MCP servers globally.
- Changing session startup behavior.
- Auto-repairing MCP config.
- Auto-approving MCP tool calls.
- Replacing
codex doctor.
Expected impact
This would make MCP reports much more actionable for maintainers and easier for users to self-diagnose. It also gives the issue template a clearer instruction than “try prompting Codex to use the tool” when the problem is startup/tool discovery rather than tool behavior.
Risks / tradeoffs
- Starting arbitrary stdio MCP servers has side effects, so the command should be explicit, one-server-only, timeout-bounded, and clearly documented.
- Captured stderr must be small and redacted.
- Some servers may require auth or external state; the command should report that rather than trying to solve it.
Open questions
- Should this live under
codex mcp check,codex mcp doctor, or as acodex doctor --mcp <server>mode? - Should
codex doctor --jsoninclude a hint recommendingcodex mcp check <server>when static MCP checks pass but a user reports startup failure? - Should the JSON output reuse the
DoctorCheckshape or have a separate MCP-specific report schema?
3 Comments
🔧 Solution Proposed
Here's a detailed technical analysis and proposed fix for this issue.
---
Solution: Add
codex mcp check <server>Diagnostic CommandIssue
https://github.com/openai/codex/issues/24439
Root Cause Analysis
Users have no built-in way to diagnose MCP server startup and tool discovery failures. When an MCP server fails to connect or doesn't expose tools correctly, users must manually debug by:
This is a developer experience issue — a diagnostic command would significantly reduce debugging time.
Proposed Solution
Command Design
This command performs a comprehensive diagnostic of the specified MCP server:
mcp_config.jsonImplementation
Output Format
Verification Steps
~/.codex/mcp_config.jsoncodex mcp check <server-name>Impact Assessment
Estimated Value: $1,000–$2,000
Working Implementation Available
I've implemented this feature and have a working branch ready:
rev2ret/codex:feat/mcp-check-diagnosticChanges (2 files, +392 lines)
codex-rs/cli/Cargo.toml— Addedrmcpandfuturesdependenciescodex-rs/cli/src/mcp_cmd.rs— AddedCheckArgs,McpSubcommand::Checkvariant, andrun_check()implementationWhat it does
The command performs the MVP scope described in this issue:
~/.codex/config.tomlinitialize+notifications/initializedwith a 30-second bounded timeouttools/listand displays all discovered tools with descriptionsExample output
Verified
x86_64-pc-windows-gnuwithcargo buildcodex mcp check --helpoutputs correct usageHappy to open a PR if given contributor access, or maintainers can cherry-pick from the branch directly.
I like the bounded one-server scope here. From user-side MCP troubleshooting, the most useful output would be a small phase-by-phase report rather than one generic startup error:
For Windows, it would also help if the command distinguishes quoting/path errors, missing npm/uvx/python commands, and stderr-heavy servers that close the transport. That would turn many current "MCP startup failed" reports into actionable user-side diagnostics without requiring full session startup.