get_manager
Retrieve comprehensive Fantasy Premier League manager details, including name, team history, and league participation, by specifying a team ID for analysis and insights.
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
| Name | Required | Description | Default |
|---|---|---|---|
| team_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"team_id": {
"title": "Team Id",
"type": "integer"
}
},
"required": [
"team_id"
],
"title": "get_managerArguments",
"type": "object"
}
Implementation Reference
- src/fpl_mcp/fpl/tools/team.py:304-318 (handler)MCP tool handler for 'get_manager'. Wraps the helper function get_manager_info with error handling.@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)}
- Implements the core logic for fetching and formatting FPL manager details from the API, including caching.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)}"}
- src/fpl_mcp/__main__.py:142-146 (registration)Registration calls that invoke register_team_tools(mcp), which defines and registers the get_manager tool.# Register team, manager, league, and player tools register_team_tools(mcp) register_manager_tools(mcp) register_league_tools(mcp) register_player_tools(mcp)