{"record":{"id":"6ca6a9f3eda433f1","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-6ca6a9","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/cloudhealthcaregetdicomstore/cloudhealthcaregetdicomstore.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\tstoreID, err := common.ValidateAndFetchStoreID(params, source.AllowedDICOMStores())\n\tif err != nil {\n\t\treturn nil, util.NewAgentError(\"failed to validate store ID\", err)\n\t}\n\tvar tokenStr string\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)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstore/cloudhealthcaregetdicomstore.go#L83-L119","documentation":"ValidateSource checks that the source bound to the tool implements the compatibleSource interface (a Cloud Healthcare source with DICOM store support). If the configured source is any other type, the tool cannot resolve its store configuration, so this error is returned.","triggerScenarios":"Calling ValidateSource with a sources.Source that does not implement compatibleSource — e.g. pairing the tool with a postgres, bigquery, or non-healthcare source.","commonSituations":"YAML config where the tool's sourceRef points at the wrong source; renaming/refactoring sources so the reference no longer matches; copy-pasted tool configs reusing an incompatible source name.","solutions":["Point the tool's sourceRef at a cloudhealthcare source","Check the source's kind in the YAML matches the Cloud Healthcare source type","Register only compatible source-tool pairs in the config"],"exampleFix":"# before\nsources:\n  db:\n    kind: postgres\n    ...\ntools:\n  get_store:\n    kind: cloud-healthcare-get-dicom-store\n    source: db\n# after\nsources:\n  hc:\n    kind: cloud-healthcare\n    ...\ntools:\n  get_store:\n    kind: cloud-healthcare-get-dicom-store\n    source: hc","handlingStrategy":"type-guard","validationCode":"if _, ok := src.(sources.Source); ok {\n    if _, compat := src.(compatibleSource); !compat {\n        return fmt.Errorf(\"source %T is not compatible with cloud-healthcare tools\", src)\n    }\n}","typeGuard":"func isCompatibleHealthcareSource(s sources.Source) bool {\n    _, ok := s.(compatibleSource)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Pair each cloud-healthcare tool with a cloud-healthcare source in YAML","Verify source kinds at config load before tool initialization","Keep tool and source kinds consistent when copy-pasting configs"],"tags":["go","config","type-mismatch","mcp-toolbox"],"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"}