{"record":{"id":"1d40500d993657dd","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-1d4050","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/serverlessspark/serverlesssparkgetbatch/serverlesssparkgetbatch.go","lineNumber":129,"sourceCode":"\tresp, err := source.GetBatch(ctx, name)\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":111,"sourceCodeEnd":133,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/serverlessspark/serverlesssparkgetbatch/serverlesssparkgetbatch.go#L111-L133","documentation":"This error is thrown by the serverlessspark-get-batch tool's ValidateSource when the source wired to the tool does not implement the tool's private `compatibleSource` interface (a Serverless Spark source exposing the batch client). In MCP Toolbox, each tool is attached to a named source in tools.yaml, and ValidateSource enforces that the referenced source's concrete type is compatible before the tool can be used. If you point the tool at a source of a different kind (e.g. a Postgres source) the type assertion fails and this message is returned at config load time.","triggerScenarios":"Configuring a tool of kind `serverless-spark-get-batch` whose `source` field references a source that is not a `serverless-spark` source (any other source type, or a source left as a different engine), causing the `source.(compatibleSource)` type assertion in ValidateSource to fail.","commonSituations":"Copy-pasting a tools.yaml block and forgetting to change the `source` name; renaming or restructuring sources so the tool now binds to the wrong source; mixing sources in one config (e.g. alloydb + serverless-spark) and mismatching the kind/source pairing.","solutions":["Set the tool's `source` field in tools.yaml to the name of a source declared with `kind: serverless-spark`.","Check the source entry's `kind` under `sources:` matches the tool type (serverless-spark) and fix typos in the source name.","If the source should be a different database, use the corresponding tool kind for that source instead of serverless-spark-get-batch."],"exampleFix":"# before\nsources:\n  my-pg:\n    kind: postgres\n    ...\ntools:\n  get-batch:\n    kind: serverless-spark-get-batch\n    source: my-pg\n# after\nsources:\n  my-spark:\n    kind: serverless-spark\n    project: my-project\n    ...\ntools:\n  get-batch:\n    kind: serverless-spark-get-batch\n    source: my-spark","handlingStrategy":"validation","validationCode":"// before starting toolbox, check the pairing in tools.yaml\nsources:\n  spark-prod:\n    kind: serverless-spark\n    project: my-project\n    region: us-central1\n    location: us-central1\ntools:\n  get-batch:\n    kind: serverless-spark-get-batch\n    source: spark-prod   # must reference a kind: serverless-spark source","typeGuard":"func isServerlessSparkSource(s sources.Source) bool {\n    _, ok := s.(serverlessspark.Source)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Always pair each tool kind with its matching source kind in tools.yaml.","Keep one source per engine and name them clearly (e.g. spark-prod, pg-prod).","Run `go run . --tools-file tools.yaml` locally to catch ValidateSource failures at startup.","After renaming a source, grep the tools file for all references to the old key."],"tags":["configuration","go","type-mismatch","serverless-spark"],"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"}