Skip to main content
Glama
rishijatia

Fantasy Premier League MCP Server

get_manager

Retrieve detailed Fantasy Premier League manager data including history, team details, and league information by providing a specific team ID.

Instructions

Get detailed information about an FPL manager

    Args:
        team_id: FPL team ID to look up
        
    Returns:
        Manager information including history, name, team details, and leagues
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
team_idYes

Implementation Reference

  • The MCP tool handler for 'get_manager'. This decorated function handles the tool call, validates input via signature, and delegates to get_manager_info for the core logic.
    @mcp.tool()
    async def get_manager(team_id: int) -> Dict[str, Any]:
        """Get detailed information about an FPL manager
        
        Args:
            team_id: FPL team ID to look up
            
        Returns:
            Manager information including history, name, team details, and leagues
        """
        try:
            return await get_manager_info(team_id)
        except Exception as e:
            logger.error(f"Error in get_manager: {e}")
            return {"error": str(e)}
  • The registration call for team tools, which includes the get_manager tool. register_team_tools(mcp) invokes the decorators in team.py to register the tool with the MCP server.
    # Register team, manager, league, and player tools
    register_team_tools(mcp)
    register_manager_tools(mcp)
    register_league_tools(mcp)
    register_player_tools(mcp)
  • Core helper function that fetches manager/team entry data from the FPL API using authentication, formats it, applies caching, and returns structured manager information.
    async def get_manager_info(team_id: int) -> Dict[str, Any]:
        """
        Get detailed information about a team manager
        
        Args:
            team_id: FPL team ID to look up
            
        Returns:
            Manager information including history, name, and team details
        """
        # Check cache first
        cache_key = f"manager_info_{team_id}"
        cached_data = cache.cache.get(cache_key)
        
        if cached_data and cached_data[0] + 3600 > time.time():  # 1 hour cache
            return cached_data[1]
        
        # Get auth manager
        auth_manager = get_auth_manager()
        
        try:
            # Fetch team entry data
            entry_data = await auth_manager.get_entry_data(team_id)
            
            # Format the response
            manager_info = {
                "team_id": team_id,
                "team_name": entry_data.get("name", "Unknown"),
                "manager_name": f"{entry_data.get('player_first_name', '')} {entry_data.get('player_last_name', '')}".strip(),
                "started_event": entry_data.get("started_event"),
                "overall_rank": entry_data.get("summary_overall_rank"),
                "overall_points": entry_data.get("summary_overall_points"),
                "value": entry_data.get("last_deadline_value") / 10.0 if entry_data.get("last_deadline_value") else 0,
                "bank": entry_data.get("last_deadline_bank") / 10.0 if entry_data.get("last_deadline_bank") else 0,
                "kit": entry_data.get("kit"),
                "region": entry_data.get("player_region_name"),
                "joined_time": entry_data.get("joined_time"),
                "leagues": {
                    "classic": entry_data.get("leagues", {}).get("classic", []),
                    "h2h": entry_data.get("leagues", {}).get("h2h", []),
                    "cup": entry_data.get("leagues", {}).get("cup", {})
                }
            }
            
            # Cache the result
            cache.cache[cache_key] = (time.time(), manager_info)
            
            return manager_info
        except Exception as e:
            logger.error(f"Error fetching manager info for team {team_id}: {e}")
            return {"error": f"Failed to retrieve manager info: {str(e)}"}

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/rishijatia/fantasy-pl-mcp'

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