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

Function sanitizeToolName

pkg/tools/builtin/openapi/openapi.go:411–428  ·  view source on GitHub ↗

sanitizeToolName converts a string into a valid tool name.

(name string)

Source from the content-addressed store, hash-verified

409
410// sanitizeToolName converts a string into a valid tool name.
411func sanitizeToolName(name string) string {
412 name = strings.NewReplacer(
413 "/", "_",
414 "-", "_",
415 ".", "_",
416 "{", "",
417 "}", "",
418 ).Replace(name)
419
420 name = strings.Trim(name, "_")
421
422 // Collapse multiple underscores.
423 for strings.Contains(name, "__") {
424 name = strings.ReplaceAll(name, "__", "_")
425 }
426
427 return name
428}
429
430// setHeaders sets identity headers (User-Agent, X-Docker-Agent-Version,
431// X-Docker-Desktop-Version) plus any operator-supplied custom headers on

Callers 2

operationToolNameFunction · 0.70
TestSanitizeToolNameFunction · 0.70

Calls

no outgoing calls

Tested by 1

TestSanitizeToolNameFunction · 0.56