{"record":{"id":"eec9985e87060e82","repo":"bytedance/deer-flow","slug":"mcp-task-repo-not-available","errorCode":null,"errorMessage":"MCP task repo not available","messagePattern":"MCP task repo not available","errorType":"http","errorClass":"HTTPException","httpStatus":503,"severity":"error","filePath":"backend/app/gateway/deps.py","lineNumber":668,"sourceCode":"\ndef get_scheduled_task_run_repo(request: Request):\n    val = getattr(request.app.state, \"scheduled_task_run_repo\", None)\n    if val is None:\n        raise HTTPException(status_code=503, detail=\"Scheduled task run repo not available\")\n    return val\n\n\ndef get_scheduled_task_service(request: Request):\n    val = getattr(request.app.state, \"scheduled_task_service\", None)\n    if val is None:\n        raise HTTPException(status_code=503, detail=\"Scheduled task service not available\")\n    return val\n\n\ndef get_mcp_task_repo(request: Request):\n    val = getattr(request.app.state, \"mcp_task_repo\", None)\n    if val is None:\n        raise HTTPException(status_code=503, detail=\"MCP task repo not available\")\n    return val\n\n\ndef get_mcp_task_service(request: Request):\n    val = getattr(request.app.state, \"mcp_task_service\", None)\n    if val is None:\n        raise HTTPException(status_code=503, detail=\"MCP task service not available\")\n    return val\n\n\ndef get_run_context(request: Request) -> RunContext:\n    \"\"\"Build a :class:`RunContext` from ``app.state`` singletons.\n\n    Returns a *base* context with infrastructure dependencies. The\n    ``app_config`` field is resolved live so per-run fields (e.g.\n    ``models[*].max_tokens``) follow ``config.yaml`` edits; the\n    ``event_store`` / ``run_events_config`` pair stays frozen to the snapshot\n    captured in :func:`langgraph_runtime` so callers never see a store bound","sourceCodeStart":650,"sourceCodeEnd":686,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/deps.py#L650-L686","documentation":"HTTP 503 from get_mcp_task_repo() when app.state.mcp_task_repo is None. The MCP task repository stores MCP-server task records; it is attached during Gateway lifespan as part of persistence bootstrap.","triggerScenarios":"Calling MCP task routes (list/create/delete MCP task records) on a Gateway whose lifespan did not attach mcp_task_repo — persistence init failure or running against an app instance without the Gateway lifespan.","commonSituations":"Database unavailable at startup so the repo never constructed; version mismatch between frontend expecting MCP task endpoints and a backend build without them; routers exercised in tests without full lifespan.","solutions":["Check Gateway startup logs for the MCP task repo init exception","Verify the persistence database is reachable and the relevant tables/migrations exist","Restart the Gateway after fixing persistence so lifespan re-attaches mcp_task_repo"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    tasks = await api.list_mcp_tasks()\nexcept HTTP503 as e:\n    if 'MCP task repo' in e.detail:\n        tasks = []\n    else:\n        raise","preventionTips":["Verify DB migrations are applied before enabling MCP task features in the UI","Health-check persistence at startup, not per request","Pin frontend/backend versions together to avoid calling endpoints the backend cannot serve"],"tags":["http-503","mcp","tasks","persistence","lifespan","gateway"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}