get_event_data
Retrieve a list of in-game events from the League of Legends client using the MCP server. Access event data for analysis or integration purposes.
Instructions
Get a list of events that have occurred in the game.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:176-184 (handler)The handler function for the 'get_event_data' tool, decorated with @mcp.tool() for registration and @with_timeout for error handling. It fetches event data from the League of Legends live client API endpoint '/liveclientdata/eventdata' using an HTTP client.@mcp.tool() @with_timeout async def get_event_data() -> dict: """ Get a list of events that have occurred in the game. """ async with get_lol_client() as client: response = await client.get("/liveclientdata/eventdata") return response.json()
- main.py:18-47 (helper)Helper decorator 'with_timeout' applied to the get_event_data handler to manage HTTP timeouts, connection errors, and other exceptions 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 'get_lol_client' used by the get_event_data handler to create an authenticated HTTP client for the LoL client API.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 )