MCPcopy
hub / github.com/codeaashu/claude-code / getMcpServerScopeFromToolName

Function getMcpServerScopeFromToolName

src/services/mcp/utils.ts:413–436  ·  view source on GitHub ↗
(
  toolName: string,
)

Source from the content-addressed store, hash-verified

411 * @returns ConfigScope or null if not an MCP tool or server not found
412 */
413export function getMcpServerScopeFromToolName(
414 toolName: string,
415): ConfigScope | null {
416 if (!isMcpTool({ name: toolName } as Tool)) {
417 return null
418 }
419
420 // Extract server name from tool name (format: mcp__serverName__toolName)
421 const mcpInfo = mcpInfoFromString(toolName)
422 if (!mcpInfo) {
423 return null
424 }
425
426 // Look up server config
427 const serverConfig = getMcpConfigByName(mcpInfo.serverName)
428
429 // Fallback: claude.ai servers have normalized names starting with "claude_ai_"
430 // but aren't in getMcpConfigByName (they're fetched async separately)
431 if (!serverConfig && mcpInfo.serverName.startsWith('claude_ai_')) {
432 return 'claudeai'
433 }
434
435 return serverConfig?.scope ?? null
436}
437
438// Type guards for MCP server config types
439function isStdioConfig(

Callers 1

Calls 3

isMcpToolFunction · 0.85
mcpInfoFromStringFunction · 0.85
getMcpConfigByNameFunction · 0.85

Tested by

no test coverage detected