Skip to main content
Glama

get_player_recent_matches

Retrieve recent Dota 2 match data for a specific player using their Steam32 account ID to analyze performance and gameplay patterns.

Instructions

Get recent matches played by a player.

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

Returns:
    List of recent matches with details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
limitNo

Implementation Reference

  • The handler function implementing the 'get_player_recent_matches' tool. It fetches recent matches data from the OpenDota API using make_opendota_request, processes up to the specified limit of matches, formats key statistics like hero, KDA, GPM/XPM, result, and returns a formatted string summary. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool()
    async def get_player_recent_matches(account_id: int, limit: int = 5) -> str:
        """Get recent matches played by a player.
    
        Args:
            account_id: Steam32 account ID of the player
            limit: Number of matches to retrieve (default: 5)
    
        Returns:
            List of recent matches with details
        """
        if limit > 20:
            limit = 20  # Cap for reasonable response size
    
        recent_matches = await make_opendota_request(f"players/{account_id}/recentMatches")
    
        if "error" in recent_matches:
            return f"Error retrieving recent matches: {recent_matches['error']}"
    
        if (
            not recent_matches
            or not isinstance(recent_matches, list)
            or len(recent_matches) == 0
        ):
            return "No recent matches found for this player."
    
        formatted_matches = []
    
        matches_to_process = []
        if isinstance(recent_matches, list):
            matches_to_process = recent_matches[:limit]
        for i, match in enumerate(matches_to_process):
            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"
            )
            gpm = match.get("gold_per_min", 0)
            xpm = match.get("xp_per_min", 0)
            match_date = format_timestamp(match.get("start_time", 0))
            duration = format_duration(match.get("duration", 0))
    
            formatted_matches.append(
                f"Match {i+1}:\n"
                f"- Match ID: {match.get('match_id')}\n"
                f"- Date: {match_date}\n"
                f"- Duration: {duration}\n"
                f"- Hero ID: {hero_id}\n"
                f"- K/D/A: {kills}/{deaths}/{assists}\n"
                f"- GPM/XPM: {gpm}/{xpm}\n"
                f"- Result: {win}"
            )
    
        return f"Recent Matches for Player ID {account_id}:\n\n" + "\n\n".join(
            formatted_matches
        )

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