{"record":{"id":"68653bb8b9c8e2eb","repo":"Kuberwastaken/claurst","slug":"mcp-client-backend-missing","errorCode":null,"errorMessage":"MCP client backend missing","messagePattern":"MCP client backend missing","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-rust/crates/mcp/src/lib.rs","lineNumber":588,"sourceCode":"                tools: snapshot.tools,\r\n                resources: snapshot.resources,\r\n                prompts: snapshot.prompts,\r\n                instructions: snapshot.instructions,\r\n                backend: None,\r\n            }\r\n        }\r\n\r\n        fn from_backend(backend: Arc<dyn backend::McpClientBackend>) -> Self {\r\n            let snapshot = backend.snapshot();\r\n            let mut client = Self::from_snapshot(snapshot);\r\n            client.backend = Some(backend);\r\n            client\r\n        }\r\n\r\n        fn backend(&self) -> anyhow::Result<&Arc<dyn backend::McpClientBackend>> {\r\n            self.backend\r\n                .as_ref()\r\n                .ok_or_else(|| anyhow::anyhow!(\"MCP client backend missing\"))\r\n        }\r\n\r\n        pub async fn connect(config: &McpServerConfig, auth_token: Option<String>) -> anyhow::Result<Self> {\r\n            match config.server_type.as_str() {\r\n                \"stdio\" => Self::connect_stdio(config).await,\r\n                \"sse\" => {\r\n                    let backend = crate::rmcp_backend::RmcpClientBackend::connect_legacy_sse(\r\n                        config,\r\n                        auth_token,\r\n                    )\r\n                    .await?;\r\n                    Ok(Self::from_backend(Arc::new(backend)))\r\n                }\r\n                \"http\" => {\r\n                    let mut last_error = None;\r\n                    for &protocol_version in transport::STREAMABLE_HTTP_PROTOCOL_VERSIONS {\r\n                        let protocol_version = serde_json::from_value::<rmcp::model::ProtocolVersion>(\r\n                            Value::String(protocol_version.to_string()),\r","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/mcp/src/lib.rs#L570-L606","documentation":"McpClient is a lazy wrapper that may be constructed without an actual transport backend (the `backend: Option<Arc<dyn McpClientBackend>>` is None). Any operation requiring the backend calls `backend()` which returns this error, indicating the client was never successfully connected or the backend was not initialized.","triggerScenarios":"Calling call_tool/list_tools/other backend-dependent methods on an McpClient created without connect (e.g. constructed via the test-only path or before connect_stdio/connect_http completed) or after connect failed and a default-constructed client is reused.","commonSituations":"Application constructs McpClient directly instead of via McpClient::connect; connect returned a client even though initialization later failed; race where tools are invoked before connection setup finishes.","solutions":["Always obtain McpClient through McpClient::connect and propagate its error before use","Check that connect succeeded (server_type stdio/sse/streamable-http handled) before calling tools","Ensure the client isn't default-constructed or partially initialized in test code","Re-run the connect sequence if the backend was dropped/restarted"],"exampleFix":"// before\nlet client = McpClient::default();\nclient.call_tool(\"t\", None).await?;\n// after\nlet client = McpClient::connect(&config, token).await?;\nclient.call_tool(\"t\", None).await?;","handlingStrategy":"validation","validationCode":"// ensure connect was called before use\nlet client = McpClient::connect(&config, token).await?;","typeGuard":null,"tryCatchPattern":"match client.call_tool(name, args).await {\n    Err(e) if e.to_string() == \"MCP client backend missing\" => {\n        // re-run connect() before retrying\n    }\n    r => r?,\n}","preventionTips":["Never construct McpClient outside connect()","Treat connect errors as fatal before invoking tools","Serialize connect and first tool call to avoid init races"],"tags":["mcp","state","initialization"],"backgroundTag":"invalid-state-transition","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}