MCPcopy Create free account
hub / github.com/docker/docker-agent / classifyParams

Method classifyParams

pkg/tools/builtin/openapi/openapi.go:510–534  ·  view source on GitHub ↗

classifyParams splits tool call arguments into path replacements, query parameters, and body parameters based on the OpenAPI path template and "body_" prefix convention.

(params openAPICallArgs)

Source from the content-addressed store, hash-verified

508// classifyParams splits tool call arguments into path replacements, query parameters,
509// and body parameters based on the OpenAPI path template and "body_" prefix convention.
510func (h *openAPIHandler) classifyParams(params openAPICallArgs) (string, url.Values, map[string]any) {
511 resolvedPath := h.path
512 queryParams := url.Values{}
513 bodyParams := map[string]any{}
514
515 for key, value := range params {
516 // Path parameter?
517 placeholder := "{" + key + "}"
518 if strings.Contains(h.path, placeholder) {
519 resolvedPath = strings.ReplaceAll(resolvedPath, placeholder, url.PathEscape(fmt.Sprintf("%v", value)))
520 continue
521 }
522
523 // Body parameter? (prefixed with "body_")
524 if after, ok := strings.CutPrefix(key, "body_"); ok {
525 bodyParams[after] = value
526 continue
527 }
528
529 // Otherwise it's a query parameter.
530 queryParams.Set(key, fmt.Sprintf("%v", value))
531 }
532
533 return resolvedPath, queryParams, bodyParams
534}

Callers 1

callToolMethod · 0.95

Calls 1

SetMethod · 0.45

Tested by

no test coverage detected