Connect Codex Desktop MCP over Unix sockets (#63497)

## Why

An SSH forward can replace its Unix socket listener while the old
keep-alive connection remains open. Reusing that connection can leave
MCP requests waiting on the old listener.

## What changed

Route `codex-desktop://<uuid>` endpoints to the corresponding Unix socket
for local `codex_app` servers with explicit HTTP authorization. Allow
`http_headers_helper` to supply supplemental headers while preserving the
configured authorization. Socket requests bypass proxies, strip
`Proxy-Authorization`, and disable redirects.

Reuse pooled connections while the socket is unchanged and discard them
when the listener is replaced or the socket disappears.

## Testing

Add coverage for authenticated Desktop startup, rejection of helper-only
authorization and other server names, and reconnection after socket
replacement while the previous connection remains open.

GitOrigin-RevId: a38e55d8cd726299506b487d1223fe64bd856e80
This commit is contained in:
Brent Traut
2026-11-24 02:20:22 +00:00
committed by copyberry
parent 188940258d
commit 6aaf2a86b1
10 changed files with 270 additions and 14 deletions
@@ -79,6 +79,16 @@ pub(crate) struct RouteAwareHttpRequestRunner {
}
impl RouteAwareHttpClient {
/// HTTP over a local socket never follows redirects to another server.
#[cfg(unix)]
pub fn for_unix_socket(factory: HttpClientFactory, path: std::path::PathBuf) -> Self {
let pool = RouteAwareClientPool::for_unix_socket(factory, path);
Self {
follow_redirects: pool.clone(),
stop_redirects: pool,
}
}
pub fn new(http_client_factory: HttpClientFactory) -> Self {
Self {
follow_redirects: RouteAwareClientPool::with_chatgpt_cloudflare_cookies_without_request_logging(