Skip to main content
Glama
johnnyinlee

lol-client-mcp Public

get_active_player

Retrieve current player data from the League of Legends client, including stats and game information for real-time analysis.

Instructions

Get all data about the active player.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:77-85 (handler)
    The handler function for the 'get_active_player' tool. It is decorated with @mcp.tool() for registration and @with_timeout for error handling. Fetches active player data from the League of Legends live client API endpoint '/liveclientdata/activeplayer' and returns it as a dictionary.
    @mcp.tool()
    @with_timeout
    async def get_active_player() -> dict:
        """
        Get all data about the active player.
        """
        async with get_lol_client() as client:
            response = await client.get("/liveclientdata/activeplayer")
            return response.json()
  • main.py:50-59 (helper)
    Helper function to create an httpx AsyncClient configured for the LoL client API, used by the get_active_player 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
        )
  • main.py:18-47 (helper)
    Decorator applied to the handler to manage various HTTP errors and timeouts, returning standardized error responses.
    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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/johnnyinlee/lol-client-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server