{"record":{"id":"d3eac161fe1078db","repo":"BloopAI/vibe-kanban","slug":"failed-to-load-orchestrator-mcp-context-from-api","errorCode":null,"errorMessage":"Failed to load orchestrator MCP context from /api/containers/attempt-context","messagePattern":"Failed to load orchestrator MCP context from /api/containers/attempt-context","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mcp/src/task_server/mod.rs","lineNumber":115,"sourceCode":"        self.context = context;\n        Ok(self)\n    }\n\n    pub fn mode(&self) -> &McpMode {\n        &self.mode\n    }\n\n    async fn fetch_context_at_startup(&self) -> anyhow::Result<Option<McpContext>> {\n        let current_dir = std::env::current_dir().context(\"Failed to resolve current directory\")?;\n        let canonical_path = current_dir.canonicalize().unwrap_or(current_dir);\n        let normalized_path = utils::path::normalize_macos_private_alias(&canonical_path);\n\n        match self.try_fetch_attempt_context(&normalized_path).await {\n            Ok(Some(ctx)) => Ok(Some(\n                self.build_mcp_context_from_workspace_context(&ctx).await,\n            )),\n            Ok(None) | Err(_) if matches!(self.mode(), McpMode::Global) => Ok(None),\n            Ok(None) => anyhow::bail!(\n                \"Failed to load orchestrator MCP context from /api/containers/attempt-context\"\n            ),\n            Err(error) => Err(error.context(\"Failed to load orchestrator MCP context\")),\n        }\n    }\n\n    async fn try_fetch_attempt_context(\n        &self,\n        path: &Path,\n    ) -> anyhow::Result<Option<WorkspaceContext>> {\n        let url = self.url(\"/api/containers/attempt-context\");\n        let query = ContainerQuery {\n            container_ref: path.to_string_lossy().to_string(),\n        };\n\n        let response = tokio::time::timeout(\n            std::time::Duration::from_millis(500),\n            self.client.get(&url).query(&query).send(),","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/crates/mcp/src/task_server/mod.rs#L97-L133","documentation":"At startup the orchestrator MCP task server fetches its workspace/attempt context from the deployment API endpoint /api/containers/attempt-context. In non-Global mode a missing or failed fetch is fatal, because the server cannot operate without its attempt context. This distinguishes 'no context exists' (None) from an actual request error, which is re-thrown with additional context.","triggerScenarios":"fetch_context_at_startup called during init in orchestrator/non-global mode; try_fetch_attempt_context returns Ok(None) or the HTTP request fails (network error, non-2xx, bad auth).","commonSituations":"Container started before the deployment API is reachable; wrong API base URL or missing auth token; attempt not yet registered server-side so the endpoint returns empty; stale container pointing at a deleted attempt.","solutions":["Verify the API base URL and auth credentials for /api/containers/attempt-context","Ensure the deployment/attempt exists and is registered before starting the MCP server","Check network connectivity from the container to the deployment API","If this instance should run standalone, configure it in Global mode"],"exampleFix":"// before\nMcpServer::new(McpMode::Task) // requires attempt-context\n// after\nMcpServer::new(McpMode::Global) // or ensure attempt-context is reachable before init","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"let ctx = match fetch_context_at_startup().await { Ok(c) => c, Err(e) if e.to_string().contains(\"Failed to load orchestrator MCP context\") => { sleep(backoff).await; retry_limited(3).await? } };","preventionTips":["Health-check the deployment API before starting the MCP server","Verify attempt registration exists prior to container start","Set Global mode explicitly for standalone usage","Log the request URL/status on failure for faster diagnosis"],"tags":["http","startup","mcp","configuration"],"backgroundTag":"context-fetch-failed","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}