{"record":{"id":"c7ab77e418a80eaa","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-c7ab77","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/clickhouseexecutesql/clickhouseexecutesql.go","lineNumber":97,"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\tsql, ok := paramsMap[\"sql\"].(string)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"unable to cast sql parameter %s\", paramsMap[\"sql\"]), nil)\n\t}\n\tresp, err := source.RunSQL(ctx, sql, nil)\n\tif err != nil {\n\t\treturn nil, util.ProcessGeneralError(err)\n\t}","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/clickhouse/clickhouseexecutesql/clickhouseexecutesql.go#L79-L115","documentation":"Tool.ValidateSource rejects a source whose Go type does not implement the tool's private `compatibleSource` interface (a ClickHouse source with a DB() accessor). The toolbox only allows a tool to run against sources declared as compatible with it; any other source type fails this check before Invoke is called. It is a config/wiring error surfaced as a defensive runtime check.","triggerScenarios":"Calling (or the server invoking) clickhouse-execute-sql's ValidateSource with a sources.Source that is not internal/sources/clickhouse.Source, e.g. a Postgres/BigQuery source attached to a ClickHouse tool in the tools YAML.","commonSituations":"YAML config where the tool's `source:` points at a differently-typed source; copying a tool config between database kinds; refactoring that renamed/moved the ClickHouse source type so the assertion no longer matches.","solutions":["Set the tool's `source:` field to a source defined with kind `clickhouse` in the same config.","Verify the source initializes successfully (its kind maps to the ClickHouse Source implementation).","If you intend a custom source, make it implement the same interface (DB() *sql.DB accessor) the tool asserts."],"exampleFix":"// before\ntools:\n  execute-sql:\n    source: my-postgres-source\n// after\ntools:\n  execute-sql:\n    source: my-clickhouse-source","handlingStrategy":"validation","validationCode":"// Go: before wiring the tool, assert the source is compatible\nif _, ok := mySource.(sources.Source); !ok {\n    return fmt.Errorf(\"source does not implement sources.Source\")\n}\n// and confirm the YAML `source:` points at a clickhouse-kind source","typeGuard":"func isClickhouseSource(s sources.Source) bool {\n    _, ok := s.(interface{ DB() *sql.DB })\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Always pair clickhouse tools with a `kind: clickhouse` source in the YAML.","Run `toolbox --tools-file` load validation before deploying.","Add a startup test that initializes every tool from your config."],"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"}