googleapis/mcp-toolbox · error

error unmarshalling HTTP method: %s

Error message

error unmarshalling HTTP method: %s

What it means

HTTPMethod has a custom YAML unmarshaler. This error wraps a lower-level failure that occurred while unmarshalling the method field into a string — e.g. the YAML node was not a scalar string (a map, list, or typed value), so the inner unmarshal call failed.

Source

Thrown at internal/tools/http_method.go:41

// HTTPMethod is a string of a valid HTTP method (e.g "GET")
type HTTPMethod string

// isValidHTTPMethod checks if the input string matches one of the method constants defined in the net/http package
func isValidHTTPMethod(method string) bool {

	switch method {
	case http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete,
		http.MethodPatch, http.MethodHead, http.MethodOptions, http.MethodTrace,
		http.MethodConnect:
		return true
	}
	return false
}

func (i *HTTPMethod) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error {
	var httpMethod string
	if err := unmarshal(&httpMethod); err != nil {
		return fmt.Errorf(`error unmarshalling HTTP method: %s`, err)
	}
	httpMethod = strings.ToUpper(httpMethod)
	if !isValidHTTPMethod(httpMethod) {
		return fmt.Errorf(`%s is not a valid http method`, httpMethod)
	}
	*i = HTTPMethod(httpMethod)
	return nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set method to a plain scalar string like method: get or method: GET
  2. Remove any surrounding list/map structure around the method value
  3. Validate the YAML config parses (yamllint or a quick Go yaml.Unmarshal) to spot the malformed node

Example fix

// before
method:
  - get
// after
method: get
Defensive patterns

Strategy: validation

Validate before calling

node must be a scalar: verify the YAML value under `method` is a plain string before loading:
if !reflect.DeepEqual(reflect.TypeOf(cfg.Method), reflect.TypeOf("")) {
    return errors.New("method must be a YAML string")
}

Try / catch

var cfg ToolConfig
if err := yaml.Unmarshal(data, &cfg); err != nil {
    if strings.Contains(err.Error(), "error unmarshalling HTTP method") {
        // fix the method field type in tools.yaml and reload
    }
    return err
}

Prevention

When it happens

Trigger: A tools.yaml config sets the HTTP tool's method to a non-string YAML value, such as method: [get], method: {name: get}, or method: 200 (parsed as int in some flows), causing unmarshal(&httpMethod) to fail.

Common situations: Copy-pasted config with a list where a scalar was expected; YAML anchors/merge producing a mapping; quotes/typing issues where YAML infers a non-string type.

Related errors


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