get_player_win_loss
Retrieve win/loss statistics for Dota 2 players using their Steam32 account ID to analyze player performance and match history.
Instructions
Get win/loss statistics for a player.
Args:
account_id: Steam32 account ID of the player
Returns:
Win/loss record
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes |
Implementation Reference
- src/opendota_server/server.py:514-540 (handler)The handler function implementing the get_player_win_loss tool. It is decorated with @mcp.tool(), serving as both the implementation and registration. Fetches win/loss data from the OpenDota API endpoint `/players/{account_id}/wl`, handles errors, computes win rate, and returns a formatted string summary.@mcp.tool() async def get_player_win_loss(account_id: int) -> str: """Get win/loss statistics for a player. Args: account_id: Steam32 account ID of the player Returns: Win/loss record """ wl_data = await make_opendota_request(f"players/{account_id}/wl") if "error" in wl_data: return f"Error retrieving win/loss data: {wl_data['error']}" wins = wl_data.get("win", 0) losses = wl_data.get("lose", 0) total = wins + losses win_rate = (wins / total * 100) if total > 0 else 0 return ( f"Win/Loss Record for Player ID {account_id}:\n" f"Wins: {wins}\n" f"Losses: {losses}\n" f"Total Games: {total}\n" f"Win Rate: {win_rate:.2f}%" )