get_public_matches
Retrieve recent public Dota 2 matches to analyze gameplay trends and player statistics. Specify the number of matches to fetch for competitive insights.
Instructions
Get recent public matches.
Args:
limit: Number of matches to retrieve (default: 5)
Returns:
List of recent public matches
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Implementation Reference
- src/opendota_server/server.py:1126-1175 (handler)The primary handler for the 'get_public_matches' tool. This async function retrieves recent public Dota 2 matches from the OpenDota API, limits and formats the results (including match ID, date, duration, average rank, winner, and team heroes), and returns a formatted string summary. It is registered as an MCP tool via the @mcp.tool() decorator.@mcp.tool() 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)