openai/codex · error

hosted MCP event server was removed

Error message

hosted MCP event server was removed

What it means

Error surfaced by McpEventStream::recv: the watch channel signaled that the hosted event server backing this subscription was removed, so the stream can no longer deliver notifications and is terminated with this error instead of returning None silently.

Solutions

  1. Re-register or reconnect the hosted MCP event server and retry the operation.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at codex-rs/codex-mcp/src/resource_client.rs:88 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/6b9cf6c50795eea4. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/codex-mcp/src/resource_client.rs:88

    request: Option<CancellableEventStreamRequest>,
    runtime_handle: Handle,
    connection: Option<Arc<McpServerConnection>>,
    hosted_event_server_removals: watch::Receiver<()>,
}

impl McpEventStream {
    /// Receives the next raw lifecycle notification for this subscription.
    pub async fn recv(&mut self) -> Result<Option<McpEventNotification>> {
        let Some(request) = self.request.as_mut() else {
            return Ok(None);
        };

        tokio::select! {
            biased;

            Ok(()) = self.hosted_event_server_removals.changed() => {
                self.cancel();
                Err(anyhow!("hosted MCP event server was removed"))
            }
            Some(notification) = request.notifications.recv() => {
                let metadata = notification.get_meta().0.0.clone();
                let mut params = notification.params;
                if !metadata.is_empty() {
                    params.get_or_insert_with(|| json!({}))["_meta"] = Value::Object(metadata);
                }
                Ok(Some(McpEventNotification {
                    method: notification.method,
                    params,
                }))
            }
            response = &mut request.handle.rx => {
                self.request = None;
                self.connection = None;

                match response {
                    Ok(Ok(_))

View on GitHub (pinned to 339751715c)