Skip to main content
Glama

get_player_rankings

Retrieve a Dota 2 player's hero performance rankings by providing their Steam32 account ID to analyze competitive statistics.

Instructions

Get player hero rankings.

Args:
    account_id: Steam32 account ID of the player

Returns:
    Player's hero rankings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes

Implementation Reference

  • The main handler function for the 'get_player_rankings' MCP tool. Decorated with @mcp.tool(), it fetches player hero rankings from the OpenDota API endpoint `/players/{account_id}/rankings`, retrieves hero names, computes percentiles, and returns a formatted string summary of the top hero rankings for the player.
    @mcp.tool()
    async def get_player_rankings(account_id: int) -> str:
        """Get player hero rankings.
    
        Args:
            account_id: Steam32 account ID of the player
    
        Returns:
            Player's hero rankings
        """
        rankings_data = await make_opendota_request(f"players/{account_id}/rankings")
    
        if "error" in rankings_data:
            return f"Error retrieving rankings data: {rankings_data['error']}"
    
        if (
            not rankings_data
            or not isinstance(rankings_data, list)
            or len(rankings_data) == 0
        ):
            return "No ranking data found for this player."
    
        # Get hero names (just for context)
        heroes_data = await make_opendota_request("heroes")
        hero_id_to_name = {}
    
        if not isinstance(heroes_data, dict) and isinstance(heroes_data, list):
            for hero in heroes_data:
                if isinstance(hero, dict) and "id" in hero and "localized_name" in hero:
                    hero_id = hero.get("id")
                    hero_name = hero.get("localized_name")
                    if hero_id is not None and hero_name is not None:
                        hero_id_to_name[hero_id] = hero_name
    
        formatted_rankings = []
    
        for ranking in rankings_data:
            hero_id = ranking.get("hero_id", 0)
            hero_name = hero_id_to_name.get(hero_id, f"Hero {hero_id}")
            score = ranking.get("score", 0)
            percent_rank = ranking.get("percent_rank", 0) * 100  # Convert to percentage
    
            formatted_rankings.append(
                f"{hero_name} (ID: {hero_id})\n"
                f"Score: {score:.2f}\n"
                f"Percentile: {percent_rank:.2f}%"
            )
    
        return f"Hero Rankings for Player ID {account_id}:\n\n" + "\n\n".join(
            formatted_rankings
        )

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