Skip to main content
Glama

get_public_matches

Retrieve recent Dota 2 public match data to analyze gameplay patterns, track player performance, and monitor competitive trends.

Instructions

Get recent public matches.

Args:
    limit: Number of matches to retrieve (default: 5)

Returns:
    List of recent public matches

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Implementation Reference

  • The handler function that implements the get_public_matches tool. It fetches recent public matches from the OpenDota API using make_opendota_request("publicMatches"), processes and formats the match data including duration, timestamps, ranks, winners, and team heroes, then returns a formatted string summary.
    async def get_public_matches(limit: int = 5) -> str:
        """Get recent public matches.
    
        Args:
            limit: Number of matches to retrieve (default: 5)
    
        Returns:
            List of recent public matches
        """
        if limit > 20:
            limit = 20  # Cap for reasonable response size
    
        matches_data = await make_opendota_request("publicMatches")
    
        if "error" in matches_data:
            return f"Error retrieving public matches: {matches_data['error']}"
    
        if not matches_data or not isinstance(matches_data, list) or len(matches_data) == 0:
            return "No public matches found."
    
        formatted_matches = []
    
        # Limit the matches to display
        matches_to_show = []
        if isinstance(matches_data, list):
            matches_to_show = matches_data[:limit]
        for i, match in enumerate(matches_to_show):
            match_id = match.get("match_id", "Unknown")
            duration = format_duration(match.get("duration", 0))
            start_time = format_timestamp(match.get("start_time", 0))
            avg_rank = match.get("avg_rank_tier", 0)
            rank_name = format_rank_tier(avg_rank)
            radiant_win = match.get("radiant_win", False)
            winner = "Radiant" if radiant_win else "Dire"
    
            radiant_heroes = match.get("radiant_team", [])
            dire_heroes = match.get("dire_team", [])
    
            formatted_matches.append(
                f"{i+1}. Match ID: {match_id}\n"
                f"   Date: {start_time}\n"
                f"   Duration: {duration}\n"
                f"   Avg. Rank: {rank_name}\n"
                f"   Winner: {winner}\n"
                f"   Radiant Heroes: {', '.join(str(h) for h in radiant_heroes)}\n"
                f"   Dire Heroes: {', '.join(str(h) for h in dire_heroes)}"
            )
    
        return "Recent Public Matches:\n\n" + "\n\n".join(formatted_matches)
  • Registers the get_public_matches function as an MCP tool using the FastMCP @mcp.tool() decorator.
    @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