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 mongodb-aggregate asserts the attached source implements the MongoDB compatibleSource interface (which provides the Mongo client/database). Any other source kind is rejected with this error since the tool cannot execute a pipeline against it.
Source
Thrown at internal/tools/mongodb/mongodbaggregate/mongodbaggregate.go:123
// 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
}
pipelineString, err := parameters.PopulateTemplateWithJSON("MongoDBAggregatePipeline", t.Cfg.PipelinePayload, paramsMap)
if err != nil {View on GitHub (pinned to 8cc6e09de2)
Solutions
- Point the tool at a source of kind `mongodb`
- Verify the source name exists under `sources:` in tools.yaml
- Validate the full config locally before deployment
Example fix
// before aggregate: kind: mongodb-aggregate source: my-postgres // after aggregate: kind: mongodb-aggregate source: my-mongodb
Defensive patterns
Strategy: validation
Validate before calling
if err := aggregateTool.ValidateSource(src); err != nil {
return fmt.Errorf("mongodb-aggregate %q: %w", name, err)
} Prevention
- Bind mongodb tools only to `kind: mongodb` sources
- Dry-start the toolbox to surface ValidateSource errors early
- Keep a naming convention mapping source kind in the name
When it happens
Trigger: Binding mongodb-aggregate to a non-MongoDB source (e.g. postgres, http); ValidateSource runs at startup when tools are wired to sources.
Common situations: Wrong source name in the tool's `source` field; source replaced by a different kind; copy-paste errors in multi-source configs.
Related errors
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- 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/fa2b7e4642e74d39.
Report an issue: GitHub.