{"record":{"id":"c9b05a79cc3a1df5","repo":"FoundationAgents/OpenManus","slug":"failed-to-load-mcp-server-config-e","errorCode":null,"errorMessage":"Failed to load MCP server config: {e}","messagePattern":"Failed to load MCP server config: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"app/config.py","lineNumber":171,"sourceCode":"        try:\n            config_file = config_path if config_path.exists() else None\n            if not config_file:\n                return {}\n\n            with config_file.open() as f:\n                data = json.load(f)\n                servers = {}\n\n                for server_id, server_config in data.get(\"mcpServers\", {}).items():\n                    servers[server_id] = MCPServerConfig(\n                        type=server_config[\"type\"],\n                        url=server_config.get(\"url\"),\n                        command=server_config.get(\"command\"),\n                        args=server_config.get(\"args\", []),\n                    )\n                return servers\n        except Exception as e:\n            raise ValueError(f\"Failed to load MCP server config: {e}\")\n\n\nclass AppConfig(BaseModel):\n    llm: Dict[str, LLMSettings]\n    sandbox: Optional[SandboxSettings] = Field(\n        None, description=\"Sandbox configuration\"\n    )\n    browser_config: Optional[BrowserSettings] = Field(\n        None, description=\"Browser configuration\"\n    )\n    search_config: Optional[SearchSettings] = Field(\n        None, description=\"Search configuration\"\n    )\n    mcp_config: Optional[MCPSettings] = Field(None, description=\"MCP configuration\")\n    run_flow_config: Optional[RunflowSettings] = Field(\n        None, description=\"Run flow configuration\"\n    )\n    daytona_config: Optional[DaytonaSettings] = Field(","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/config.py#L153-L189","documentation":"Raised by the MCP server config loader in config.py when parsing mcp_servers.json fails for any reason — the outer `except Exception` wraps JSON syntax errors, missing required keys, wrong types, and file read failures into one ValueError with the original exception interpolated. The underlying cause is always in the `{e}` part of the message.","triggerScenarios":"Loading mcp_servers.json with invalid JSON (trailing comma, comments), a server entry missing the required \"type\" key (server_config[\"type\"] raises KeyError), or non-dict values under mcpServers. File permission errors also surface here.","commonSituations":"Hand-editing mcp_servers.json and leaving a trailing comma; entry with url/command/args but no \"type\" field; comments in JSON; running with read permissions missing on the config file.","solutions":["Read the {e} suffix to identify the root cause: JSONDecodeError means syntax, KeyError 'type' means a missing field","Validate the file with a JSON linter (python -m json.tool mcp_servers.json) and fix syntax","Ensure every mcpServers entry has \"type\" (\"sse\" or \"stdio\") plus the matching fields: url for sse, command for stdio"],"exampleFix":"// before (mcp_servers.json)\n{ \"mcpServers\": { \"fs\": { \"command\": \"npx\" } } }  // KeyError: 'type'\n\n// after\n{ \"mcpServers\": { \"fs\": { \"type\": \"stdio\", \"command\": \"npx\", \"args\": [\"-y\", \"@modelcontextprotocol/server-filesystem\"] } } }","handlingStrategy":"try-catch","validationCode":"import json\n\ndef validate_mcp_config(path: str) -> dict:\n    with open(path) as f:\n        data = json.load(f)  # raises JSONDecodeError early\n    for sid, sc in data.get(\"mcpServers\", {}).items():\n        assert sc.get(\"type\") in (\"sse\", \"stdio\"), f\"{sid}: bad type\"\n        if sc[\"type\"] == \"sse\":\n            assert sc.get(\"url\"), f\"{sid}: url required\"\n        else:\n            assert sc.get(\"command\"), f\"{sid}: command required\"\n    return data","typeGuard":null,"tryCatchPattern":"try:\n    servers = load_mcp_servers()\nexcept ValueError as e:\n    # the original cause is embedded after the colon\n    logger.error(\"MCP config invalid: %s\", e)\n    raise SystemExit(1) from e","preventionTips":["Validate mcp_servers.json with python -m json.tool in CI","Keep MCP config in a pydantic model so key errors surface as precise field messages","Never hand-edit JSON without re-linting"],"tags":["mcp","configuration","json","validation"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}