googleapis/mcp-toolbox · error

unable to parse source %q as %q: %w

Error message

unable to parse source %q as %q: %w

What it means

A factory was found for the source type, but the subsequent YAML decode into the source-specific Config failed — one or more fields under the source's `spec` do not match that source's schema.

Source

Thrown at internal/sources/sources.go:54

// It returns false if the type is already registered.
func Register(sourceType string, factory SourceConfigFactory) bool {
	if _, exists := sourceRegistry[sourceType]; exists {
		// Source with this type already exists, do not overwrite.
		return false
	}
	sourceRegistry[sourceType] = factory
	return true
}

// DecodeConfig decodes a source configuration using the registered factory for the given type.
func DecodeConfig(ctx context.Context, sourceType string, name string, decoder *yaml.Decoder) (SourceConfig, error) {
	factory, found := sourceRegistry[sourceType]
	if !found {
		return nil, fmt.Errorf("unknown source type: %q", sourceType)
	}
	sourceConfig, err := factory(ctx, name, decoder)
	if err != nil {
		return nil, fmt.Errorf("unable to parse source %q as %q: %w", name, sourceType, err)
	}
	return sourceConfig, err
}

// SourceConfig is the interface for configuring a source.
type SourceConfig interface {
	SourceConfigType() string
	Initialize(ctx context.Context, tracer trace.Tracer) (Source, error)
}

// Source is the interface for the source itself.
type Source interface {
	SourceType() string
	ToConfig() SourceConfig
	IsReadOnly() bool
}

// InitConnectionSpan adds a span for database pool connection initialization

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Compare the source's spec fields with the documentation for that source type
  2. Fix field names, types, or missing required fields
  3. Check indentation and nesting of the spec block
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/sources/sources.go:54 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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