{"record":{"id":"4767ce1b8a424dd4","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-4767ce","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/mongodbdeletemany/mongodbdeletemany.go","lineNumber":121,"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\tfilterString, err := parameters.PopulateTemplateWithJSON(\"MongoDBDeleteManyFilter\", t.Cfg.FilterPayload, paramsMap)\n\tif err != nil {","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/mongodb/mongodbdeletemany/mongodbdeletemany.go#L103-L139","documentation":"Tool.ValidateSource for mongodb-delete-many rejects sources that do not implement the MongoDB compatibleSource interface. The tool needs a Mongo client from the source to delete documents; an incompatible source type cannot supply one, so the mismatch fails validation.","triggerScenarios":"Attaching mongodb-delete-many to a non-MongoDB source in tools.yaml; the server invokes ValidateSource for each tool/source pair at startup.","commonSituations":"Tool `source` field pointing at the wrong named source; source kind swapped (e.g. from mongodb to firestore); copy-paste across tool blocks.","solutions":["Set the tool's `source` to a `mongodb` kind source","Check that the referenced source name exists under `sources:`","Run a local config validation/start before deploying"],"exampleFix":"// before\ndelete-many:\n  kind: mongodb-delete-many\n  source: my-mysql\n// after\ndelete-many:\n  kind: mongodb-delete-many\n  source: my-mongodb","handlingStrategy":"validation","validationCode":"if err := deleteManyTool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"mongodb-delete-many %q: %w\", name, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Attach mongodb-delete-many only to MongoDB sources","Validate all tool/source bindings at startup","Audit source references when renaming or changing source kinds"],"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"}