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
The postgres-list-roles tool's ValidateSource fails because the bound source does not implement compatibleSource (PostgresPool() *pgxpool.Pool and RunSQL). Only Postgres-family sources expose a pgx pool, so any other source kind is rejected. This surfaces at startup when tools are resolved against sources.
Source
Thrown at internal/tools/postgres/postgreslistroles/postgreslistroles.go:161
resp, err := source.RunSQL(ctx, listRolesStatement, sliceParams)
if err != nil {
return nil, util.ProcessGeneralError(err)
}
return resp, 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 nil
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Point `source:` at a Postgres-family source (postgres, cloud-sql-postgres, alloydb-postgres).
- Verify the source key exists in `sources:` and its kind is Postgres-based.
- Swap in the correct tool for your engine if not on Postgres.
Example fix
# before
tools:
list-roles:
kind: postgres-list-roles
source: mysql-prod
# after
tools:
list-roles:
kind: postgres-list-roles
source: pg-prod Defensive patterns
Strategy: validation
Validate before calling
src := myConfig.sources[tool.Source]
if _, ok := src.(interface {
PostgresPool() *pgxpool.Pool
RunSQL(context.Context, string, []any) (any, error)
}); !ok {
return fmt.Errorf("postgres-list-roles requires a Postgres-family source, got %T", src)
} Type guard
func isCompatiblePostgresSource(s sources.Source) bool {
_, ok := s.(interface {
PostgresPool() *pgxpool.Pool
RunSQL(context.Context, string, []any) (any, error)
})
return ok
} Prevention
- Pair role-listing tools exclusively with Postgres kinds.
- Keep one config file per database engine to prevent cross-engine tool reuse.
- Validate configs at startup in CI.
When it happens
Trigger: A `postgres-list-roles` tool whose `source:` points to a non-Postgres source (mysql, mssql, sqlite, http, etc.) or to an undefined/misspelled source.
Common situations: Hand-maintained configs spanning engines; renamed sources; combining cloud-sql-mysql with postgres tools after copying a template.
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/b3d3f7712d9fa73b.
Report an issue: GitHub.