Skip to main content
Glama

get_heroes

Retrieve a complete list of Dota 2 heroes with basic information for game analysis and strategy planning.

Instructions

Get list of all Dota 2 heroes.

Returns:
    List of all heroes with basic information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_heroes' tool. It fetches heroes data from OpenDota API, formats it with details like ID, name, primary attribute, attack type, and roles, and returns a formatted string. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def get_heroes() -> str:
        """Get list of all Dota 2 heroes.
    
        Returns:
            List of all heroes with basic information
        """
        heroes_data = await make_opendota_request("heroes")
    
        if "error" in heroes_data:
            return f"Error retrieving heroes data: {heroes_data['error']}"
    
        if not heroes_data or not isinstance(heroes_data, list) or len(heroes_data) == 0:
            return "No heroes data found."
    
        # Sort by hero ID
        sorted_heroes = sorted(heroes_data, key=lambda x: x.get("id", 0))
    
        formatted_heroes = []
    
        for hero in sorted_heroes:
            hero_id = hero.get("id", 0)
            name = hero.get("localized_name", f"Hero {hero_id}")
            primary_attr = hero.get("primary_attr", "Unknown")
            attack_type = hero.get("attack_type", "Unknown")
            roles = ", ".join(hero.get("roles", []))
    
            formatted_heroes.append(
                f"{name} (ID: {hero_id})\n"
                f"Primary Attribute: {primary_attr}\n"
                f"Attack Type: {attack_type}\n"
                f"Roles: {roles}"
            )
    
        return "Dota 2 Heroes:\n\n" + "\n\n".join(formatted_heroes)
  • The @mcp.tool() decorator registers the get_heroes function as an MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/asusevski/opendota-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server