{"record":{"id":"fa2b7e4642e74d39","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-fa2b7e","errorCode":null,"errorMessage":"invalid source for %q tool: source %q is not a compatible type","messagePattern":"invalid source for %q tool: source %q is not a compatible type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/mongodb/mongodbaggregate/mongodbaggregate.go","lineNumber":123,"sourceCode":"// validate interface\nvar _ tools.Tool = Tool{}\n\ntype Tool struct {\n\ttools.BaseTool[Config]\n}\n\nfunc (t Tool) GetSourceName() string {\n\treturn t.Cfg.Source\n}\n\nfunc (t Tool) ToConfig() tools.ToolConfig {\n\treturn t.Cfg\n}\n\nfunc (t Tool) ValidateSource(source sources.Source) error {\n\t_, ok := source.(compatibleSource)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid source for %q tool: source %q is not a compatible type\", t.Cfg.Type, t.Cfg.Source)\n\t}\n\treturn nil\n}\n\nfunc (t Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {\n\tsource, ok := s.(compatibleSource)\n\tif !ok {\n\t\treturn nil, util.NewClientServerError(\"source used is not compatible with the tool\", http.StatusInternalServerError, nil)\n\t}\n\tparamsMap := params.AsMap()\n\n\tcollection, tbErr := mongodbcommon.ResolveCollection(t.Cfg.Collection, paramsMap)\n\tif tbErr != nil {\n\t\treturn nil, tbErr\n\t}\n\n\tpipelineString, err := parameters.PopulateTemplateWithJSON(\"MongoDBAggregatePipeline\", t.Cfg.PipelinePayload, paramsMap)\n\tif err != nil {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/mongodb/mongodbaggregate/mongodbaggregate.go#L105-L141","documentation":"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.","triggerScenarios":"Binding mongodb-aggregate to a non-MongoDB source (e.g. postgres, http); ValidateSource runs at startup when tools are wired to sources.","commonSituations":"Wrong source name in the tool's `source` field; source replaced by a different kind; copy-paste errors in multi-source configs.","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"],"exampleFix":"// before\naggregate:\n  kind: mongodb-aggregate\n  source: my-postgres\n// after\naggregate:\n  kind: mongodb-aggregate\n  source: my-mongodb","handlingStrategy":"validation","validationCode":"if err := aggregateTool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"mongodb-aggregate %q: %w\", name, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["go","mongodb","source-binding","type-mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}