googleapis/mcp-toolbox · error
is not a valid http method
Error message
%s is not a valid http method
What it means
After successfully unmarshalling the method string, it is uppercased and checked against the set of valid HTTP methods (GET, POST, PUT, DELETE, etc.). This error means the configured method string is not one of the supported HTTP verbs.
Solutions
- Replace the method value with a standard HTTP verb: GET, POST, PUT, DELETE, PATCH, or HEAD as supported by isValidHTTPMethod
- Fix the typo in the config (e.g. gtet -> get)
- Check the library version's supported method list and upgrade if a needed verb is missing
Example fix
// before method: fetch // after method: GET
Defensive patterns
Strategy: validation
Validate before calling
var valid = map[string]bool{"GET":true,"POST":true,"PUT":true,"DELETE":true,"PATCH":true,"HEAD":true}
m := strings.ToUpper(cfg.Method)
if !valid[m] {
return fmt.Errorf("%s is not a valid http method", m)
} Try / catch
if err := yaml.Unmarshal(data, &cfg); err != nil {
if strings.HasSuffix(strings.TrimSpace(err.Error()), "is not a valid http method") {
// correct the method verb in tools.yaml
}
return err
} Prevention
- Use only standard HTTP verbs in configs; check isValidHTTPMethod's list
- Keep a canonical tools.yaml template with method pre-filled
- Lint configs against a schema that enum-constrains method
When it happens
Trigger: A tools.yaml http tool declares method: fetch, method: patch (if unsupported), method: getall, or a typo like method: gtet; the string parses fine as YAML but fails isValidHTTPMethod after uppercasing.
Common situations: Typos in hand-edited configs; invented verbs ('UPSERT', 'READ'); casing confusion (handled by ToUpper, so this is genuinely an invalid verb, not a case issue); older configs written for a fork supporting extra verbs.
Related errors
- description is required for tool
- description is required for tool
- description is required for tool
- description is required for tool
- description is required for tool
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/e408765c9f5c271f.
Report an issue: GitHub.
Appendix: source
Thrown at internal/tools/http_method.go:45
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)