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 checks that the source instance passed to the tool implements the tool's compatibleSource interface (a MongoDB source). If the source wired to this mongodb-delete-one tool is any other type, validation fails with this message naming the tool type and the configured source name. It guards against misconfigured tool-to-source bindings before any DB call is made.
Source
Thrown at internal/tools/mongodb/mongodbdeleteone/mongodbdeleteone.go:121
// 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)
}
paramsMap := params.AsMap()
collection, tbErr := mongodbcommon.ResolveCollection(t.Cfg.Collection, paramsMap)
if tbErr != nil {
return nil, tbErr
}
filterString, err := parameters.PopulateTemplateWithJSON("MongoDBDeleteOneFilter", t.Cfg.FilterPayload, paramsMap)
if err != nil {View on GitHub (pinned to 8cc6e09de2)
Solutions
- Set the tool's source to a MongoDB-based source kind (mongodb, mongodb-atlas, etc.).
- Confirm the referenced source name exists in the sources section and is of a MongoDB type.
- If composing sources programmatically, pass the *mongodb.Source (or compatible implementation) to the tool.
Example fix
# before
sources:
my-pg:
kind: postgres
uri: postgres://...
tools:
del:
kind: mongodb-delete-one
source: my-pg
# after
sources:
my-mongo:
kind: mongodb
uri: mongodb://...
tools:
del:
kind: mongodb-delete-one
source: my-mongo Defensive patterns
Strategy: type-guard
Validate before calling
// Go: check compatibility before invoking
var src sources.Source = mySource
if _, ok := src.(mongodbdeleteonecompatibleSourcePlaceholder); !ok { /* use the tool's ValidateSource instead */ }
if err := tool.ValidateSource(mySource); err != nil { /* reconfigure */ } Type guard
// Go: narrow to the MongoDB source family by checking kind
func isMongoSource(s sources.Source) bool {
type mongoSrc interface{ SourceType() string }
if m, ok := s.(mongoSrc); ok {
t := m.SourceType()
return t == "mongodb" || t == "mongodb-atlas"
}
return false
} Try / catch
if err := t.ValidateSource(src); err != nil {
return fmt.Errorf("source binding invalid, reconfigure tools.yaml: %w", err)
} Prevention
- Keep each tool's source pointing at the same engine family as the tool kind.
- After changing a source's kind, grep configs for tools referencing it.
- Validate the whole config at startup so mismatches surface before serving traffic.
When it happens
Trigger: A tools.yaml where a mongodb-delete-one tool references a source whose kind is not MongoDB (e.g. postgres, cloud-sql-postgres); programmatically passing a wrong sources.Source implementation to Invoke/ValidateSource.
Common situations: Copy-pasting tool definitions between configs and leaving the old source name; changing a source's kind without updating dependent tools; typos in source names that resolve to a different source.
Related errors
- invalid source for %q tool: source %q is not a compatible ty
- description is required for tool %q
- description is required for tool %q
- 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/14e0f4d90b564ce0.
Report an issue: GitHub.