{"record":{"id":"893e20d15412c789","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-893e20","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/mongodbfind/mongodbfind.go","lineNumber":132,"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 getOptions(ctx context.Context, sortParameters parameters.Parameters, projectPayload string, limit int64, paramsMap map[string]any) (*options.FindOptionsBuilder, error) {\n\tlogger, err := util.LoggerFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\topts := options.Find()\n\n\tsort := bson.M{}\n\tfor _, p := range sortParameters {\n\t\tsort[p.GetName()] = paramsMap[p.GetName()]\n\t}\n\topts = opts.SetSort(sort)\n","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/mongodb/mongodbfind/mongodbfind.go#L114-L150","documentation":"Identical source-compatibility guard as mongodb-delete-one: mongodbfind.Tool.ValidateSource asserts the provided source implements the MongoDB compatibleSource interface. Any non-MongoDB source bound to a mongodb-find tool produces this error with the tool type and configured source name.","triggerScenarios":"A mongodb-find tool referencing a postgres/mysql/mssql or other non-MongoDB source in tools.yaml; passing a wrong sources.Source implementation at runtime.","commonSituations":"Reusing a tool block across configs with the old source name; switching a source's kind without updating tools; source-name typos resolving to another source.","solutions":["Point the tool's source at a MongoDB-based source kind.","Verify the source name exists and its kind is MongoDB-compatible.","Programmatic usage: pass the MongoDB source instance, not another engine's."],"exampleFix":"# before\n  find:\n    kind: mongodb-find\n    source: my-mysql\n# after\n  find:\n    kind: mongodb-find\n    source: my-mongo","handlingStrategy":"type-guard","validationCode":"if err := tool.ValidateSource(src); err != nil { /* fix tools.yaml source binding */ }","typeGuard":"func 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(\"mongodb-find bound to non-Mongo source %q: %w\", srcName, err)\n}","preventionTips":["Match tool kind and source kind one-to-one in tools.yaml.","Run toolbox with config validation early (startup) to catch mismatches.","Avoid sharing one tool definition across different engine sources."],"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"}