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 redis tool's ValidateSource method when the source named in the tool's YAML config does not implement the tool's `compatibleSource` interface (a source exposing a RedisClient and RunCommand). MCP Toolbox tools are decoupled from concrete source types, so at startup each tool type-asserts its configured source; a failed assertion means the tool was wired to a source it cannot send Redis commands to.

Source

Thrown at internal/tools/redis/redis.go:99

// validate interface
var _ tools.Tool = 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
}

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)
	}
	cmds, err := replaceCommandsParams(t.Cfg.Commands, t.Cfg.Parameters, params)
	if err != nil {
		return nil, util.NewAgentError("error replacing commands' parameters", err)
	}
	resp, err := source.RunCommand(ctx, cmds)
	if err != nil {
		return nil, util.ProcessGeneralError(err)
	}
	return resp, nil

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Change the tool's `source:` field to a Redis source (kind: redis) defined in `sources:`
  2. Confirm the source implements RedisClient()/RunCommand
  3. Validate the config locally before deploying

Example fix

# before
kind: redis
source: postgres-prod
# after
kind: redis
source: redis-cache
Defensive patterns

Strategy: validation

Validate before calling

if _, ok := any(myRedisSource).(interface {
	RedisClient() redissrc.RedisClient
	RunCommand(context.Context, [][]any) (any, error)
}); !ok {
	log.Fatalf("source is not compatible with redis tools")
}

Type guard

func isCompatibleRedisSource(s sources.Source) bool {
	_, ok := s.(interface {
		RedisClient() redissrc.RedisClient
		RunCommand(context.Context, [][]any) (any, error)
	})
	return ok
}

Prevention

When it happens

Trigger: Server startup/config validation when a tool of `kind: redis` references a `source:` whose registered source does not satisfy the compatibleSource interface (e.g. postgres, mysql, http sources).

Common situations: Copy-pasted tool entries with stale `source:` names; pointing the redis tool at a non-Redis source; renaming sources without updating tool references.

Related errors


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