MCPcopy Index your code
hub / github.com/coder/coder / EncodeToolID

Function EncodeToolID

aibridge/mcp/tool.go:108–117  ·  view source on GitHub ↗

EncodeToolID namespaces the given tool name with a prefix to identify tools injected by this library. Claude Code, for example, prefixes the tools it includes from defined MCP servers with the "mcp__" prefix. We have to namespace the tools we inject to prevent clashes. We stick to 5 prefix chars ("

(server, tool string)

Source from the content-addressed store, hash-verified

106// - https://community.openai.com/t/function-call-description-max-length/529902
107// - https://github.com/anthropics/claude-code/issues/2326
108func EncodeToolID(server, tool string) string {
109 // strings.Builder writes to in-memory storage and never return errors.
110 var sb strings.Builder
111 _, _ = sb.WriteString(injectedToolPrefix)
112 _, _ = sb.WriteString(injectedToolDelimiter)
113 _, _ = sb.WriteString(server)
114 _, _ = sb.WriteString(injectedToolDelimiter)
115 _, _ = sb.WriteString(tool)
116 return sb.String()
117}
118
119// FilterAllowedTools filters tools based on the given allow/denylists.
120// Filtering acts on tool names, and uses tool IDs for tracking.

Callers 1

fetchToolsMethod · 0.85

Calls 2

WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected