MCPcopy Create free account
hub / github.com/freecodexyz/free-code / detectCodeIndexingFromMcpTool

Function detectCodeIndexingFromMcpTool

src/utils/codeIndexing.ts:159–184  ·  view source on GitHub ↗
(
  toolName: string,
)

Source from the content-addressed store, hash-verified

157 * detectCodeIndexingFromMcpTool('mcp__filesystem__read') // returns undefined
158 */
159export function detectCodeIndexingFromMcpTool(
160 toolName: string,
161): CodeIndexingTool | undefined {
162 // MCP tool names follow the format: mcp__serverName__toolName
163 if (!toolName.startsWith('mcp__')) {
164 return undefined
165 }
166
167 const parts = toolName.split('__')
168 if (parts.length < 3) {
169 return undefined
170 }
171
172 const serverName = parts[1]
173 if (!serverName) {
174 return undefined
175 }
176
177 for (const { pattern, tool } of MCP_SERVER_PATTERNS) {
178 if (pattern.test(serverName)) {
179 return tool
180 }
181 }
182
183 return undefined
184}
185
186/**
187 * Detects if an MCP server name corresponds to a code indexing tool.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected