Skip to content

Codex stdio handshake fails: connection closed during initialize #219

@feliche93

Description

@feliche93

Summary

When Codex (OpenAI's CLI client) launches @sylphx/pdf-reader-mcp over stdio, the handshake fails immediately with connection closed: initialize response. Running the same command manually works fine.

Reproduction

  1. Add this entry to ~/.codex/config.toml:
    [mcp_servers.pdf_reader_mcp]
    command = "bunx"
    args = ["-y", "@sylphx/pdf-reader-mcp"]
    startup_timeout_sec = 30
  2. Start Codex CLI and run /mcp (or codex mcp list).
  3. Codex logs show WARN MCP client for 'pdf_reader_mcp' failed to start: handshaking with MCP server failed: connection closed: initialize response.

Additional Context

  • Running bunx -y @sylphx/pdf-reader-mcp manually and piping JSON-RPC (e.g., tools/list) succeeds and returns the tool definition.
  • Codex newest MCP client is enabled via [features].rmcp_client = true.
  • ~/.codex/log/codex-tui.log only logs the generic warning; no extra stack trace appears.
  • codex mcp list with CODex_MCP_LOG=trace currently panics in the Rust system-configuration crate, so it’s hard to collect more traces.

Is there anything we should tweak on the server side (e.g., flush stderr, disable some capability), or is this a known incompatibility with Codex’s stdio startup? Any guidance would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions