{"record":{"id":"5c90f75e78a033c6","repo":"Tencent/WeKnora","slug":"url-is-required-for-http-streamable-transport","errorCode":null,"errorMessage":"URL is required for HTTP Streamable transport","messagePattern":"URL is required for HTTP Streamable transport","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/mcp/client.go","lineNumber":207,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"URL is required for SSE transport\")\n\t\t}\n\t\tif useOAuth {\n\t\t\tmcpClient, err = client.NewOAuthSSEClient(*config.Service.URL, oauthConfig,\n\t\t\t\ttransport.WithHTTPClient(httpClient),\n\t\t\t\ttransport.WithHeaders(headers),\n\t\t\t)\n\t\t} else {\n\t\t\tmcpClient, err = client.NewSSEMCPClient(*config.Service.URL,\n\t\t\t\tclient.WithHTTPClient(httpClient),\n\t\t\t\tclient.WithHeaders(headers),\n\t\t\t)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create SSE client: %w\", err)\n\t\t}\n\tcase types.MCPTransportHTTPStreamable:\n\t\tif config.Service.URL == nil || *config.Service.URL == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"URL is required for HTTP Streamable transport\")\n\t\t}\n\t\tif useOAuth {\n\t\t\tmcpClient, err = client.NewOAuthStreamableHttpClient(*config.Service.URL, oauthConfig,\n\t\t\t\ttransport.WithHTTPBasicClient(httpClient),\n\t\t\t\ttransport.WithHTTPHeaders(headers),\n\t\t\t)\n\t\t} else {\n\t\t\t// For HTTP streamable, we need to use transport options\n\t\t\tmcpClient, err = client.NewStreamableHttpClient(*config.Service.URL,\n\t\t\t\ttransport.WithHTTPBasicClient(httpClient),\n\t\t\t\ttransport.WithHTTPHeaders(headers),\n\t\t\t)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create HTTP streamable client: %w\", err)\n\t\t}\n\tcase types.MCPTransportStdio:\n\t\t// Stdio transport is disabled for security reasons (potential command injection vulnerabilities)","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/mcp/client.go#L189-L225","documentation":"Guard clause in NewMCPClient for the HTTP Streamable transport: the service's URL pointer is nil or the dereferenced string is empty, so no endpoint exists to connect to. It is a configuration validation error thrown before any client construction.","triggerScenarios":"NewMCPClient called with config.Service.TransportType == types.MCPTransportHTTPStreamable while config.Service.URL is nil or *config.Service.URL == \"\".","commonSituations":"Service record created without a URL (e.g. placeholder created from a template meant for stdio); JSON config omitted the url field; URL cleared by an update API that didn't validate transport-type/url consistency.","solutions":["Set config.Service.URL to the absolute streamable endpoint (usually https://host/mcp) before creating the client","Validate at service-create/update time that URL is non-empty when transport type is HTTP Streamable","Check the persisted service row/config file actually contains the url field"],"exampleFix":"// before\nsvc := &types.MCPService{TransportType: types.MCPTransportHTTPStreamable}\nclient, err := NewMCPClient(&ClientConfig{Service: svc})\n// after\nurl := \"https://mcp.example.com/mcp\"\nsvc := &types.MCPService{TransportType: types.MCPTransportHTTPStreamable, URL: &url}\nclient, err := NewMCPClient(&ClientConfig{Service: svc})","handlingStrategy":"validation","validationCode":"func requireStreamableURL(svc *types.MCPService) error {\n    if svc.TransportType == types.MCPTransportHTTPStreamable && (svc.URL == nil || *svc.URL == \"\") {\n        return errors.New(\"HTTP Streamable MCP service requires a URL\")\n    }\n    return nil\n}","typeGuard":"func hasURL(svc *types.MCPService) bool { return svc != nil && svc.URL != nil && *svc.URL != \"\" }","tryCatchPattern":"_, err := NewMCPClient(cfg)\nif err != nil && strings.Contains(err.Error(), \"URL is required for HTTP Streamable\") {\n    return fmt.Errorf(\"service %s misconfigured: streamable transport needs a URL\", cfg.Service.ID)\n}","preventionTips":["Enforce transport-type/URL consistency in the service admin API and DB schema","Never clear URL on update without also checking transport type","Add table-level validation tests for service records"],"tags":["go","mcp","configuration","validation"],"backgroundTag":"missing-config-field","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}