Files
codex/codex-rs
thomas bfe3c82570 Broaden legacy fallback for MCP discovery over HTTP (#62893)
## Why

Legacy MCP servers can reject `server/discover` before JSON-RPC dispatch
because they require a session ID or reject the requested protocol version.
Their HTTP 400 response can be empty or lack a matching JSON-RPC request ID,
leaving Codex unable to start the legacy handshake.

## What changed

Retry with a sessionless `initialize` when the initial sessionless
`server/discover` receives HTTP 400 without an authentication challenge or
a JSON-RPC error code that requires validation. Preserve fallback for
recognized legacy rejections and give structured protocol version offers
precedence over error text. Once a server offers a modern version, surface
a rejected follow-up probe as a discovery failure.

## Testing

Extend mock-server coverage to verify that legacy fallback establishes a
fresh session and uses it for `tools/list`. Cover authentication challenges,
malformed and uncorrelated JSON-RPC errors, and failures after a modern
version offer.

GitOrigin-RevId: edc573e38c63b837462f1b8d84e2d8abdf62cb3e
2026-11-21 03:51:15 +00:00
..
…
…
…