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-tables tool's ValidateSource fails because the attached source does not implement compatibleSource (PostgresPool() *pgxpool.Pool and RunSQL). Only Postgres-family sources can back this tool, since it queries Postgres catalogs through the pgx pool. Validation occurs at startup when the tool is bound to its named source.

Source

Thrown at internal/tools/postgres/postgreslisttables/postgreslisttables.go:204

	resSlice, ok := resp.([]any)
	if !ok || len(resSlice) == 0 {
		return []any{}, nil
	}
	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

  1. Point `source:` at a Postgres-family source (postgres, cloud-sql-postgres, alloydb-postgres).
  2. Verify the source is defined in `sources:` with a Postgres `kind`.
  3. Use the engine-appropriate equivalent tool if the source is not Postgres.
  4. Regenerate from the matching prebuilt config instead of manual edits.

Example fix

# before
tools:
  list-tables:
    kind: postgres-list-tables
    source: mysql-app
# after
tools:
  list-tables:
    kind: postgres-list-tables
    source: pg-app
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-tables 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

When it happens

Trigger: A `postgres-list-tables` tool whose `source:` points to a non-Postgres source kind (mysql, mssql, sqlite, http, etc.) or to a nonexistent/misspelled source name.

Common situations: Cross-engine copy-paste of tool configs; renamed sources not updated in tools; mixing cloud-sql-mysql sources with postgres tools; typo'd prebuilt-config merges.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/184234048d7fc752. Report an issue: GitHub.