{"record":{"id":"14e0f4d90b564ce0","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-14e0f4","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/mongodbdeleteone/mongodbdeleteone.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(\"MongoDBDeleteOneFilter\", t.Cfg.FilterPayload, paramsMap)\n\tif err != nil {","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/mongodb/mongodbdeleteone/mongodbdeleteone.go#L103-L139","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nsources:\n  my-pg:\n    kind: postgres\n    uri: postgres://...\ntools:\n  del:\n    kind: mongodb-delete-one\n    source: my-pg\n# after\nsources:\n  my-mongo:\n    kind: mongodb\n    uri: mongodb://...\ntools:\n  del:\n    kind: mongodb-delete-one\n    source: my-mongo","handlingStrategy":"type-guard","validationCode":"// Go: check compatibility before invoking\nvar src sources.Source = mySource\nif _, ok := src.(mongodbdeleteonecompatibleSourcePlaceholder); !ok { /* use the tool's ValidateSource instead */ }\nif err := tool.ValidateSource(mySource); err != nil { /* reconfigure */ }","typeGuard":"// Go: narrow to the MongoDB source family by checking kind\nfunc isMongoSource(s sources.Source) bool {\n    type mongoSrc interface{ SourceType() string }\n    if m, ok := s.(mongoSrc); ok {\n        t := m.SourceType()\n        return t == \"mongodb\" || t == \"mongodb-atlas\"\n    }\n    return false\n}","tryCatchPattern":"if err := t.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"source binding invalid, reconfigure tools.yaml: %w\", err)\n}","preventionTips":["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."],"tags":["go","mongodb","source-compatibility","tool-configuration"],"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"}