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-query-stats tool's ValidateSource rejects the configured source because it lacks the compatibleSource methods (PostgresPool() *pgxpool.Pool, RunSQL). Query stats read pg_stat_statements-style data, which only Postgres-family sources can provide. The check happens when the tool is initialized and bound to the source.
Source
Thrown at internal/tools/postgres/postgreslistquerystats/postgreslistquerystats.go:140
resp, err := source.RunSQL(ctx, listQueryStats, 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
- Set `source:` to a Postgres-family source (postgres, cloud-sql-postgres, alloydb-postgres).
- Ensure the source is defined in `sources:` with a Postgres `kind`.
- Use the correct engine-specific tool if you are not on Postgres.
Example fix
# before
tools:
query-stats:
kind: postgres-list-query-stats
source: my-sqlite
# after
tools:
query-stats:
kind: postgres-list-query-stats
source: my-postgres 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-query-stats 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
- Attach query-stats tools only to Postgres-family sources (pg_stat_statements is Postgres-only).
- Verify source names exist in `sources:` after refactors.
- Run a config validation/smoke test in CI.
When it happens
Trigger: A `postgres-list-query-stats` tool whose `source:` names a source of an incompatible kind (mysql, mssql, sqlite, http, etc.) or a nonexistent source key.
Common situations: Copy-pasting tool defs between database configs; referencing cloud-sql-mysql sources from postgres tools; typos in the source name.
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/092bba4d7426859d.
Report an issue: GitHub.