Skip to main content
Glama

get_player_peers

Retrieve players frequently matched with a specific Dota 2 player by Steam32 account ID to analyze team dynamics and common allies.

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
NameRequiredDescriptionDefault
account_idYes
limitNo

Implementation Reference

  • The core handler function for the 'get_player_peers' MCP tool. It is decorated with @mcp.tool(), which serves as both the implementation and registration in FastMCP. Fetches peer data from OpenDota API endpoint 'players/{account_id}/peers', sorts by games played together, and formats a response listing top peers with stats.
    @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)
  • The @mcp.tool() decorator registers the get_player_peers function as an MCP tool with the name matching the function name.
    @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