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
- Set method to a plain scalar string like method: get or method: GET
- Remove any surrounding list/map structure around the method value
- 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
- Always write method as a plain scalar (method: GET) in tools.yaml
- Run yamllint or a schema validator over tools.yaml before deployment
- Avoid anchors/merge keys around the method field
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
- %s is not a valid http method
- unable to parse prebuilt tool configuration for '%s': %w
- prebuilt source tool for '%s' not found. %s
- error parsing argument: %w
- invalid role %q: must be 'user' or 'assistant'
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/dcd2177500542b8c.
Report an issue: GitHub.