{"record":{"id":"6ae9e5b25ff0eae1","repo":"Panniantong/Agent-Reach","slug":"mcporter-server","errorCode":null,"errorMessage":"mcporter server 定义必须是对象","messagePattern":"mcporter server 定义必须是对象","errorType":"exception","errorClass":"McporterConfigError","httpStatus":null,"severity":"error","filePath":"agent_reach/channels/mcporter.py","lineNumber":62,"sourceCode":"    \"\"\"\n    selected_layers = _select_config_layers(root_dir)\n    if not selected_layers:\n        return McporterConfigInspection(frozenset(), None)\n\n    names = set()\n    imports_unchecked = False\n    sources = []\n    for config_path, source in selected_layers:\n        payload = _read_config_object(config_path)\n        servers = payload.get(\"mcpServers\")\n        if not isinstance(servers, dict):\n            raise McporterConfigError(\"mcporter 配置缺少 mcpServers 对象\")\n\n        for name, definition in servers.items():\n            if not isinstance(name, str) or not name.strip():\n                raise McporterConfigError(\"mcporter 配置包含无效的 server name\")\n            if not isinstance(definition, dict):\n                raise McporterConfigError(\"mcporter server 定义必须是对象\")\n            names.add(name.casefold())\n\n        imports = payload.get(\"imports\", _MISSING)\n        if imports is _MISSING:\n            # mcporter defaults to importing supported editor configs when the\n            # key is omitted. Doctor intentionally does not open those files.\n            imports_unchecked = True\n        elif not isinstance(imports, list) or not all(\n            isinstance(item, str) for item in imports\n        ):\n            raise McporterConfigError(\"mcporter imports 必须是字符串列表\")\n        elif imports:\n            imports_unchecked = True\n        sources.append(source)\n\n    return McporterConfigInspection(\n        frozenset(names),\n        \"+\".join(sources),","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/channels/mcporter.py#L44-L80","documentation":"Raised when a value under mcpServers is not a JSON object. Each server must be a mapping (command/args/env or url etc.); a string, array, number, or null value fails the isinstance(definition, dict) check and aborts the whole inspection.","triggerScenarios":"mcpServers contains e.g. '\"github\": \"ghcop mcp serve\"' (bare command string), '\"github\": [\"cmd\", \"arg\"]', or '\"github\": null' in any selected layer.","commonSituations":"Shorthand configs from blog posts that put the command string directly as the value instead of {\"command\": ...}; YAML-style config pasted into JSON; a key set to null when commenting out a server.","solutions":["Wrap each value in an object with the standard fields: '\"name\": { \"command\": \"...\", \"args\": [...] }' or '\"name\": { \"url\": \"https://...\" }'","Validate with: jq -e '.mcpServers | to_entries | all(.value | type == \"object\")' file.json","To disable a server, delete the key rather than setting it to null"],"exampleFix":"// before\n { \"mcpServers\": { \"github\": \"ghcop mcp serve\" } }\n// after\n { \"mcpServers\": { \"github\": { \"command\": \"ghcop\", \"args\": [\"mcp\", \"serve\"] } } }","handlingStrategy":"validation","validationCode":"import json\n\ndef server_defs_ok(path) -> bool:\n    try:\n        servers = json.load(open(path, encoding=\"utf-8\")).get(\"mcpServers\", {})\n    except Exception:\n        return False\n    return all(isinstance(v, dict) for v in servers.values())","typeGuard":"def valid_server_entries(servers: dict) -> bool:\n    return all(isinstance(k, str) and k.strip() and isinstance(v, dict) for k, v in servers.items())","tryCatchPattern":"except McporterConfigError as exc:\n    if \"定义必须是对象\" in str(exc):\n        hint = \"each mcpServers value needs {command, args} or {url} shape\"","preventionTips":["Every server value must be an object; wrap bare command strings","Comment out by removing keys, not nulling values","Validate pasted configs: jq '.mcpServers | map_values(type==\"object\")'"],"tags":["mcporter","mcp","json","config"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}