get_player_list
Fetch the list of in-game heroes and their stats using this tool connected to the League of Legends Live Client Data API. Access essential player data for enhanced analysis and decision-making.
Instructions
Retrieve the list of heroes in the game and their stats.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:121-129 (handler)The handler function for the 'get_player_list' tool. Decorated with @mcp.tool() for registration and @with_timeout for error handling. Fetches the player list from the League of Legends client API at /liveclientdata/playerlist and returns it as a list of dictionaries.@mcp.tool() @with_timeout async def get_player_list() -> list[dict]: """ Retrieve the list of heroes in the game and their stats. """ async with get_lol_client() as client: response = await client.get("/liveclientdata/playerlist") return response.json()
- main.py:121-121 (registration)The @mcp.tool() decorator registers the get_player_list function as an MCP tool.@mcp.tool()
- main.py:18-47 (helper)Shared helper decorator 'with_timeout' applied to the get_player_list handler for handling HTTP errors and timeouts when communicating with the LOL client.def with_timeout(func: Callable[..., Awaitable[T]]) -> Callable[..., Awaitable[T]]: """ Decorator to handle timeout exceptions for async functions. """ @functools.wraps(func) async def wrapper(*args: Any, **kwargs: Any) -> T: try: return await func(*args, **kwargs) except httpx.TimeoutException: return { "error": "Game has not started or connection failed.", "code": "TIMEOUT" } except httpx.ConnectError: return { "error": "Cannot connect to the game client. Please check if the game is running.", "code": "CONNECTION_ERROR" } except httpx.HTTPStatusError as e: return { "error": f"Server error: HTTP {e.response.status_code}", "code": "HTTP_ERROR", "status": e.response.status_code } except Exception as e: return { "error": f"An error occurred: {str(e)}", "code": "UNKNOWN_ERROR" } return wrapper
- main.py:50-58 (helper)Helper function to create an httpx AsyncClient configured for the LOL client API, used by the get_player_list handler.def get_lol_client(): """ Create an HTTP client for the League of Legends client. """ return httpx.AsyncClient( base_url=LOL_CLIENT_HOST, verify="./certs/riotgames.pem", timeout=DEFAULT_TIMEOUT )