{"record":{"id":"9b235ab4f0a7d841","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-9b235a","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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go","lineNumber":100,"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\tvar tokenStr string\n\tvar err error\n\tif source.UseClientAuthorization() {\n\t\ttokenStr, err = accessToken.ParseBearerToken()\n\t\tif err != nil {\n\t\t\treturn nil, util.NewClientServerError(\"error parsing access token\", http.StatusUnauthorized, err)\n\t\t}\n\t}\n\tresp, err := source.GetDataset(tokenStr)","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go#L82-L118","documentation":"ValidateSource for cloudhealthcare-get-dataset asserts the bound source implements the tool's compatibleSource interface (UseClientAuthorization and GetDataset per internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go:46). Any other source type fails the assertion and produces this error. It is a wiring check performed when the tool is bound to a source.","triggerScenarios":"ValidateSource(source) is called with a source that is not the cloudhealthcare Source — e.g. a postgres/http source, or a stub missing GetDataset/UseClientAuthorization.","commonSituations":"tools.yaml binds the tool to a source of the wrong kind; a source-name typo; custom test doubles missing interface methods; refactor broke interface compliance.","solutions":["Bind the tool to a kind: cloudhealthcare source in tools.yaml.","Fix the source name referenced by the tool.","Implement GetDataset(string) (*healthcare.Dataset, error) and UseClientAuthorization() bool on custom sources.","Rebuild so the concrete cloudhealthcare Source is registered."],"exampleFix":"# before\nsource: my-spanner\n\n# after\nsource: my-healthcare  # kind: cloudhealthcare","handlingStrategy":"type-guard","validationCode":"if _, ok := src.(compatibleSource); !ok {\n\treturn errors.New(\"cloudhealthcare-get-dataset requires a cloudhealthcare source (with GetDataset)\")\n}","typeGuard":"cs, ok := src.(compatibleSource)","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n\tlog.Fatalf(\"bad tool/source binding: %v\", err) // config bug, no retry\n}","preventionTips":["Use kind: cloudhealthcare sources for cloudhealthcare tools.","Verify source references resolve to declared sources.","Make test doubles implement GetDataset and UseClientAuthorization.","Run go build after source refactors to catch interface breakage."],"tags":["go","cloud-healthcare","type-assertion","config"],"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"}