isToolAvailable method

Future<bool> isToolAvailable(
  1. String toolName, {
  2. String? serverId,
})

Check if a specific tool is available

Implementation

Future<bool> isToolAvailable(String toolName, {String? serverId}) async {
  // Check local tools
  if (localTools.containsKey(toolName)) {
    return true;
  }

  // Check plugin tools
  if (pluginManager.getToolPlugin(toolName) != null) {
    return true;
  }

  // Check server tools
  if (hasMcpServer) {
    try {
      final tools = await serverManager!.getTools(serverId);
      return tools.any((tool) => tool['name'] == toolName);
    } catch (e) {
      // If error, assume not available
      return false;
    }
  }

  return false;
}