get_heroes
Retrieve comprehensive Dota 2 hero data including names, attributes, and basic statistics for game analysis and strategy planning.
Instructions
Get list of all Dota 2 heroes.
Returns:
List of all heroes with basic information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/opendota_server/server.py:904-939 (handler)Handler and registration for the get_heroes tool. This async function fetches the list of all Dota 2 heroes from the OpenDota API endpoint '/heroes', sorts them by ID, and formats a string response with each hero's name, ID, primary attribute, attack type, and roles. Registered using the @mcp.tool() decorator which also infers the schema from the function signature and docstring.@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)