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

Tool.ValidateSource for the Firebird execute-sql tool fails when the injected source does not implement the tool's compatibleSource interface (i.e., it is not a Firebird source). The error reports the tool's configured type and source name so the developer can see the mismatch.

Source

Thrown at internal/tools/firebird/firebirdexecutesql/firebirdexecutesql.go:99

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)
	}
	paramsMap := params.AsMap()
	sqlStr, ok := paramsMap["sql"].(string)
	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("unable to cast parameter 'sql' to string: %v", paramsMap["sql"]), nil)
	}

	// Log the query executed for debugging.
	logger, err := util.LoggerFromContext(ctx)
	if err != nil {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's 'source' field to the name of a Firebird source (kind: firebird).
  2. Verify the sources section declares the source with the correct kind.
  3. Re-validate config with `toolbox --prebuilt` or run the server to confirm source-tool compatibility.

Example fix

// before
tools:
  execute_sql:
    kind: firebird-execute-sql
    source: my-postgres
// after
tools:
  execute_sql:
    kind: firebird-execute-sql
    source: my-firebird
Defensive patterns

Strategy: validation

Validate before calling

# Verify tool's source kind matches before load
cfg = yaml.safe_load(open('config.yaml'))
src = cfg['sources'][tool['source']]
assert src['kind'] == 'firebird', "firebird-execute-sql requires a firebird source"

Try / catch

if err := tool.ValidateSource(src); err != nil {
    log.Fatalf("source mismatch: %v (bind the tool to a 'kind: firebird' source)", err)
}

Prevention

When it happens

Trigger: A tools YAML config references a source name that maps to a non-Firebird source kind (e.g., a Postgres source) for a firebird-execute-sql tool; or the source failed to initialize and a different/uninitialized source is injected.

Common situations: Copy-pasting tool configs between source kinds without updating the 'source' field; source kind typos causing fallback type mismatch; wiring a shared tool to the wrong source kind.

Related errors


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