get_recent_matches_tool
Retrieves recent match history for a League of Legends player using their game name and tag line. Returns match summaries with champion, score, and result.
Instructions
đšī¸ Get the player's recent match history.
Returns a brief summary of the player's most recent matches, including champion, score, and result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game_name | Yes | ||
| tag_line | Yes | ||
| count | No |
Implementation Reference
- src/server.py:132-142 (handler)The MCP tool handler function 'get_recent_matches_tool'. It uses @mcp.tool() decorator (registration), accepts game_name, tag_line, and count parameters, fetches the player's PUUID, then calls the helper get_recent_matches() to retrieve and format recent match history.
@mcp.tool() async def get_recent_matches_tool(game_name: str, tag_line: str, count: int = 3) -> str: """ đšī¸ Get the player's recent match history. Returns a brief summary of the player's most recent matches, including champion, score, and result. """ puuid = await get_puuid(game_name, tag_line) if not puuid: return "Failed to find player." return await get_recent_matches(puuid, count) - src/server.py:112-129 (helper)Helper function 'get_recent_matches' that executes the actual Riot API calls. It fetches match IDs by PUUID, retrieves each match, extracts participant data (champion, KDA, win/loss), and returns formatted strings.
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) - src/server.py:132-133 (registration)The tool is registered via the @mcp.tool() decorator on the get_recent_matches_tool function (line 132).
@mcp.tool() async def get_recent_matches_tool(game_name: str, tag_line: str, count: int = 3) -> str: - src/server.py:133-136 (schema)Input schema defined via function signature: game_name (str), tag_line (str), count (int, default 3). The docstring serves as the description.
async def get_recent_matches_tool(game_name: str, tag_line: str, count: int = 3) -> str: """ đšī¸ Get the player's recent match history.