openai/codex · error · anyhow::Error

MCP runtime refresh semaphore closed

Error message

MCP runtime refresh semaphore closed

What it means

Error "MCP runtime refresh semaphore closed" thrown in openai/codex.

Source

Thrown at codex-rs/core/src/session/mcp.rs:255

            )
            .await;
            refresh_invalidation.published = true;
            if !self.mcp_refresh.is_pending() {
                return;
            }
        }
    }

    /// Reconnects the runtime so refreshed Apps tools belong to their new exact client.
    pub(crate) async fn hard_refresh_latest_codex_apps_tools(
        self: &Arc<Self>,
    ) -> anyhow::Result<Vec<codex_mcp::ToolInfo>> {
        self.refresh_mcp_if_dirty().await;
        let _refresh = self
            .mcp_refresh
            .acquire()
            .await
            .map_err(|_| anyhow::anyhow!("MCP runtime refresh semaphore closed"))?;
        let auth = self.services.auth_manager.auth().await;
        let desired = self.latest_mcp_desired_state(auth).await;
        let selected_capability_roots = self
            .resolve_selected_capability_roots_for_step(&desired.environments)
            .await;
        let ready_selected_capability_roots =
            Self::ready_selected_capability_roots(&selected_capability_roots);
        let executor_capability_discovery = self
            .executor_capability_discovery_for_step(
                &desired.config,
                &ready_selected_capability_roots,
                &desired.environments,
                desired.windows_sandbox_level,
            )
            .await;
        let mcp_projection = self
            .services
            .mcp_manager

View on GitHub (pinned to 339751715c)

Solutions

  1. Restart the session; the MCP runtime refresh subsystem has shut down.

When it happens

Trigger: Thrown at codex-rs/core/src/session/mcp.rs:255 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/b4ae09ba862ac95a. Report an issue: GitHub.