get_league_standings
Retrieve Fantasy Premier League standings and team details by providing a specific league ID. Access league information for analysis and comparison using the FPL MCP Server.
Instructions
Get standings for a specified FPL league
Args:
league_id: ID of the league to fetch
Returns:
League information with standings and team details
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| league_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"league_id": {
"title": "League Id",
"type": "integer"
}
},
"required": [
"league_id"
],
"title": "get_league_standingsArguments",
"type": "object"
}
Implementation Reference
- src/fpl_mcp/__main__.py:143-146 (registration)Calls register_league_tools(mcp) which registers all league tools including get_league_standingsregister_team_tools(mcp) register_manager_tools(mcp) register_league_tools(mcp) register_player_tools(mcp)
- src/fpl_mcp/fpl/tools/leagues.py:1119-1129 (registration)Registers the get_league_standings tool using @mcp.tool() decorator within register_tools functionasync def get_league_standings(league_id: int) -> Dict[str, Any]: """Get standings for a specified FPL league Args: league_id: ID of the league to fetch Returns: League information with standings and team details """ # When directly using the tool, enforce size check return await _get_league_standings(league_id)
- Primary MCP tool handler for get_league_standings; thin wrapper that calls core implementationasync def get_league_standings(league_id: int) -> Dict[str, Any]: """Get standings for a specified FPL league Args: league_id: ID of the league to fetch Returns: League information with standings and team details """ # When directly using the tool, enforce size check return await _get_league_standings(league_id)
- src/fpl_mcp/fpl/tools/leagues.py:203-226 (handler)Core handler logic: fetches raw data, parses standings, applies limits, handles errorsasync def _get_league_standings(league_id: int) -> Dict[str, Any]: """ Get standings for a specified FPL league Args: league_id: ID of the league to fetch Returns: League information with standings and team details """ # Get raw league data data = await get_league_standings_data(league_id) # Check for errors if "error" in data: return data # Parse league standings and limit results if needed parsed_data = parse_league_standings(data) # If we have too many teams but aren't checking size, limit the results if "standings" in parsed_data and len(parsed_data["standings"]) > LEAGUE_RESULTS_LIMIT: parsed_data["standings"] = parsed_data["standings"][:LEAGUE_RESULTS_LIMIT] parsed_data["limited"] = True return parsed_data
- Helper: Fetches raw league standings data from FPL API with caching and authentication@cached("league_standings", ttl=3600) async def get_league_standings_data(league_id: int) -> Dict[str, Any]: """ Get raw league standings data from the FPL API Args: league_id: ID of the league to fetch Returns: Raw league data from the API or error message """ auth_manager = get_auth_manager() # Construct the URL url = f"{FPL_API_BASE_URL}/leagues-classic/{league_id}/standings/" # Get league data try: data = await auth_manager.make_authed_request(url) return data except Exception as e: logger.error(f"Error fetching league standings: {e}") return { "error": f"Failed to retrieve league standings: {str(e)}" }