{"record":{"id":"dd12e7e753f539ec","repo":"langchain-ai/deepagents","slug":"mcp-config-file-not-found-config-path","errorCode":null,"errorMessage":"MCP config file not found: {config_path}","messagePattern":"MCP config file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/mcp_tools.py","lineNumber":1132,"sourceCode":"\ndef _load_mcp_config_json(config_path: str) -> dict[str, Any]:\n    \"\"\"Load MCP configuration JSON with parser diagnostics.\n\n    Args:\n        config_path: Path to the MCP JSON configuration file.\n\n    Returns:\n        Parsed configuration dictionary.\n\n    Raises:\n        FileNotFoundError: If config file doesn't exist.\n        json.JSONDecodeError: If config file contains invalid JSON.\n    \"\"\"\n    path = Path(config_path)\n\n    if not path.exists():\n        error_msg = f\"MCP config file not found: {config_path}\"\n        raise FileNotFoundError(error_msg)\n\n    try:\n        with path.open(encoding=\"utf-8\") as file_obj:\n            return json.load(file_obj)\n    except json.JSONDecodeError as exc:\n        # Build a layered message: core reason, an actionable hint for common\n        # mistakes, then a caret snippet last so the auto-appended\n        # \"line X column Y\" suffix reads as the location of the caret.\n        parts = [f\"Invalid JSON in MCP config file: {exc.msg}\"]\n        hint = _json_error_hint(exc)\n        if hint is not None:\n            parts.append(hint)\n        snippet = _json_error_snippet(exc.doc, exc.lineno, exc.colno, pos=exc.pos)\n        if snippet is not None:\n            parts.append(snippet)\n        error_msg = \"\\n\".join(parts)\n        raise json.JSONDecodeError(error_msg, exc.doc, exc.pos) from exc\n","sourceCodeStart":1114,"sourceCodeEnd":1150,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/mcp_tools.py#L1114-L1150","documentation":"`_load_mcp_config_json` opens the MCP config file at the given path to parse it as JSON. If the path does not exist on disk it raises this FileNotFoundError before any parsing. This is an environment/path problem, not a JSON problem.","triggerScenarios":"Calling the config loader (via _load_mcp_config_top_level) with a path that doesn't exist: a typo'd path, a relative path resolved from a different working directory, or a file deleted/moved after the path string was computed.","commonSituations":"Pointing dcode at ~/.cursor/mcp.json or .mcp.json that was never created; running from a different cwd so './mcp.json' resolves elsewhere; switching machines where the config was never synced; passing the project directory instead of the config file path.","solutions":["Check the path with `ls <config_path>` / Path.exists() and fix typos or point at the actual file.","Use an absolute path, or run the command from the directory containing the config.","Create the config file if it genuinely doesn't exist yet, e.g. `{\"mcpServers\": {}}` skeleton (then add servers)."],"exampleFix":"// before\nload_mcp_config(\"./mcp.json\")  # run from another cwd -> not found\n// after\nload_mcp_config(\"/home/me/project/.mcp.json\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\ncfg = Path(config_path).expanduser().resolve()\nif not cfg.is_file():\n    raise SystemExit(f\"config not found: {cfg}\")\nload_mcp_config(str(cfg))","typeGuard":"def config_exists(path: str) -> bool:\n    from pathlib import Path\n    return Path(path).expanduser().is_file()","tryCatchPattern":"try:\n    load_mcp_config(path)\nexcept FileNotFoundError:\n    logging.error(\"MCP config %s missing; create it or pass --config\", path)\n    sys.exit(2)","preventionTips":["Use absolute paths (or expanduser) for config files instead of cwd-relative ones.","Check the file into the repo or bootstrap it on first run.","Run `ls`/`test -f` on the path before invoking tools that need the config."],"tags":["config","mcp","filesystem","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}