MCPcopy Create free account
hub / github.com/github/gh-aw / PrettifyToolName

Function PrettifyToolName

pkg/workflow/strings.go:197–218  ·  view source on GitHub ↗

PrettifyToolName removes "mcp__" prefix and formats tool names nicely

(toolName string)

Source from the content-addressed store, hash-verified

195
196// PrettifyToolName removes "mcp__" prefix and formats tool names nicely
197func PrettifyToolName(toolName string) string {
198 // Handle MCP tools: "mcp__github__search_issues" -> "github_search_issues"
199 // Avoid colons and leave underscores as-is
200 if strings.HasPrefix(toolName, "mcp__") {
201 parts := strings.Split(toolName, "__")
202 if len(parts) >= 3 {
203 provider := parts[1]
204 method := strings.Join(parts[2:], "_")
205 return fmt.Sprintf("%s_%s", provider, method)
206 }
207 // If format is unexpected, just remove the mcp__ prefix
208 return strings.TrimPrefix(toolName, "mcp__")
209 }
210
211 // Handle bash specially - keep as "bash"
212 if strings.EqualFold(toolName, "bash") {
213 return "bash"
214 }
215
216 // Return other tool names as-is
217 return toolName
218}
219
220// SanitizeWorkflowIDForCacheKey sanitizes a workflow ID for use in cache keys.
221// It removes all hyphens and converts to lowercase to create a filesystem-safe identifier.

Callers 6

buildToolUsageInfoFunction · 0.92
mergeMCPToolUsageInfoFunction · 0.92
buildToolUsageSummaryFunction · 0.92
TestPrettifyToolNameFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestPrettifyToolNameFunction · 0.68