MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseToolName

Function parseToolName

src/tools/ToolSearchTool/ToolSearchTool.ts:132–161  ·  view source on GitHub ↗

* Parse tool name into searchable parts. * Handles both MCP tools (mcp__server__action) and regular tools (CamelCase).

(name: string)

Source from the content-addressed store, hash-verified

130 * Handles both MCP tools (mcp__server__action) and regular tools (CamelCase).
131 */
132function parseToolName(name: string): {
133 parts: string[]
134 full: string
135 isMcp: boolean
136} {
137 // Check if it's an MCP tool
138 if (name.startsWith('mcp__')) {
139 const withoutPrefix = name.replace(/^mcp__/, '').toLowerCase()
140 const parts = withoutPrefix.split('__').flatMap(p => p.split('_'))
141 return {
142 parts: parts.filter(Boolean),
143 full: withoutPrefix.replace(/__/g, ' ').replace(/_/g, ' '),
144 isMcp: true,
145 }
146 }
147
148 // Regular tool - split by CamelCase and underscores
149 const parts = name
150 .replace(/([a-z])([A-Z])/g, '$1 $2') // CamelCase to spaces
151 .replace(/_/g, ' ')
152 .toLowerCase()
153 .split(/\s+/)
154 .filter(Boolean)
155
156 return {
157 parts,
158 full: parts.join(' '),
159 isMcp: false,
160 }
161}
162
163/**
164 * Pre-compile word-boundary regexes for all search terms.

Callers 1

searchToolsWithKeywordsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected