{"record":{"id":"eeadbb3e4a7a61cd","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-eeadbb","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/spanner/spannersql/spannersql.go","lineNumber":176,"sourceCode":"\tresp, err := source.RunSQL(ctx, t.Cfg.ReadOnly, newStatement, mapParams)\n\tif err != nil {\n\t\treturn nil, util.ProcessGcpError(err)\n\t}\n\treturn resp, nil\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","sourceCodeStart":158,"sourceCodeEnd":180,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/spanner/spannersql/spannersql.go#L158-L180","documentation":"The Spanner execute-sql tool's ValidateSource checks that the resolved source implements the compatibleSource interface (a Spanner source exposing a *spanner.Client). If the source bound to this tool is a different kind of source (e.g. Postgres, SQLite), the type assertion fails and this error is returned. Tools may only run against sources of the matching engine type.","triggerScenarios":"Invoking or validating a spanner tool whose YAML config points `source` at a source declared with a kind other than `spanner`; programmatically passing a non-Spanner sources.Source to Tool.Invoke or ValidateSource.","commonSituations":"Copy-pasting a tools.yaml and forgetting to update the `source:` field; renaming sources so the tool binds to the wrong source; dynamically assembling configs where a generic SQL tool is attached to every source regardless of engine.","solutions":["Change the tool's `source:` field in the YAML to the name of a source whose `kind` is `spanner`.","Declare a `sources:` entry of kind `spanner` if none exists, then point the tool at it.","If using multiple sources, verify each tool references the source matching its engine type.","Add a startup config check so source/tool compatibility is validated before serving."],"exampleFix":"# before\nsources:\n  my-pg:\n    kind: postgres\n    uri: ...\ntools:\n  run-query:\n    kind: spanner-execute-sql\n    source: my-pg\n# after\nsources:\n  my-spanner:\n    kind: spanner\n    project: my-project\n    instance: my-instance\n    database: my-db\ntools:\n  run-query:\n    kind: spanner-execute-sql\n    source: my-spanner","handlingStrategy":"type-guard","validationCode":"# Validate before running:\ngrep -A2 'kind: spanner' tools.yaml   # confirm a spanner source exists\n# and that the tool's source: field references it\nyq '.tools[] | select(.kind == \"spanner-execute-sql\") | .source' tools.yaml","typeGuard":"func isSpannerSource(s sources.Source) bool {\n    _, ok := s.(spannersql.CompatibleSource)\n    return ok\n}","tryCatchPattern":"tool, err := myTool.ValidateSource(src)\nif err != nil {\n    log.Fatalf(\"source binding mismatch: %v (check tools.yaml source: field)\", err)\n}","preventionTips":["Keep one source per engine and name tools after their source.","Validate the full tools.yaml at startup before serving.","Never share a single tool definition across different engine sources.","Use schema/IDE validation for tools.yaml kinds and source refs."],"tags":["go","config","source-binding","spanner"],"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"}