{"record":{"id":"48e8793db3e858ef","repo":"langchain-ai/deepagents","slug":"mcp-config-file-not-found-mcp-config-path","errorCode":null,"errorMessage":"MCP config file not found: {mcp_config_path}","messagePattern":"MCP config file not found: (.+?)","errorType":"exception","errorClass":"MCPConfigError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/client/launch/server_manager.py","lineNumber":279,"sourceCode":"        mcp_config_path: Explicit path passed via `--mcp-config`, or `None`.\n        no_mcp: When `True`, MCP is disabled and validation is skipped.\n\n    Raises:\n        MCPConfigError: If the config file is malformed or missing required\n            fields. Message includes the offending path for context.\n    \"\"\"\n    if no_mcp or not mcp_config_path:\n        return\n\n    from deepagents_code.mcp_tools import MCPConfigError, load_mcp_config\n\n    try:\n        load_mcp_config(mcp_config_path)\n    except MCPConfigError:\n        raise\n    except FileNotFoundError as exc:\n        msg = f\"MCP config file not found: {mcp_config_path}\"\n        raise MCPConfigError(msg) from exc\n    except (ValueError, TypeError) as exc:\n        # `ValueError` covers `json.JSONDecodeError` (subclass) and the\n        # shape/field validators in `_validate_server_config`; `TypeError`\n        # covers the wrong-type branches. Bare `RuntimeError` is\n        # deliberately NOT caught — it would mask unrelated bugs\n        # (recursion, reentrancy, stdlib internals) as config errors.\n        msg = f\"Invalid MCP config at {mcp_config_path}: {exc}\"\n        raise MCPConfigError(msg) from exc\n\n\n# ------------------------------------------------------------------\n# Server startup\n# ------------------------------------------------------------------\n\n\nasync def start_server_and_get_agent(\n    *,\n    assistant_id: str,","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/client/launch/server_manager.py#L261-L297","documentation":"Before spawning the server, `_preflight_validate_mcp_config` runs `load_mcp_config` on the explicit `--mcp-config` path in the parent process so config problems surface as a clean MCPConfigError instead of an opaque truncated log dump from inside the subprocess. When the file at `mcp_config_path` does not exist, the FileNotFoundError is re-raised as this MCPConfigError including the path.","triggerScenarios":"Passing `--mcp-config /path/to/config.json` where the file is missing — typo'd path, file deleted/moved after CLI config was written, relative path resolved from a different working directory, or a stale path stored in a wrapper script.","commonSituations":"Typo in the path; running dcode from a different cwd than when the path was recorded; dotfile config pointing at a temp file that was cleaned up; case-sensitivity issues on Linux paths.","solutions":["Check the path in the message exists: run `ls <path>` and correct typos","Use an absolute path for --mcp-config to avoid cwd-dependent resolution","Recreate the MCP config file if it was deleted, or point --mcp-config at a valid config","If MCP is not needed, pass the no_mcp flag (--no-mcp) to skip validation entirely"],"exampleFix":"// before\n$ dcode --mcp-config ./mcfg.json  # FileNotFoundError -> MCPConfigError\n// after\n$ dcode --mcp-config /home/me/.config/dcode/mcp.json","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef mcp_config_exists(path: str | None) -> bool:\n    return bool(path) and Path(path).expanduser().resolve().is_file()","typeGuard":null,"tryCatchPattern":"try:\n    await start_server_and_get_agent(..., mcp_config_path=path)\nexcept MCPConfigError as e:\n    if \"not found\" in str(e):\n        print(f\"check path: {e}\")  # fix or pass --no-mcp\n    else:\n        raise","preventionTips":["Pass absolute paths to --mcp-config","Verify the file exists right before launching","Avoid storing temp-file paths in persistent config","On Linux, mind case-sensitive filenames"],"tags":["mcp","config","file-not-found"],"backgroundTag":"config-file-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}