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

This error is thrown by the postgres-list-tablespaces tool's ValidateSource method when the source named in the tool's YAML config does not implement the tool's `compatibleSource` interface (a Postgres-backed source exposing a pgx pool). MCP Toolbox tools are decoupled from concrete source types, so at startup each tool type-asserts its configured source; the assertion failing means the tool was wired to a source it cannot use.

Source

Thrown at internal/tools/postgres/postgreslisttablespaces/postgreslisttablespaces.go:148

	resp, err := source.RunSQL(ctx, listTableSpacesStatement, []any{tablespaceName, limit})
	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

  1. Change the tool's `source:` field in tools.yaml to the name of a Postgres source defined in the `sources:` section
  2. Verify the referenced source kind supports Postgres tools (its Go type implements PostgresPool()/RunSQL) — e.g. `kind: postgres`
  3. Run `./toolbox --tools-file tools.yaml` or the config validate command locally to catch the mismatch before deployment

Example fix

# before
tools:
  list-ts:
    kind: postgres-list-tablespaces
    source: my-redis-source
# after
tools:
  list-ts:
    kind: postgres-list-tablespaces
    source: my-postgres-source
Defensive patterns

Strategy: validation

Validate before calling

// before starting the server, assert the source is compatible
var _ sources.Source = myPostgresSource
if _, ok := any(myPostgresSource).(interface {
	PostgresPool() *pgxpool.Pool
	RunSQL(context.Context, string, []any) (any, error)
}); !ok {
	log.Fatalf("source %q is not compatible with postgres-list-tablespaces", "my-postgres-source")
}

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: Server startup/config validation when a tool of `kind: postgres-list-tablespaces` references a `source:` whose registered source does not satisfy the compatibleSource interface (e.g. a non-Postgres source like redis, mysql, http, or a Postgres variant lacking the required methods).

Common situations: Copy-pasting a tool entry and forgetting to update the `source:` field; pointing postgres tools at a cloud-sql or alloydb source variant that does not implement PostgresPool()/the required methods; renaming sources and leaving stale references in tools.yaml.

Related errors


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