Skip to main content
Glama

get_player_by_id

Retrieve Dota 2 player details including rank, match history, and statistics using their Steam32 account ID.

Instructions

Get a player's information by their account ID.

Args:
    account_id: The player's Steam32 account ID

Returns:
    Player information including rank, matches, and statistics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_player_by_id' tool, decorated with @mcp.tool() for registration. It fetches player data, win/loss stats, and recent matches from the OpenDota API and formats the response using format_player_data.
    @mcp.tool()
    async def get_player_by_id(account_id: int) -> str:
        """Get a player's information by their account ID.
    
        Args:
            account_id: The player's Steam32 account ID
    
        Returns:
            Player information including rank, matches, and statistics
        """
        player_data = await make_opendota_request(f"players/{account_id}")
    
        if "error" in player_data:
            return f"Error retrieving player data: {player_data['error']}"
    
        # Get win/loss stats
        wl_data = await make_opendota_request(f"players/{account_id}/wl")
    
        # Get recent matches
        recent_matches = await make_opendota_request(f"players/{account_id}/recentMatches")
    
        return format_player_data(player_data, wl_data, recent_matches)
  • Helper function to format the player data, win/loss stats, and recent matches into a human-readable string. Called by the handler.
    def format_player_data(
        player: Dict[str, Any],
        wl: Optional[Dict[str, Any]] = None,
        recent_matches: Optional[Union[List[Dict[str, Any]], Dict[str, Any]]] = None,
    ) -> str:
        """Format player data into a readable string."""
        if not player:
            return "Player data not found."
    
        # Parse the player data
        player_obj = parse_player(player)
    
        # Basic info
        account_id = player_obj.account_id
        name = player_obj.personaname or "Anonymous"
        rank = format_rank_tier(player_obj.rank_tier)
        mmr = player_obj.mmr_estimate or "Unknown"
    
        # Win/Loss record
        wins = wl.get("win", 0) if wl else 0
        losses = wl.get("lose", 0) if wl else 0
        total_games = wins + losses
        win_rate = (wins / total_games * 100) if total_games > 0 else 0
    
        # Format recent matches if available
        recent_matches_text = ""
        if recent_matches and isinstance(recent_matches, list):
            match_texts = []
            matches_to_show = recent_matches[:5] if len(recent_matches) > 0 else []
            for match in matches_to_show:
                hero_id = match.get("hero_id", "Unknown")
                kills = match.get("kills", 0)
                deaths = match.get("deaths", 0)
                assists = match.get("assists", 0)
                win = (
                    "Won"
                    if (match.get("radiant_win") == (match.get("player_slot", 0) < 128))
                    else "Lost"
                )
                match_date = format_timestamp(match.get("start_time", 0))
    
                match_texts.append(
                    f"Match ID: {match.get('match_id')}\n"
                    f"- Date: {match_date}\n"
                    f"- Hero: {hero_id}\n"
                    f"- K/D/A: {kills}/{deaths}/{assists}\n"
                    f"- Result: {win}"
                )
    
            recent_matches_text = "\n\nRecent Matches:\n" + "\n\n".join(match_texts)
    
        # Professional player info if applicable
        pro_info = ""
        if player_obj.is_pro:
            pro_info = (
                f"\nProfessional Player: Yes\nTeam: {player_obj.team_name or 'Unknown'}"
            )
    
        return (
            f"Player: {name} (ID: {account_id})\n"
            f"Rank: {rank}\n"
            f"Estimated MMR: {mmr}\n"
            f"Win/Loss: {wins}/{losses} ({win_rate:.1f}% win rate){pro_info}{recent_matches_text}"
        )
  • Helper function to parse raw player data from API into a structured Player dataclass instance, used in formatting.
    def parse_player(player_data: Dict[str, Any]) -> Player:
        """Parse API response into a Player object."""
        profile = player_data.get("profile", {})
        account_id = player_data.get("account_id")
    
        if account_id is None:
            # Default to 0 if account_id is None to satisfy the type checker
            account_id = 0
    
        return Player(
            account_id=account_id,
            personaname=profile.get("personaname"),
            name=profile.get("name"),
            steam_id=profile.get("steamid"),
            avatar=profile.get("avatarfull"),
            profile_url=profile.get("profileurl"),
            rank_tier=player_data.get("rank_tier"),
            mmr_estimate=player_data.get("mmr_estimate", {}).get("estimate"),
            country_code=profile.get("loccountrycode"),
            is_pro=bool(player_data.get("is_pro", False)),
            team_name=player_data.get("team_name"),
            team_id=player_data.get("team_id"),
        )
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 information, implying a read-only operation, but doesn't cover critical aspects like rate limits, authentication needs, error handling, or data freshness. For a tool with no annotation coverage, this leaves significant gaps in understanding its operational behavior.

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 well-structured and concise, with three sentences that efficiently cover purpose, arguments, and returns. Each sentence adds value: the first states the core function, the second explains the parameter, and the third outlines the response. There's no wasted text, making it easy to scan and understand.

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

Completeness3/5

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

Given the tool's low complexity (1 parameter) and the presence of an output schema, the description is moderately complete. It covers the basic purpose and parameter semantics adequately. However, with no annotations and multiple sibling tools, it lacks usage guidelines and behavioral details, which could hinder effective tool selection and invocation in a broader context.

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 context beyond the input schema, which has 0% description coverage. It specifies that 'account_id' is 'The player's Steam32 account ID,' clarifying the parameter's purpose and format. This compensates well for the schema's lack of descriptions, though it doesn't detail constraints like valid ID ranges or examples.

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 information by their account ID.' It specifies the verb ('Get') and resource ('player's information'), and distinguishes it from siblings like get_player_heroes or get_player_recent_matches by focusing on basic player data. However, it doesn't explicitly differentiate from get_player_rankings or get_player_totals, which might overlap in scope, preventing 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 prerequisites, such as needing a valid account ID, or compare it to siblings like search_player for unknown IDs or get_player_recent_matches for recent activity. Without such context, users might struggle to choose the right tool among the many player-related options.

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