{"record":{"id":"df41065cce9dd782","repo":"ZhuLinsen/daily_stock_analysis","slug":"unsupported-mcp-name","errorCode":"unsupported_mcp_name","errorMessage":"Configured MCP name cannot be safely expressed as a transient CLI override","messagePattern":"Configured MCP name cannot be safely expressed as a transient CLI override","errorType":"error_code","errorClass":"CodexAppServerError","httpStatus":null,"severity":"error","filePath":"src/agent/codex_app_server_transport.py","lineNumber":1099,"sourceCode":"        tool_surface=empty_surface,\n        tool_context=ToolAccessContext(),\n        request_timeout=timeout,\n        deadline=deadline,\n        cancel_event=cancel_event,\n    ) as client:\n        assert client.safe_cwd is not None\n        result = client.request(\"config/read\", {\"cwd\": str(client.safe_cwd), \"includeLayers\": False})\n        config = result.get(\"config\")\n        if not isinstance(config, dict):\n            raise CodexAppServerError(\"protocol_error\", \"config/read did not return an effective config\")\n        mcp_servers = config.get(\"mcp_servers\") or {}\n        if not isinstance(mcp_servers, dict) or not all(isinstance(name, str) for name in mcp_servers):\n            raise CodexAppServerError(\"protocol_error\", \"config/read returned invalid MCP configuration\")\n\n    hardened = list(command)\n    for name in sorted(mcp_servers):\n        if _TOML_BARE_KEY.fullmatch(name) is None:\n            raise CodexAppServerError(\n                \"unsupported_mcp_name\",\n                \"Configured MCP name cannot be safely expressed as a transient CLI override\",\n            )\n        hardened.extend([\"-c\", f\"mcp_servers.{name}.enabled=false\"])\n    return hardened\n\n\ndef build_hardened_command(\n    *,\n    timeout: float,\n    executable: str = \"codex\",\n    deadline: Optional[float] = None,\n    cancel_event: Optional[threading.Event] = None,\n) -> list[str]:\n    \"\"\"Build the fixed production argv with every configured MCP disabled.\"\"\"\n    return harden_command_against_configured_mcp(\n        resolve_command(executable),\n        timeout=timeout,","sourceCodeStart":1081,"sourceCodeEnd":1117,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/src/agent/codex_app_server_transport.py#L1081-L1117","documentation":"The MCP hardening step disables every configured MCP server by appending `-c mcp_servers.<name>.enabled=false` overrides to the argv. A server name that fails the _TOML_BARE_KEY regex (bare TOML key: [A-Za-z0-9_-]+) cannot be expressed as a dotted config key on the CLI without quoting/injection risk, so the code refuses with code 'unsupported_mcp_name'.","triggerScenarios":"An ~/.codex/config.toml defining an MCP server whose name contains dots, spaces, quotes, unicode, or other characters outside the bare-key charset — e.g. [mcp_servers.\"my server.v2\"] — while the hardening path tries to build the override list.","commonSituations":"Quoted TOML keys with special characters in server names; names copied from URLs or product names ('context7-mcp (dev)'); configs authored for a codex version that permits such names meeting a hardening path that does not.","solutions":["Rename the MCP server in ~/.codex/config.toml to a bare key: letters, digits, underscore, hyphen only (e.g. context7_dev)","If the name is intentional, disable that server manually or exclude this hardening path for that config","Validate names with the same regex before launching: re.fullmatch(r'[A-Za-z0-9_-]+', name)","Document the naming constraint wherever users author MCP config for this agent"],"exampleFix":"# before (~/.codex/config.toml)\n[mcp_servers.\"my server.v2\"]\ncommand = \"npx\"\n\n# after\n[mcp_servers.my_server_v2]\ncommand = \"npx\"","handlingStrategy":"validation","validationCode":"import re\n\nTOML_BARE_KEY = re.compile(r\"[A-Za-z0-9_-]+\")\nbad = [n for n in mcp_server_names if not TOML_BARE_KEY.fullmatch(n)]\nif bad:\n    raise ValueError(f\"rename MCP servers to bare keys: {bad}\")","typeGuard":"def is_toml_bare_key(name: str) -> bool:\n    return bool(re.fullmatch(r\"[A-Za-z0-9_-]+\", name))","tryCatchPattern":null,"preventionTips":["Restrict MCP server names to [A-Za-z0-9_-]","Validate config before agent start","Fail fast on exotic names rather than quoting"],"tags":["codex","app-server","mcp","toml","naming"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}