googleapis/mcp-toolbox · error
invalid source for %q tool: source %q is not a compatible ty
Error message
invalid source for %q tool: source %q is not a compatible type
What it means
RequiresClientAuthorization on the cloudloggingadmin-list-resource-types tool asserts the injected source implements compatibleSource so it can query UseClientAuthorization(). A source of an incompatible Go type makes the assertion fail and the method returns this error instead of a boolean. The tool cannot determine its auth behavior without the right source type.
Source
Thrown at internal/tools/cloudloggingadmin/cloudloggingadminlistresourcetypes/cloudloggingadminlistresourcetypes.go:112
var err error
if source.UseClientAuthorization() {
tokenString, err = accessToken.ParseBearerToken()
if err != nil {
return nil, util.NewClientServerError("failed to parse access token", http.StatusUnauthorized, err)
}
}
resp, err := source.ListResourceTypes(ctx, tokenString)
if err != nil {
return nil, util.ProcessGcpError(err)
}
return resp, nil
}
func (t Tool) RequiresClientAuthorization(source sources.Source) (bool, error) {
s, ok := source.(compatibleSource)
if !ok {
return false, fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
}
return s.UseClientAuthorization(), nil
}
func (t Tool) GetSourceName() string {
return t.Cfg.Source
}
func (t Tool) ToConfig() tools.ToolConfig {
return t.Cfg
}
func (t Tool) ValidateSource(source sources.Source) error {
_, ok := source.(compatibleSource)
if !ok {
return fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
}
return nilView on GitHub (pinned to 8cc6e09de2)
Solutions
- Bind the tool to a cloud-logging-admin source (one implementing compatibleSource).
- If using a custom source wrapper, add a UseClientAuthorization() bool method so it satisfies compatibleSource.
- Validate the config before serving so the mismatch surfaces at startup rather than during a request.
Example fix
// before (custom source)
type mySource struct{}
func (s mySource) SourceType() string { return "my-source" }
// after
type mySource struct{ UseClientAuth bool }
func (s mySource) SourceType() string { return "my-source" }
func (s mySource) UseClientAuthorization() bool { return s.UseClientAuth } Defensive patterns
Strategy: type-guard
Validate before calling
// Go: assert source compatibility before invoking the tool
if _, ok := src.(compatibleSource); !ok {
return false, fmt.Errorf("source %T does not support client authorization checks", src)
} Type guard
func toCompatibleSource(s sources.Source) (compatibleSource, error) {
if cs, ok := s.(compatibleSource); ok {
return cs, nil
}
return nil, fmt.Errorf("incompatible source type %T", s)
} Try / catch
useClientAuth, err := tool.RequiresClientAuthorization(src)
if err != nil {
return fmt.Errorf("source binding invalid for tool %q: %w", tool.GetName(), err)
} Prevention
- Bind each tool only to sources of the matching kind.
- Add compile-time assertions like `var _ compatibleSource = mySource{}` for custom sources.
- Re-check source bindings after any refactor or toolbox version bump.
When it happens
Trigger: Invoking the tool (server startup or per-call auth resolution) when the tool's configured source is not a Cloud Logging Admin-compatible source, e.g. a database source or a wrapped custom source missing UseClientAuthorization().
Common situations: Binding the tool to a source of the wrong kind in tools.yaml; custom sources implementing sources.Source but not the compatibleSource interface; refactors that changed the source's Go type after an upgrade.
Related errors
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/bd3b354806d55424.
Report an issue: GitHub.