Tencent/WeKnora · error
failed to create HTTP streamable client: %w
Error message
failed to create HTTP streamable client: %w
What it means
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.
Source
Thrown at internal/mcp/client.go:222
}
case types.MCPTransportHTTPStreamable:
if config.Service.URL == nil || *config.Service.URL == "" {
return nil, fmt.Errorf("URL is required for HTTP Streamable transport")
}
if useOAuth {
mcpClient, err = client.NewOAuthStreamableHttpClient(*config.Service.URL, oauthConfig,
transport.WithHTTPBasicClient(httpClient),
transport.WithHTTPHeaders(headers),
)
} else {
// For HTTP streamable, we need to use transport options
mcpClient, err = client.NewStreamableHttpClient(*config.Service.URL,
transport.WithHTTPBasicClient(httpClient),
transport.WithHTTPHeaders(headers),
)
}
if err != nil {
return nil, fmt.Errorf("failed to create HTTP streamable client: %w", err)
}
case types.MCPTransportStdio:
// Stdio transport is disabled for security reasons (potential command injection vulnerabilities)
return nil, fmt.Errorf("stdio transport is disabled for security reasons; please use SSE or HTTP Streamable transport instead")
default:
return nil, ErrUnsupportedTransport
}
instance := &mcpGoClient{
service: config.Service,
client: mcpClient,
}
if useOAuth {
instance.oauth = newOAuthRuntime(
config.OAuthRepo,
config.TenantID,
config.Principal,
config.Service.ID,View on GitHub (pinned to 988cbb0330)
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
Example fix
// before
mcpClient, err = client.NewStreamableHttpClient("http://bad url\tmcp", ...)
// after
endpoint := strings.TrimSpace(cfg.URL)
if _, perr := url.Parse(endpoint); perr != nil {
return nil, fmt.Errorf("invalid streamable URL: %w", perr)
}
mcpClient, err = client.NewStreamableHttpClient(endpoint, ...) Defensive patterns
Strategy: validation
Validate before calling
func validStreamableURL(raw *string) bool {
if raw == nil || *raw == "" { return false }
u, err := url.Parse(strings.TrimSpace(*raw))
return err == nil && (u.Scheme == "http" || u.Scheme == "https") && u.Host != ""
} Type guard
func asCreateStreamableErr(err error) (cause error, ok bool) {
if err == nil || !strings.Contains(err.Error(), "failed to create HTTP streamable client") { return nil, false }
return errors.Unwrap(err), true
} Try / catch
mcpClient, err := NewMCPClient(cfg)
if err != nil {
if strings.Contains(err.Error(), "failed to create HTTP streamable client") {
return fmt.Errorf("bad streamable endpoint %q: %v", *cfg.Service.URL, errors.Unwrap(err))
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/1acda3978a227ac8.
Report an issue: GitHub.