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
ValidateSource for the alloydb-alloydbcreatecluster tool asserts the injected sources.Source implements the tool's compatibleSource interface (an AlloyDB admin source with UseClientAuthorization and GetDefaultProject). A source of any other kind fails the assertion and this error is returned, blocking the tool from running against an incompatible source.
Source
Thrown at internal/tools/alloydb/alloydbcreatecluster/alloydbcreatecluster.go:101
}
// Tool represents the create-cluster tool.
type Tool struct {
tools.BaseTool[Config]
}
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 nil
}
// Invoke executes the tool's logic.
func (t Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {
source, ok := s.(compatibleSource)
if !ok {
return nil, util.NewClientServerError("source used is not compatible with the tool", http.StatusInternalServerError, nil)
}
paramsMap := params.AsMap()
project, ok := paramsMap["project"].(string)
if !ok || project == "" {
return nil, util.NewAgentError("invalid or missing 'project' parameter; expected a non-empty string", nil)
}
location, ok := paramsMap["location"].(string)
if !ok {View on GitHub (pinned to 8cc6e09de2)
Solutions
- Set the tool's `source` field to an AlloyDB admin source (kind: alloydb)
- Verify the referenced source in the `sources:` block declares the correct kind
- Restart the toolbox and confirm the tool registers without error
Example fix
// before
tools:
create-cluster:
kind: alloydb-alloydbcreatecluster
source: my-postgres-source
// after
tools:
create-cluster:
kind: alloydb-alloydbcreatecluster
source: my-alloydb-admin-source Defensive patterns
Strategy: validation
Validate before calling
// config sanity check before startup
src, ok := sources[toolCfg.Source]
if !ok || src.SourceType() != "alloydb" {
return fmt.Errorf("tool %q requires an alloydb admin source, got %T", toolCfg.Name, src)
} Type guard
func asCompatibleSource(s sources.Source) (compatibleSource, bool) {
cs, ok := s.(compatibleSource)
return cs, ok
} Try / catch
if err := tool.ValidateSource(src); err != nil {
log.Fatalf("tool misconfigured: %v", err)
} Prevention
- Match each admin tool's source to a kind: alloydb source
- Validate config at startup before serving traffic
- Use source names descriptive of their kind
When it happens
Trigger: Configuring the alloydb-alloydbcreatecluster tool with a `source` entry whose kind is not the AlloyDB admin source (e.g. postgres or alloydb-postgres); assertion runs at startup validation or during tool registration.
Common situations: Copy-pasted YAML where `source:` points at a SQL source; renamed/restructured config entries; mixing alloydb-postgres and alloydb admin sources in one config.
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
- could not marshal operation: %w
- failed to unmarshal operation bytes: %w
- unable to create pool: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/fe829b527f7df359.
Report an issue: GitHub.