googleapis/mcp-toolbox · error
failed to parse BaseUrl %v
Error message
failed to parse BaseUrl %v
What it means
This error occurs when url.ParseRequestURI rejects the configured BaseUrl for the HTTP source. ParseRequestURI is stricter than url.Parse: it requires an absolute URI (scheme + host) for this usage, so values like "example.com/api", "/api", or strings with spaces/illegal characters fail. The source cannot make any request without a valid base URL.
Source
Thrown at internal/sources/http/http.go:117
}
logger, err := util.LoggerFromContext(ctx)
if err != nil {
return nil, fmt.Errorf("unable to get logger from ctx: %s", err)
}
if r.DisableSslVerification {
tr.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
logger.WarnContext(ctx, "WARNING: TLS certificate verification is skipped (InsecureSkipVerify: true) for HTTP source %s. This exposes all traffic for this source to Man-in-the-Middle (MITM) attacks. Do not use in production.", r.Name)
}
// Validate BaseURL
parsedURL, err := url.ParseRequestURI(r.BaseURL)
if err != nil {
return nil, fmt.Errorf("failed to parse BaseUrl %v", err)
}
allowedRanges, err := parseCIDRs(r.AllowedIPRanges)
if err != nil {
return nil, fmt.Errorf("invalid allowedIpRanges: %w", err)
}
customBlocked, err := parseCIDRs(r.CustomBlockedIPRanges)
if err != nil {
return nil, fmt.Errorf("invalid customBlockedIpRanges: %w", err)
}
guard := &SSRFGuard{
AllowPrivateNetworks: r.AllowPrivateNetworks,
AllowedRanges: allowedRanges,
CustomBlocked: customBlocked,
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Include the scheme: use "https://api.example.com" not "api.example.com"
- Trim whitespace and stray quotes from the configured value
- Verify the full BaseUrl with a quick curl or by parsing it in a scratch Go snippet using url.ParseRequestURI to confirm it passes
Example fix
// before baseUrl: api.example.com/v1 // after baseUrl: https://api.example.com/v1
Defensive patterns
Strategy: validation
Validate before calling
func validBaseURL(s string) bool {
u, err := url.ParseRequestURI(strings.TrimSpace(s))
return err == nil && (u.Scheme == "http" || u.Scheme == "https") && u.Host != ""
} Try / catch
src, err := cfg.Initialize(ctx, tracer)
if err != nil && strings.Contains(err.Error(), "failed to parse BaseUrl") {
log.Fatalf("BaseUrl must be an absolute URI with scheme, e.g. https://host: %v", err)
} Prevention
- Always include http:// or https:// in BaseUrl
- Trim whitespace/quotes when editing YAML values
- Validate the URL with url.ParseRequestURI before deploying configs
When it happens
Trigger: url.ParseRequestURI(r.BaseURL) returns non-nil err during Initialize: BaseUrl missing the scheme ("myhost.com" instead of "https://myhost.com"), empty string, relative path, embedded spaces, or otherwise malformed URI.
Common situations: Omitting https:// from the configured URL; trailing config typos; pasting a URL with surrounding whitespace/quotes; using a path-only value for internal services.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- error building req for endpoint [%v] : %v
- unable to parse Timeout string as time.Duration: %s
- invalid allowedIpRanges: %w
- failed to create request: %w
- %s is not a valid http method
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/d44309dba4722091.
Report an issue: GitHub.