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

The "http" tool only works with sources implementing compatibleSource (HttpDefaultHeaders, HttpBaseURL, HttpQueryParams, RunRequest). ValidateSource type-asserts the configured source and returns this error when the source kind doesn't support raw HTTP requests.

Source

Thrown at internal/tools/http/http.go:129

// 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
}

// Helper function to generate the HTTP request body upon Tool invocation.
func getRequestBody(bodyParams parameters.Parameters, requestBodyPayload string, paramsMap map[string]any) (string, error) {
	bodyParamValues, err := parameters.GetParams(bodyParams, paramsMap)
	if err != nil {
		return "", err
	}
	bodyParamsMap := bodyParamValues.AsMap()

	requestBodyStr, err := parameters.PopulateTemplateWithJSON("HTTPToolRequestBody", requestBodyPayload, bodyParamsMap)
	if err != nil {
		return "", err
	}
	return requestBodyStr, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's "source" to a source declared with kind "http" in tools.yaml.
  2. Confirm the named source's kind in the sources: section matches what the http tool expects.
  3. If the intent was a database query, change the tool type to the appropriate SQL tool instead.

Example fix

# before
proxy-tool:
  type: http
  source: postgres-src
  path: /v1/items
  method: GET
  description: Proxy call
# after
proxy-tool:
  type: http
  source: rest-api-src
  path: /v1/items
  method: GET
  description: Proxy call
Defensive patterns

Strategy: validation

Validate before calling

// Ensure each http tool's source is an http-kind source
src, ok := cfg.Sources[tool.Source]
if tool.Type == "http" && (!ok || src.Kind != "http") {
    return fmt.Errorf("http tool %q requires an http source, got %q", tool.Name, tool.Source)
}

Type guard

func isHTTPSource(s sources.Source) bool {
    _, ok := s.(interface {
        HttpDefaultHeaders() map[string]string
        HttpBaseURL() string
        HttpQueryParams() map[string]string
        RunRequest(context.Context, *http.Request) (any, error)
    })
    return ok
}

Prevention

When it happens

Trigger: An http tool's "source" field names a non-HTTP source (e.g., postgres, firestore) so the source.(compatibleSource) assertion fails during tool/source validation at startup.

Common situations: Pointing an http tool at a database source by mistake; renaming/re-pointing a shared source; copying tool definitions between configs where source names refer to different source kinds.

Related errors


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