get_player_totals
Retrieve comprehensive Dota 2 player statistics including total matches, wins, kills, deaths, assists, and other performance metrics using Steam32 account ID.
Instructions
Get player's overall stats totals.
Args:
account_id: Steam32 account ID of the player
Returns:
Summary of player's total stats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes |
Implementation Reference
- src/opendota_server/server.py:941-975 (handler)The primary handler function for the 'get_player_totals' MCP tool. It is registered via the @mcp.tool() decorator. The function fetches the player's totals statistics from the OpenDota API endpoint `/players/{account_id}/totals`, processes the data, and returns a formatted string summary of total and average stats for various fields.@mcp.tool() async def get_player_totals(account_id: int) -> str: """Get player's overall stats totals. Args: account_id: Steam32 account ID of the player Returns: Summary of player's total stats """ totals_data = await make_opendota_request(f"players/{account_id}/totals") if "error" in totals_data: return f"Error retrieving totals data: {totals_data['error']}" if not totals_data or not isinstance(totals_data, list) or len(totals_data) == 0: return "No totals data found for this player." # Extract important fields formatted_stats = [] for stat in totals_data: field = stat.get("field", "") count = stat.get("n", 0) sum_value = stat.get("sum", 0) avg_value = sum_value / count if count > 0 else 0 # Convert field name to something more readable readable_field = field.replace("_", " ").title() formatted_stats.append( f"{readable_field}: {sum_value:,} total, {avg_value:.2f} avg" ) return f"Stat Totals for Player ID {account_id}:\n\n" + "\n".join(formatted_stats)