get_player_summary
Retrieve a full player profile summary including level, solo rank, top champion masteries, and recent matches.
Instructions
๐งพ Get a complete summary of a player's profile.
Includes level, solo rank, top champion masteries, and recent matches in a single output.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game_name | Yes | ||
| tag_line | Yes | ||
| language | No | en_US |
Implementation Reference
- src/server.py:178-209 (handler)The handler function for the get_player_summary MCP tool. Fetches player profile, rank, top champion masteries, and recent matches, combining them into a single formatted summary string.
@mcp.tool() async def get_player_summary(game_name: str, tag_line: str, language: str = "en_US") -> str: """ ๐งพ Get a complete summary of a player's profile. Includes level, solo rank, top champion masteries, and recent matches in a single output. """ puuid = await get_puuid(game_name, tag_line) if not puuid: return "Failed to find player." champ_map = await get_champion_map(language) summoner = await get_summoner_by_puuid(puuid) if not summoner: return "Failed to get summoner profile." level = summoner["summonerLevel"] rank = await get_rank_by_summoner_id(summoner["id"]) top_champs = await get_top_champions(puuid, champ_map, count=3) matches = await get_recent_matches(puuid) return f""" ๐ค {game_name} (Level {level}) ๐ Rank: {rank} ๐ฅ Top Champions: {top_champs} ๐น๏ธ Recent Matches: {matches} """ - src/server.py:178-178 (registration)Registration of get_player_summary as an MCP tool via the @mcp.tool() decorator.
@mcp.tool() - src/server.py:18-33 (helper)Base helper function used by get_player_summary for making Riot API requests.
async def riot_request( url: str, region: str = "kr", params: dict[str, Any] | None = None ) -> dict[str, Any] | None: headers = { "X-Riot-Token": RIOT_API_KEY, "Content-Type": "application/json", } async with httpx.AsyncClient() as client: try: full_url = f"https://{region}.api.riotgames.com{url}" res = await client.get(full_url, headers=headers, params=params, timeout=30.0) res.raise_for_status() return res.json() except Exception as e: print(f"Riot API Error: {e}") return None - src/server.py:51-63 (helper)Helper function called by get_player_summary to resolve a Riot ID to a PUUID.
async def get_puuid(game_name: str, tag_line: str) -> str | None: url = f"https://asia.api.riotgames.com/riot/account/v1/accounts/by-riot-id/{game_name}/{tag_line}" headers = { "X-Riot-Token": RIOT_API_KEY, "Content-Type": "application/json", } try: async with httpx.AsyncClient() as client: res = await client.get(url, headers=headers) res.raise_for_status() return res.json()["puuid"] except Exception: return None - src/server.py:112-129 (helper)Helper function called by get_player_summary to fetch and format recent matches.
async def get_recent_matches(puuid: str, count: int = 3) -> str: match_ids = await riot_request( f"/lol/match/v5/matches/by-puuid/{puuid}/ids", region="asia", params={"count": count} ) if not match_ids: return "No recent matches found." matches = [] for match_id in match_ids: match = await riot_request(f"/lol/match/v5/matches/{match_id}", region="asia") if match: participant = next((p for p in match["info"]["participants"] if p["puuid"] == puuid), None) if participant: champ = participant["championName"] k, d, a = participant["kills"], participant["deaths"], participant["assists"] result = "Win" if participant["win"] else "Loss" matches.append(f"{match_id} {champ}: {k}/{d}/{a} - {result}") return "\n".join(matches)