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

For cloudloggingadmin-list-log-names, RequiresClientAuthorization asserts the resolved source implements compatibleSource so it can report whether client-side (per-request) OAuth is used. A source of any other kind fails the assertion and produces this error, blocking tool setup.

Source

Thrown at internal/tools/cloudloggingadmin/cloudloggingadminlistlognames/cloudloggingadminlistlognames.go:124

	var err error
	if source.UseClientAuthorization() {
		tokenString, err = accessToken.ParseBearerToken()
		if err != nil {
			return nil, util.NewClientServerError("failed to parse access token", http.StatusUnauthorized, err)
		}
	}

	resp, err := source.ListLogNames(ctx, limit, tokenString)
	if err != nil {
		return nil, util.ProcessGcpError(err)
	}
	return resp, nil
}

func (t Tool) RequiresClientAuthorization(source sources.Source) (bool, error) {
	s, ok := source.(compatibleSource)
	if !ok {
		return false, fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
	}
	return s.UseClientAuthorization(), nil
}

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

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool's `source` field at a source of kind cloudloggingadmin.
  2. Confirm the referenced source exists in the `sources:` section and initialized successfully.
  3. In tests, use a stub implementing compatibleSource (UseClientAuthorization).
  4. Grep the config for the tool and validate its source mapping against the source kind.

Example fix

// before
tools:
  list-log-names:
    kind: cloudloggingadmin-list-log-names
    source: my-postgres
// after
tools:
  list-log-names:
    kind: cloudloggingadmin-list-log-names
    source: my-cloud-logging
Defensive patterns

Strategy: validation

Validate before calling

for name, t in tools.items():
    if t['kind'].startswith('cloudloggingadmin') and sources[t['source']]['kind'] != 'cloudloggingadmin':
        raise ValueError(f"tool {name}: source {t['source']} must be kind cloudloggingadmin")

Type guard

func mustCompatibleLoggingSource(s sources.Source) (compatibleSource, error) {
    cs, ok := s.(compatibleSource)
    if !ok { return nil, fmt.Errorf("source %T incompatible with cloudloggingadmin tools", s) }
    return cs, nil
}

Prevention

When it happens

Trigger: The tool config's `source` points to a source whose kind is not cloudloggingadmin (e.g. a postgres or cloudhealthcare source), and RequiresClientAuthorization(source) is invoked during server initialization or request handling.

Common situations: Reusing a tool YAML entry across projects where the source kind changed; leaving a stale source reference after migrating to Cloud Logging; tests injecting a generic sources.Source stub.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/9d1a0487a578843c. Report an issue: GitHub.