Tencent/WeKnora · error

URL is required for HTTP Streamable transport

Error message

URL is required for HTTP Streamable transport

What it means

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.

Source

Thrown at internal/mcp/client.go:207

			return nil, fmt.Errorf("URL is required for SSE transport")
		}
		if useOAuth {
			mcpClient, err = client.NewOAuthSSEClient(*config.Service.URL, oauthConfig,
				transport.WithHTTPClient(httpClient),
				transport.WithHeaders(headers),
			)
		} else {
			mcpClient, err = client.NewSSEMCPClient(*config.Service.URL,
				client.WithHTTPClient(httpClient),
				client.WithHeaders(headers),
			)
		}
		if err != nil {
			return nil, fmt.Errorf("failed to create SSE client: %w", err)
		}
	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)

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set config.Service.URL to the absolute streamable endpoint (usually https://host/mcp) before creating the client
  2. Validate at service-create/update time that URL is non-empty when transport type is HTTP Streamable
  3. Check the persisted service row/config file actually contains the url field

Example fix

// before
svc := &types.MCPService{TransportType: types.MCPTransportHTTPStreamable}
client, err := NewMCPClient(&ClientConfig{Service: svc})
// after
url := "https://mcp.example.com/mcp"
svc := &types.MCPService{TransportType: types.MCPTransportHTTPStreamable, URL: &url}
client, err := NewMCPClient(&ClientConfig{Service: svc})
Defensive patterns

Strategy: validation

Validate before calling

func requireStreamableURL(svc *types.MCPService) error {
    if svc.TransportType == types.MCPTransportHTTPStreamable && (svc.URL == nil || *svc.URL == "") {
        return errors.New("HTTP Streamable MCP service requires a URL")
    }
    return nil
}

Type guard

func hasURL(svc *types.MCPService) bool { return svc != nil && svc.URL != nil && *svc.URL != "" }

Try / catch

_, err := NewMCPClient(cfg)
if err != nil && strings.Contains(err.Error(), "URL is required for HTTP Streamable") {
    return fmt.Errorf("service %s misconfigured: streamable transport needs a URL", cfg.Service.ID)
}

Prevention

When it happens

Trigger: NewMCPClient called with config.Service.TransportType == types.MCPTransportHTTPStreamable while config.Service.URL is nil or *config.Service.URL == "".

Common situations: 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.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/5c90f75e78a033c6. Report an issue: GitHub.