{"record":{"id":"fc1077dbad8ad326","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-fc1077","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/snowflake/snowflakeexecutesql/snowflakeexecutesql.go","lineNumber":101,"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\tmapParams := params.AsMap()\n\tsqlStr, ok := mapParams[\"sql\"].(string)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(\"invalid parameters: sql parameter is not a string\", nil)\n\t}\n\n\t// Log the query executed for debugging.\n\tlogger, err := util.LoggerFromContext(ctx)\n\tif err != nil {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/snowflake/snowflakeexecutesql/snowflakeexecutesql.go#L83-L119","documentation":"This error comes from Tool.ValidateSource in the snowflake-execute-sql tool. MCP Toolbox validates at startup that every tool's configured source implements the tool's compatibleSource interface (a Spanner/Snowflake source exposing the client and RunSQL methods). If the source named in the tool's YAML config resolves to a source of a different type, the type assertion fails and this error is thrown.","triggerScenarios":"Calling ValidateSource (directly or via toolbox startup/config loading) when the tool's `source` field points to a source whose concrete type does not implement compatibleSource (e.g. a postgres or alloydb source wired to a snowflake-execute-sql tool).","commonSituations":"Copy-pasting a tools.yaml between projects where the tool's `source` name matches but points to the wrong kind of source; refactoring source names so two sources swap; using prebuilt configs against a source of the wrong engine.","solutions":["Check the `source:` field of the snowflake-execute-sql tool in your YAML and point it at a source defined with kind snowflake (or another type implementing the tool's compatibleSource interface).","Run the toolbox binary with your config; ValidateSource runs at startup and will name the offending tool and source, letting you fix the mapping.","If defining sources programmatically, ensure the Source passed to ValidateSource is the concrete snowflake source type, not a wrapper or different source."],"exampleFix":"// before (tools.yaml)\ntools:\n  execute-sql:\n    kind: snowflake-execute-sql\n    source: my-postgres-source\n// after\ntools:\n  execute-sql:\n    kind: snowflake-execute-sql\n    source: my-snowflake-source","handlingStrategy":"validation","validationCode":"func isSnowflakeCompatible(s sources.Source) bool {\n\t_, ok := s.(interface {\n\t\tSnowflakeClient() *sql.DB\n\t\tRunSQL(context.Context, string, map[string]any) (any, error)\n\t})\n\treturn ok\n}\n// before registering the tool:\n// if !isSnowflakeCompatible(cfg.Source) { return fmt.Errorf(\"tool %q requires a snowflake source\", name) }","typeGuard":"func asCompatibleSource(s sources.Source) (compatibleSource, bool) {\n\tcs, ok := s.(compatibleSource)\n\treturn cs, ok\n}","tryCatchPattern":null,"preventionTips":["Keep tool `source:` references pointing at sources of the matching kind; audit tools.yaml after renames.","Run the toolbox once against your config in CI; ValidateSource fails fast at startup.","Name sources after their engine (e.g. `snowflake-prod`) to make mismatches obvious."],"tags":["go","snowflake","config","source-validation"],"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"}