// Set of built-in tool names (from formatToolArgs in ToolCallLine.tsx). // Any tool not in this set that has a `server_tool` name pattern is an MCP tool. export const BUILT_IN_TOOLS = new Set([ 'view_file', 'list_dir', 'grep', 'find_files', 'git_status', 'skill_use', 'get_codebase_overview', 'get_file_analysis', 'get_symbol_info', 'search_symbols', 'get_dependencies', 'watch_changes', 'get_semantic_neighborhoods', 'get_framework_analysis', ]); /** * Returns true if the tool name follows the `_` MCP pattern. * Built-in tools (view_file, grep, skill_use, etc.) are excluded even if * they happen to contain an underscore (e.g. 'git_status', 'skill_use'). */ export function isMcpTool(name: string): boolean { return name.includes('_') && !BUILT_IN_TOOLS.has(name); } /** * Extracts the MCP server name from a tool call name. * For 'context7_searchWeb' returns 'context7'. * Returns null for native tools. */ export function extractServerName(name: string): string | null { const idx = name.indexOf('_'); if (idx === -1) return null; return name.slice(0, idx); } /** * Extracts the tool name (without server prefix) from an MCP tool call name. * For 'context7_searchWeb' returns 'searchWeb'. * Returns null for native tools. */ export function extractToolName(name: string): string | null { const idx = name.indexOf('_'); if (idx === -1) return null; return name.slice(idx + 1); }