googleapis/mcp-toolbox · error
invalid source for %q tool: source %q is not a compatible ty
Error message
invalid source for %q tool: source %q is not a compatible type
What it means
ValidateSource asserts the incoming sources.Source to compatibleSource and returns this error when the tool is invoked or wired against a source that is not the Cloud Healthcare source. It is the upfront guard ensuring Invoke only ever sees a source exposing FHIR/DICOM store helpers.
Source
Thrown at internal/tools/cloudhealthcare/cloudhealthcaregetfhirstore/cloudhealthcaregetfhirstore.go:101
// validate interface
var _ tools.Tool = Tool{}
type Tool struct {
tools.BaseTool[Config]
}
func (t Tool) GetSourceName() string {
return t.Cfg.Source
}
func (t Tool) ToConfig() tools.ToolConfig {
return t.Cfg
}
func (t Tool) ValidateSource(source sources.Source) error {
_, ok := source.(compatibleSource)
if !ok {
return fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
}
return nil
}
func (t Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {
source, ok := s.(compatibleSource)
if !ok {
return nil, util.NewClientServerError("source used is not compatible with the tool", http.StatusInternalServerError, nil)
}
storeID, err := common.ValidateAndFetchStoreID(params, source.AllowedFHIRStores())
if err != nil {
return nil, util.NewAgentError("failed to validate store ID", err)
}
var tokenStr string
if source.UseClientAuthorization() {
tokenStr, err = accessToken.ParseBearerToken()
if err != nil {
return nil, util.NewClientServerError("error parsing access token", http.StatusUnauthorized, err)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Use a 'cloudhealthcare' kind source for this tool in tools.yaml.
- Confirm source registration: the source's SourceType() must equal the cloudhealthcare resource type.
- Update mock sources in tests to implement compatibleSource.
- Re-run toolbox init after upgrading to regenerate correct bindings.
Example fix
// before source: my-sql-source // after source: my-healthcare-source
Defensive patterns
Strategy: type-guard
Validate before calling
if _, ok := src.(cloudhealthcare.Source); !ok {
return errors.New("this tool only supports the cloudhealthcare source")
} Type guard
func implementsCompatibleSource(s sources.Source) bool {
_, ok := s.(interface {
UseClientAuthorization() bool
AllowedFHIRStores() []string
IsFHIRStoreAllowed(string) bool
})
return ok
} Try / catch
if err := tool.ValidateSource(src); err != nil {
return fmt.Errorf("invalid source binding: %w", err)
} Prevention
- Bind healthcare tools only to healthcare sources
- Run startup validation so ValidateSource fires before traffic
- Update test doubles whenever compatibleSource gains methods
- Keep source names unique to avoid accidental binding to the wrong entry
When it happens
Trigger: Invoke/ValidateSource called with a non-cloudhealthcare source, e.g. toolset assembly attaching this tool to a different engine's source.
Common situations: Wrong source referenced in tools.yaml; source kind renamed after an upgrade so binding resolves to the wrong source; test fakes not updated to the compatibleSource interface.
Related errors
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- source is not compatible with the tool
- source is not compatible with the tool
- source is not compatible with the tool
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/dd6eefd9eb613b38.
Report an issue: GitHub.