{"record":{"id":"9717825c02b069a2","repo":"alibaba/open-code-review","slug":"mcp-server-url-cannot-be-empty","errorCode":null,"errorMessage":"MCP server URL cannot be empty","messagePattern":"MCP server URL cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":887,"sourceCode":"\t\tif err := json.Unmarshal([]byte(value), &args); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tentry.Args = args\n\tcase \"env\":\n\t\tvar env []string\n\t\tif err := json.Unmarshal([]byte(value), &env); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tfor _, e := range env {\n\t\t\tidx := strings.Index(e, \"=\")\n\t\t\tif idx <= 0 {\n\t\t\t\treturn fmt.Errorf(\"invalid env entry %q: must be in KEY=VALUE format\", e)\n\t\t\t}\n\t\t}\n\t\tentry.Env = env\n\tcase \"url\":\n\t\tif value == \"\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL cannot be empty\")\n\t\t}\n\t\tparsed, err := url.Parse(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid MCP server URL %q: %w\", value, err)\n\t\t}\n\t\tif parsed.Scheme != \"http\" && parsed.Scheme != \"https\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL must use http or https scheme, got %q\", parsed.Scheme)\n\t\t}\n\t\tif parsed.Host == \"\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL %q must include a host\", value)\n\t\t}\n\t\tentry.URL = value\n\tcase \"headers\":\n\t\tparsed, err := parseMCPHeaders(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid headers for %s: %w\", key, err)\n\t\t}\n\t\tentry.Headers = parsed","sourceCodeStart":869,"sourceCodeEnd":905,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L869-L905","documentation":"Validation in setMCPServerValue's url case: a remote MCP server entry requires a non-empty URL. Setting mcp_servers.<name>.url to an empty string would leave the remote transport with no endpoint, so the setter rejects it.","triggerScenarios":"Calling setMCPServerValue with field \"url\" and value \"\".","commonSituations":"Running `ocr config set mcp_servers.api.url` without the value argument (shell passes empty string), or templated scripts where the URL variable is unset.","solutions":["Pass the full server URL, e.g. https://mcp.example.com/sse","If the server is local, use type stdio with command/args instead of url","Check that any script variable holding the URL is actually set"],"exampleFix":"// before\nocr config set mcp_servers.api.url \"\"\n// after\nocr config set mcp_servers.api.url https://mcp.example.com/sse","handlingStrategy":"validation","validationCode":"if url == \"\" {\n\treturn fmt.Errorf(\"url is required for remote servers\")\n}","typeGuard":null,"tryCatchPattern":"if err := setMCPServerValue(cfg, key, value); err != nil {\n\tfmt.Fprintf(os.Stderr, \"config set failed: %v\\n\", err)\n\tos.Exit(1)\n}","preventionTips":["Always pass the URL as a quoted argument","In scripts, fail fast if the URL variable is empty (set -u / : \"${URL:?}\")","Use stdio type with command for local servers instead"],"tags":["config","mcp","url","validation"],"backgroundTag":"empty-required-field","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}