{"record":{"id":"c44d6e2dc4d89574","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-c44d6e","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/cloudhealthcarefhirpatientsearch/cloudhealthcarefhirpatientsearch.go","lineNumber":123,"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\tstoreID, err := common.ValidateAndFetchStoreID(params, source.AllowedFHIRStores())\n\tif err != nil {\n\t\treturn nil, util.NewAgentError(\"failed to validate store ID\", err)\n\t}\n\n\tvar tokenStr string\n\tif source.UseClientAuthorization() {\n\t\ttokenStr, err = accessToken.ParseBearerToken()\n\t\tif err != nil {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudhealthcare/cloudhealthcarefhirpatientsearch/cloudhealthcarefhirpatientsearch.go#L105-L141","documentation":"ValidateSource for the cloudhealthcare-fhir-patient-search tool asserts that the bound source implements the tool's compatibleSource interface (the Cloud Healthcare source methods this tool depends on). Any source whose concrete type fails that assertion triggers this error. It is a startup/config-time wiring check, guaranteeing the tool only runs against a compatible Cloud Healthcare source.","triggerScenarios":"ValidateSource(source) is called during tool/source binding with a source that is not the cloudhealthcare Source (e.g. postgres, http, storage) or a stub missing compatibleSource methods.","commonSituations":"tools.yaml binds the tool to a source declared with the wrong kind; a typo in the source name selects a different source; a custom test double doesn't implement the full interface; a refactor changed the source package so it no longer satisfies the interface.","solutions":["Point the tool's source at a kind: cloudhealthcare source in tools.yaml.","Correct the source name referenced by the tool (check for typos).","Implement all compatibleSource methods on any custom/mock source.","Rebuild so the registered source is the concrete cloudhealthcare Source type."],"exampleFix":"# before\ntools:\n  fhir-patient-search:\n    kind: cloudhealthcare-fhir-patient-search\n    source: my-mssql   # not a cloudhealthcare source\n\n# after\ntools:\n  fhir-patient-search:\n    kind: cloudhealthcare-fhir-patient-search\n    source: my-healthcare # kind: cloudhealthcare","handlingStrategy":"type-guard","validationCode":"func checkBinding(toolKind, sourceKind string) error {\n\tif strings.HasPrefix(toolKind, \"cloudhealthcare-\") && sourceKind != \"cloudhealthcare\" {\n\t\treturn fmt.Errorf(\"tool %s requires a cloudhealthcare source, got %s\", toolKind, sourceKind)\n\t}\n\treturn nil\n}","typeGuard":"if _, ok := src.(compatibleSource); !ok { /* handle before ValidateSource */ }","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n\tlog.Fatalf(\"invalid tool/source binding (non-recoverable): %v\", err)\n}","preventionTips":["Match tool kind prefix to source kind when editing tools.yaml.","Grep your config for source names and confirm each declared kind.","Keep mocks interface-complete with compile-time assertions.","Re-validate bindings after upgrading the toolbox version."],"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"}