Skip to main content
Glama

get_player_heroes

Retrieve a Dota 2 player's most frequently played heroes with performance statistics using their Steam account ID.

Instructions

Get a player's most played heroes.

Args:
    account_id: Steam32 account ID of the player
    limit: Number of heroes to retrieve (default: 5)

Returns:
    List of most played heroes with stats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for 'get_player_heroes' tool. It is decorated with @mcp.tool() which registers it with the FastMCP server. Fetches player's most played heroes from OpenDota API endpoint /players/{account_id}/heroes, retrieves hero names, sorts by games played, computes win rates, and returns formatted list of top heroes.
    @mcp.tool()
    async def get_player_heroes(account_id: int, limit: int = 5) -> str:
        """Get a player's most played heroes.
    
        Args:
            account_id: Steam32 account ID of the player
            limit: Number of heroes to retrieve (default: 5)
    
        Returns:
            List of most played heroes with stats
        """
        if limit > 20:
            limit = 20  # Cap for reasonable response size
    
        # Get hero usage data
        heroes_data = await make_opendota_request(f"players/{account_id}/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 hero data found for this player."
    
        # Get hero lookup table from cache or API
        heroes_names = await make_opendota_request("heroes")
        hero_id_to_name = {}
    
        if isinstance(heroes_names, list) and heroes_names:
            # Process the heroes data to create a mapping
            for hero in heroes_names:
                if isinstance(hero, dict) and "id" in hero and "localized_name" in hero:
                    hero_id = hero.get("id")
                    hero_name = hero.get("localized_name")
                    if hero_id is not None and hero_name is not None:
                        hero_id_to_name[hero_id] = hero_name
        else:
            # Fallback to a minimal hero dictionary if API fails
            logger.warning("Failed to get hero names, using fallback dictionary")
            hero_id_to_name = {
                1: "Anti-Mage",
                2: "Axe",
                3: "Bane",
                4: "Bloodseeker",
                5: "Crystal Maiden",
                6: "Drow Ranger",
                7: "Earthshaker",
                8: "Juggernaut",
                9: "Mirana",
                10: "Morphling",
                11: "Shadow Fiend",
                12: "Phantom Lancer",
                13: "Puck",
                14: "Pudge",
                15: "Razor",
                # This is just a small sample of common heroes
            }
    
        try:
            # Sort heroes by games played
            sorted_heroes = sorted(
                heroes_data, key=lambda x: x.get("games", 0), reverse=True
            )
    
            formatted_heroes = []
    
            for i, hero in enumerate(sorted_heroes[:limit]):
                hero_id = hero.get("hero_id", 0)
                hero_name = hero_id_to_name.get(hero_id, f"Hero {hero_id}")
                games = hero.get("games", 0)
                wins = hero.get("win", 0)
                win_rate = (wins / games * 100) if games > 0 else 0
                last_played = format_timestamp(hero.get("last_played", 0))
    
                formatted_heroes.append(
                    f"{i+1}. {hero_name} (ID: {hero_id})\n"
                    f"   Games: {games}\n"
                    f"   Wins: {wins}\n"
                    f"   Win Rate: {win_rate:.2f}%\n"
                    f"   Last Played: {last_played}"
                )
    
            return f"Most Played Heroes for Player ID {account_id}:\n\n" + "\n\n".join(
                formatted_heroes
            )
        except Exception as e:
            logger.error(f"Error formatting hero data: {e}")
            return f"Error processing heroes data: {str(e)}"
  • The @mcp.tool() decorator registers the get_player_heroes function as an MCP tool.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves data ('Get'), implying a read-only operation, but doesn't specify any behavioral traits like rate limits, authentication needs, or data freshness. The mention of 'default: 5' for the limit parameter adds some context, but overall, it lacks details on how the tool behaves beyond basic functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose followed by structured sections for 'Args' and 'Returns.' Every sentence earns its place by providing essential information without redundancy, making it efficient and easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no annotations, but with an output schema), the description is fairly complete. It covers the purpose, parameters, and return value ('List of most played heroes with stats'), and the output schema likely handles return details. However, it lacks usage guidelines and deeper behavioral context, which holds it back from a perfect score.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful semantics beyond the input schema, which has 0% description coverage. It explains that 'account_id' is a 'Steam32 account ID of the player' and 'limit' is the 'Number of heroes to retrieve (default: 5),' clarifying the purpose and default value. This compensates well for the low schema coverage, though it doesn't detail constraints like valid ranges for 'limit.'

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get a player's most played heroes.' It specifies the verb ('Get') and resource ('player's most played heroes'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from siblings like 'get_player_totals' or 'get_player_recent_matches,' which might also involve player data, so it lacks sibling differentiation for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any context, prerequisites, or exclusions, such as how it differs from 'get_hero_stats' or 'get_player_totals.' Without this, users must infer usage from the purpose alone, which is insufficient for optimal tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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