get_player_peers
Retrieve players who frequently play Dota 2 with a specific player by providing their Steam32 account ID to identify common teammates and opponents.
Instructions
Get players who have played with the specified player.
Args:
account_id: Steam32 account ID of the player
limit: Number of peers to retrieve (default: 5)
Returns:
List of players frequently played with
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes | ||
| limit | No |
Implementation Reference
- src/opendota_server/server.py:860-902 (handler)The handler function for the 'get_player_peers' MCP tool. It is decorated with @mcp.tool() for registration. Fetches peers data from the OpenDota API, sorts by games played together, limits results, calculates win rates, and formats a readable string output.@mcp.tool() async def get_player_peers(account_id: int, limit: int = 5) -> str: """Get players who have played with the specified player. Args: account_id: Steam32 account ID of the player limit: Number of peers to retrieve (default: 5) Returns: List of players frequently played with """ if limit > 20: limit = 20 # Cap for reasonable response size peers_data = await make_opendota_request(f"players/{account_id}/peers") if "error" in peers_data: return f"Error retrieving peers data: {peers_data['error']}" if not peers_data or not isinstance(peers_data, list) or len(peers_data) == 0: return "No peers found for this player." # Sort by games played together sorted_peers = sorted(peers_data, key=lambda x: x.get("games", 0), reverse=True) formatted_peers = [] for i, peer in enumerate(sorted_peers[:limit]): peer_account_id = peer.get("account_id", "Unknown") peer_name = peer.get("personaname", "Anonymous") games = peer.get("games", 0) wins = peer.get("win", 0) win_rate = (wins / games * 100) if games > 0 else 0 formatted_peers.append( f"{i+1}. {peer_name} (ID: {peer_account_id})\n" f" Games together: {games}\n" f" Wins: {wins}\n" f" Win Rate: {win_rate:.2f}%" ) return f"Peers for Player ID {account_id}:\n\n" + "\n\n".join(formatted_peers)
- src/opendota_server/server.py:860-860 (registration)The @mcp.tool() decorator registers the get_player_peers function as an MCP tool.@mcp.tool()