detectCodeIndexingFromMcpTool function

CodeIndexingTool? detectCodeIndexingFromMcpTool(
  1. String toolName
)

Detects if an MCP tool is from a code indexing server.

MCP tool names follow the format: mcp__serverName__toolName.

Implementation

CodeIndexingTool? detectCodeIndexingFromMcpTool(String toolName) {
  if (!toolName.startsWith('mcp__')) return null;

  final parts = toolName.split('__');
  if (parts.length < 3) return null;

  final serverName = parts[1];
  if (serverName.isEmpty) return null;

  for (final entry in _mcpServerPatterns) {
    if (entry.pattern.hasMatch(serverName)) {
      return entry.tool;
    }
  }

  return null;
}