{"record":{"id":"144b4f88c609000f","repo":"openai/codex","slug":"mcp-server-server-is-running-in-environment","errorCode":null,"errorMessage":"MCP server `{server}` is running in environment `{}`, expected `{environment_id}`","messagePattern":"MCP server `(.+?)` is running in environment `(.+?)`, expected `(.+?)`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/codex-mcp/src/connection_manager.rs","lineNumber":885,"sourceCode":"    #[allow(clippy::too_many_arguments)]\n    pub async fn call_tool(\n        &self,\n        server: &str,\n        tool: &str,\n        environment_id: Option<&str>,\n        arguments: Option<serde_json::Value>,\n        meta: Option<serde_json::Value>,\n        requested_timeout: Option<Duration>,\n        wait_for_server: bool,\n    ) -> Result<CallToolResult> {\n        let view = self\n            .servers\n            .get(server)\n            .ok_or_else(|| anyhow!(\"unknown MCP server '{server}'\"))?;\n        if let Some(environment_id) = environment_id\n            && view.metadata.environment_id != environment_id\n        {\n            bail!(\n                \"MCP server `{server}` is running in environment `{}`, expected `{environment_id}`\",\n                view.metadata.environment_id\n            );\n        }\n        if !view.tool_filter.allows(tool) {\n            return Err(anyhow!(\n                \"tool '{tool}' is disabled for MCP server '{server}'\"\n            ));\n        }\n        let client = if wait_for_server {\n            view.connection\n                .client()\n                .await\n                .context(\"failed to get client\")?\n        } else {\n            let client = view\n                .connection\n                .client","sourceCodeStart":867,"sourceCodeEnd":903,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/codex-mcp/src/connection_manager.rs#L867-L903","documentation":"Error \"MCP server `{server}` is running in environment `{}`, expected `{environment_id}`\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/codex-mcp/src/connection_manager.rs:885 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reconnect the MCP server under the expected environment `{environment_id}`, or re-register the environment so the running server's environment matches."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}