{"record":{"id":"72dbf122a0761f88","repo":"alibaba/open-code-review","slug":"mcp-server-url-must-use-http-or-https-scheme-got","errorCode":null,"errorMessage":"MCP server URL must use http or https scheme, got %q","messagePattern":"MCP server URL must use http or https scheme, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":894,"sourceCode":"\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\n\tcase \"tools\":\n\t\tvar tools []string\n\t\tif err := json.Unmarshal([]byte(value), &tools); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tseen := make(map[string]struct{}, len(tools))\n\t\tfiltered := make([]string, 0, len(tools))","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L876-L912","documentation":"Only http and https schemes are accepted for remote MCP server URLs. Other schemes (ws, ftp, file, or a missing scheme making parsed.Scheme empty) are rejected with this error naming the offending scheme.","triggerScenarios":"Calling setMCPServerValue with field \"url\" whose parsed scheme is not http or https: e.g. \"ftp://host\", \"localhost:8080\" (scheme parsed as empty/other), or \"wss://host\".","commonSituations":"Omitting the scheme so Go parses the URL as an opaque/path-only value; using websocket schemes from other MCP client configs; pasting file:// URLs for local servers.","solutions":["Prefix the URL with https:// (or http:// for plain local endpoints)","Do not use ws:// or wss://; the client speaks HTTP/SSE","If targeting localhost, still write the full scheme: http://localhost:8080"],"exampleFix":"// before\nocr config set mcp_servers.api.url localhost:8080/mcp\n// after\nocr config set mcp_servers.api.url http://localhost:8080/mcp","handlingStrategy":"validation","validationCode":"u, err := url.Parse(rawURL)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") {\n\treturn fmt.Errorf(\"URL must use http or https\")\n}","typeGuard":"func isHTTPURL(rawURL string) bool {\n\tu, err := url.Parse(rawURL)\n\treturn err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\")\n}","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 prefix URLs with https:// or http://","Do not use ws://, wss://, or file:// schemes","Even localhost endpoints need an explicit scheme"],"tags":["config","mcp","url","validation"],"backgroundTag":"invalid-url-scheme","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}