{"record":{"id":"1acda3978a227ac8","repo":"Tencent/WeKnora","slug":"failed-to-create-http-streamable-client-w","errorCode":null,"errorMessage":"failed to create HTTP streamable client: %w","messagePattern":"failed to create HTTP streamable client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/mcp/client.go","lineNumber":222,"sourceCode":"\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)\n\t\treturn nil, fmt.Errorf(\"stdio transport is disabled for security reasons; please use SSE or HTTP Streamable transport instead\")\n\tdefault:\n\t\treturn nil, ErrUnsupportedTransport\n\t}\n\n\tinstance := &mcpGoClient{\n\t\tservice: config.Service,\n\t\tclient:  mcpClient,\n\t}\n\tif useOAuth {\n\t\tinstance.oauth = newOAuthRuntime(\n\t\t\tconfig.OAuthRepo,\n\t\t\tconfig.TenantID,\n\t\t\tconfig.Principal,\n\t\t\tconfig.Service.ID,","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/mcp/client.go#L204-L240","documentation":"NewMCPClient wraps errors from NewStreamableHttpClient or NewOAuthStreamableHttpClient with 'failed to create HTTP streamable client'. As with SSE, construction-time failures are almost always URL parse errors or invalid options; network problems surface later in Connect, not here.","triggerScenarios":"NewMCPClient with TransportType == MCPTransportHTTPStreamable and a non-empty URL that the streamable client constructor rejects (malformed/unsupported URL), or an OAuth streamable client rejecting the URL/OAuth options.","commonSituations":"Typo in URL scheme (ftp://, ws://); URL with control characters loaded from config; endpoint missing the /mcp path so later calls fail but construction itself fails only on parse errors.","solutions":["Read the wrapped cause after 'failed to create HTTP streamable client:' for the real error","Validate the URL with url.Parse and require http/https before calling NewMCPClient","Correct the stored service URL to an absolute https endpoint","If OAuth, verify the OAuthConfig fields are valid before construction"],"exampleFix":"// before\nmcpClient, err = client.NewStreamableHttpClient(\"http://bad url\\tmcp\", ...)\n// after\nendpoint := strings.TrimSpace(cfg.URL)\nif _, perr := url.Parse(endpoint); perr != nil {\n    return nil, fmt.Errorf(\"invalid streamable URL: %w\", perr)\n}\nmcpClient, err = client.NewStreamableHttpClient(endpoint, ...)","handlingStrategy":"validation","validationCode":"func validStreamableURL(raw *string) bool {\n    if raw == nil || *raw == \"\" { return false }\n    u, err := url.Parse(strings.TrimSpace(*raw))\n    return err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\") && u.Host != \"\"\n}","typeGuard":"func asCreateStreamableErr(err error) (cause error, ok bool) {\n    if err == nil || !strings.Contains(err.Error(), \"failed to create HTTP streamable client\") { return nil, false }\n    return errors.Unwrap(err), true\n}","tryCatchPattern":"mcpClient, err := NewMCPClient(cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to create HTTP streamable client\") {\n        return fmt.Errorf(\"bad streamable endpoint %q: %v\", *cfg.Service.URL, errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["Trim and validate URLs before persisting","Restrict schemes to http/https in the admin UI","Log the wrapped cause, not just the wrapper, when constructing clients"],"tags":["go","mcp","http","url-parsing"],"backgroundTag":"invalid-url","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}