{"record":{"id":"a8c0b30592685870","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-a8c0b3","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/clickhouse/clickhouselistdatabases/clickhouselistdatabases.go","lineNumber":100,"sourceCode":"\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\t// Query to list all databases\n\tquery := \"SHOW DATABASES\"\n\n\tout, err := source.RunSQL(ctx, query, nil)\n\tif err != nil {\n\t\treturn nil, util.ProcessGeneralError(err)\n\t}\n\n\treturn out, nil","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/clickhouse/clickhouselistdatabases/clickhouselistdatabases.go#L82-L118","documentation":"Same family as error 1140: clickhouse-list-databases' ValidateSource type-asserts the incoming sources.Source to its private `compatibleSource` interface and errors when the source is any other kind. This guards that the tool only runs against ClickHouse sources.","triggerScenarios":"Server startup or tool invocation where the tool's bound source is not a ClickHouse source (wrong `source:` reference in YAML, or programmatic registration of a non-compatible source).","commonSituations":"Miswired tool-to-source references in toolbox YAML; sharing one tool definition across multiple source kinds; tests passing a mock source that doesn't implement the accessor interface.","solutions":["Point the tool at a `clickhouse`-kind source.","Check for copy/paste mistakes in the `source:` field of the tool config.","For custom sources, satisfy the compatibleSource interface the tool asserts."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the tool against its bound source during setup\nif err := tool.ValidateSource(mySource); err != nil {\n    return fmt.Errorf(\"tool/source wiring invalid: %w\", err)\n}","typeGuard":"func isCompatible(s sources.Source) bool {\n    _, ok := s.(interface{ DB() *sql.DB })\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Call ValidateSource once at startup for every tool/source pair.","Never reuse a single tool definition across different source kinds.","Add CI checks that load the full tools YAML."],"tags":["clickhouse","source-compatibility","config","type-assertion"],"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"}