{"record":{"id":"b6609234417f72a8","repo":"openai/codex","slug":"mcp-client-not-initialized","errorCode":null,"errorMessage":"MCP client not initialized","messagePattern":"MCP client not initialized","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/rmcp-client/src/rmcp_client.rs","lineNumber":928,"sourceCode":"        let handle = service\n            .peer()\n            .send_cancellable_request(\n                ClientRequest::CustomRequest(request),\n                rmcp::service::PeerRequestOptions::no_options(),\n            )\n            .await?;\n\n        Ok(CancellableEventStreamRequest {\n            handle,\n            notifications,\n        })\n    }\n\n    async fn service(&self) -> Result<Arc<RunningService<RoleClient, ElicitationClientService>>> {\n        let guard = self.state.lock().await;\n        match &*guard {\n            ClientState::Ready { service, .. } => Ok(Arc::clone(service)),\n            ClientState::Connecting { .. } => Err(anyhow!(\"MCP client not initialized\")),\n            ClientState::Closed => Err(anyhow!(\"MCP client is shut down\")),\n        }\n    }\n\n    async fn oauth_persistor(&self) -> Option<OAuthPersistor> {\n        let guard = self.state.lock().await;\n        match &*guard {\n            ClientState::Ready {\n                oauth: Some(runtime),\n                ..\n            } => Some(runtime.clone()),\n            _ => None,\n        }\n    }\n\n    /// Returns `None` when this client does not manage stored OAuth credentials.\n    pub async fn managed_oauth_credentials(&self) -> Option<Option<StoredOAuthTokens>> {\n        let persistor = self.oauth_persistor().await?;","sourceCodeStart":910,"sourceCodeEnd":946,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/rmcp-client/src/rmcp_client.rs#L910-L946","documentation":"State-machine guard in the internal service() accessor: the client is not in the Ready state (still connecting or already closed), so the request cannot be sent. The input at fault is a request issued before initialize completed or after shutdown.","triggerScenarios":"Thrown at codex-rs/rmcp-client/src/rmcp_client.rs:928 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Await initialize before issuing requests such as custom/event-stream calls","Recreate the client if it was shut down"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}