get_top_champions_tool
Retrieve a player's top champion masteries by their game name and tag line. Returns a list of most-played champions sorted by mastery points.
Instructions
🔝 Get the player's top champion masteries.
Returns a list of the player's most-played champions based on mastery points.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game_name | Yes | ||
| tag_line | Yes | ||
| language | No | en_US | |
| count | No |
Implementation Reference
- src/server.py:98-109 (handler)The main handler for the 'get_top_champions_tool' MCP tool. Resolves the player PUUID, loads the champion name map, and delegates to the helper 'get_top_champions' to fetch and format champion mastery data.
async def get_top_champions_tool(game_name: str, tag_line: str, language: str = "en_US", count: int = 3) -> str: """ 🔝 Get the player's top champion masteries. Returns a list of the player's most-played champions based on mastery points. """ puuid = await get_puuid(game_name, tag_line) if not puuid: return "Failed to find player." champ_map = await get_champion_map(language) return await get_top_champions(puuid, champ_map, count) - src/server.py:97-97 (registration)The @mcp.tool() decorator registers 'get_top_champions_tool' as an MCP tool on the FastMCP instance.
@mcp.tool() - src/server.py:98-98 (schema)Input schema: accepts game_name (str), tag_line (str), optional language (default 'en_US'), and optional count (default 3). Returns a string.
async def get_top_champions_tool(game_name: str, tag_line: str, language: str = "en_US", count: int = 3) -> str: - src/server.py:84-94 (helper)Helper function that calls the Riot API champion-mastery endpoint and formats the top champions as a bulleted list string.
async def get_top_champions(puuid: str, champ_map: dict[int, str], count: int = 3) -> str: mastery_data = await riot_request( f"/lol/champion-mastery/v4/champion-masteries/by-puuid/{puuid}/top", params={"count": count} ) if not mastery_data: return "No champion mastery data found." return "\n".join( f"- {champ_map.get(c['championId'], f'ID({c['championId']})')}: Level {c['championLevel']}, {c['championPoints']} pts" for c in mastery_data )