{"record":{"id":"4d036eea5d427d72","repo":"langchain-ai/deepagents","slug":"str-exc-4d036e","errorCode":null,"errorMessage":"str(exc)","messagePattern":"str\\(exc\\)","errorType":"error_code","errorClass":"MCPConfigError","httpStatus":null,"severity":"error","filePath":"libs/talon/deepagents_talon/mcp.py","lineNumber":85,"sourceCode":"\n    Args:\n        config: Talon runtime configuration.\n\n    Returns:\n        Loaded tools and status for each configured server.\n\n    Raises:\n        MCPConfigError: If a selected config source is malformed.\n    \"\"\"\n    try:\n        tools, manager, infos = await resolve_and_load_mcp_tools(\n            explicit_config_path=_first_env_value(config.env),\n            trust_project_mcp=None,\n            project_context=_project_context(config),\n        )\n    except (OSError, json.JSONDecodeError, TypeError, ValueError) as exc:\n        msg = str(exc)\n        raise MCPConfigError(msg) from exc\n    if manager is not None:\n        logger.debug(\"Loaded MCP tools with a persistent session manager: %r\", manager)\n    return MCPTools(tools=tuple(tools), servers=tuple(infos))\n\n\ndef print_mcp_config_paths(config: TalonConfig) -> None:\n    \"\"\"Print Deep Agents Code MCP config discovery paths.\n\n    Args:\n        config: Talon runtime configuration.\n    \"\"\"\n    project_context = _project_context(config)\n    found = {str(path.resolve()) for path in discover_mcp_config_paths(config)}\n    project_root = (\n        project_context.project_root\n        if project_context is not None and project_context.project_root is not None\n        else (project_context.user_cwd if project_context is not None else Path.cwd())\n    )","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/talon/deepagents_talon/mcp.py#L67-L103","documentation":"MCPConfigError wrapping any OSError, JSONDecodeError, TypeError, or ValueError raised while discovering and loading MCP tools (env parsing, config file reading, JSON decoding). The original message is preserved verbatim via str(exc) and the cause is chained.","triggerScenarios":"Calling load_mcp_tools when the MCP config file is unreadable (OSError), contains invalid JSON (JSONDecodeError), or has a structurally wrong type/value (TypeError/ValueError) during discovery.","commonSituations":"Bad MCP_CONFIG path env var; malformed .mcp.json with a JSON typo; unexpected value types in config fields; permissions issues on the config file.","solutions":["Read the chained 'Caused by' exception for the root cause and fix that underlying issue","Validate the MCP config JSON parses (python -m json.tool <file>)","Check the config path env vars point to an existing readable file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"cfg_path = os.environ.get(\"MCP_CONFIG_PATH\")\nif cfg_path and not Path(cfg_path).is_file():\n    raise FileNotFoundError(cfg_path)\njson.loads(Path(cfg_path).read_text())  # syntax check","typeGuard":null,"tryCatchPattern":"try:\n    mcp_tools = load_mcp_tools(config)\nexcept MCPConfigError as exc:\n    logger.error(\"MCP config failed to load: %s (cause: %r)\", exc, exc.__cause__)\n    mcp_tools = MCPTools(tools=(), servers=())","preventionTips":["Always inspect exc.__cause__ — the wrapped OSError/JSONDecodeError names the real problem","Validate the MCP config JSON with python -m json.tool in CI","Check config path env vars early at startup"],"tags":["mcp","config","json","wrapping"],"backgroundTag":"mcp-config-load-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}