mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Add opt-in protocol discovery for local stdio MCP servers (#57210)
## Why Stdio servers without `CODEX_MCP_PROTOCOL_VERSION` use the legacy handshake, even when they support MCP `2026-07-28`. ## What changed - Add the disabled-by-default `mcp_connection_sharing` feature to enable discovery for eligible local stdio servers. - Recover from failed or late discovery with a fresh handshake when needed, waiting for the previous helper to release resources before restarting. - Retain a working legacy connection when an upgrade attempt fails for the same account, except on authentication errors. - Keep tool catalogs separate by protocol and invalidate legacy catalogs when discovery negotiates the modern protocol. ## Testing Add regression coverage for failed and late discovery, legacy fallback, protocol-specific catalog reuse, message limits, and Windows descendant cleanup. GitOrigin-RevId: 36c675ef3b81d32fccf06ccbddda2312cfe602c9
This commit is contained in:
@@ -288,6 +288,33 @@ pub fn kill_process_group(_process_group_id: u32) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Wait up to `grace` for a signaled group's members to release their resources.
|
||||
/// After that, allow the caller to proceed. An unreaped zombie or a recycled group ID
|
||||
/// can remain visible after the original processes have released their resources.
|
||||
#[cfg(unix)]
|
||||
pub fn wait_for_process_group_exit(process_group_id: u32, grace: std::time::Duration) {
|
||||
let deadline = std::time::Instant::now() + grace;
|
||||
loop {
|
||||
#[cfg(target_os = "macos")]
|
||||
let exists = signal_process_group_with_member_fallback(
|
||||
process_group_id,
|
||||
/*signal*/ 0,
|
||||
signal_process_group_id,
|
||||
signal_process_id,
|
||||
);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let exists = signal_process_group_id(process_group_id as libc::pid_t, /*signal*/ 0);
|
||||
if matches!(exists, Ok(false)) {
|
||||
break;
|
||||
}
|
||||
let remaining = deadline.saturating_duration_since(std::time::Instant::now());
|
||||
if remaining.is_zero() {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(remaining.min(std::time::Duration::from_millis(10)));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
/// Kill the process group for a tokio child (best-effort).
|
||||
pub fn kill_child_process_group(child: &mut Child) -> io::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user