{"record":{"id":"9bce71c380d354fe","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-9bce71","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/clickhousesql/clickhousesql.go","lineNumber":103,"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\tparamsMap := params.AsMap()\n\tnewStatement, err := parameters.ResolveTemplateParams(t.Cfg.TemplateParameters, t.Cfg.Statement, paramsMap)\n\tif err != nil {\n\t\treturn nil, util.NewAgentError(\"unable to extract template params\", err)\n\t}\n\n\tnewParams, err := parameters.GetParams(t.Cfg.Parameters, paramsMap)\n\tif err != nil {\n\t\treturn nil, util.NewAgentError(\"unable to extract standard params\", err)","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/clickhouse/clickhousesql/clickhousesql.go#L85-L121","documentation":"clickhouse-sql.ValidateSource type-asserts the given sources.Source against the tool's private `compatibleSource` interface (ClickHouse source with a *sql.DB accessor) and returns this error on mismatch. It is the toolbox's mechanism to keep tools and sources of matching kinds wired together.","triggerScenarios":"Binding clickhouse-sql to any non-ClickHouse source — a wrong `source:` name in YAML resolving to another kind, or passing an incompatible source programmatically/in tests.","commonSituations":"Copy-pasting tool configs across database examples; multiple sources defined and the wrong one referenced; custom source implementations missing the expected accessor.","solutions":["Set the tool's `source:` to a clickhouse-kind source.","Double-check source name spelling and that it is defined in `sources:`.","Implement the compatibleSource interface if using a custom source."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Fail fast at server startup\nfor _, t := range loadedTools {\n    if err := t.Tool.ValidateSource(t.Source); err != nil {\n        return fmt.Errorf(\"tool %q: %w\", t.Tool.GetName(), err)\n    }\n}","typeGuard":"func ok(s sources.Source) bool { _, good := s.(interface{ DB() *sql.DB }); return good }","tryCatchPattern":null,"preventionTips":["Verify source names resolve to clickhouse sources before serving traffic.","Keep tool and source naming conventions aligned (clickhouse-* tools -> clickhouse sources).","Test with `toolbox --tools-file ... --prebuilt` style load checks."],"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"}