{"record":{"id":"fac1cf2f495c18cb","repo":"xai-org/grok-build","slug":"invalid-url-url-server-urls-must-start-with-h","errorCode":null,"errorMessage":"Invalid URL '{url}'. Server URLs must start with http:// or https://.","messagePattern":"Invalid URL '(.+?)'\\. Server URLs must start with http:// or https://\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/mcp_cmd.rs","lineNumber":385,"sourceCode":"                    env: (!env.is_empty()).then_some(env),\n                    cwd: None,\n                },\n                warnings,\n            })\n        }\n        McpTransport::Http | McpTransport::Sse => {\n            let label = if transport == McpTransport::Sse {\n                \"sse\"\n            } else {\n                \"http\"\n            };\n            let Some(url) = source else {\n                bail!(\n                    \"A URL is required for {label} servers. Usage: grok mcp add --transport {label} <name> <url>\"\n                );\n            };\n            if !url.starts_with(\"http://\") && !url.starts_with(\"https://\") {\n                bail!(\"Invalid URL '{url}'. Server URLs must start with http:// or https://.\");\n            }\n            if !server_args.is_empty() {\n                bail!(\n                    \"Unexpected arguments after the URL: '{}'. HTTP and SSE servers take a single URL.\",\n                    server_args.join(\" \")\n                );\n            }\n            if !args.env.is_empty() {\n                bail!(\"--env can only be used with stdio servers.\");\n            }\n            let headers = parse_headers(&args.header)?;\n\n            let mut warnings = Vec::new();\n            if inferred_http {\n                warnings.push(format!(\n                    \"No --transport given; '{url}' starts with http(s)://, adding as an HTTP server. Use --transport sse for an SSE server, or --transport stdio to force a stdio command.\"\n                ));\n            }","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/mcp_cmd.rs#L367-L403","documentation":"When adding an HTTP/SSE MCP server, the URL argument must start with http:// or https://. Anything else (bare host, file path, ws://, etc.) is rejected with this message so a malformed endpoint never reaches the HTTP client.","triggerScenarios":"`grok mcp add <name> --transport http acme.example.com/mcp` or a URL using an unsupported scheme like `grpc://` or a local path.","commonSituations":"Omitting the scheme out of habit (browsers auto-add https), copying an internal `http://` URL but trimming the prefix, using ws:// or localhost:path forms from other tools' configs.","solutions":["Prefix the URL with https:// (or http:// for plain-HTTP endpoints).","Verify the full endpoint URL from the MCP server provider's docs.","Use --transport stdio if the server is actually a local command, not an HTTP endpoint."],"exampleFix":"// before\ngrok mcp add acme --transport http acme.example.com/mcp\n// after\ngrok mcp add acme --transport http https://acme.example.com/mcp","handlingStrategy":"validation","validationCode":"fn is_http_url(s: &str) -> bool { s.starts_with(\"http://\") || s.starts_with(\"https://\") }\nassert!(is_http_url(url), \"URL must start with http:// or https://\");","typeGuard":"fn is_http_url(s: &str) -> bool { s.starts_with(\"http://\") || s.starts_with(\"https://\") }","tryCatchPattern":null,"preventionTips":["Always include the scheme in server URLs.","Normalize URLs in scripts to add https:// when missing.","Use stdio transport for local commands instead of file:// or path URLs."],"tags":["cli","mcp","url","validation"],"backgroundTag":"invalid-url-scheme","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}