fpl-mcp-server 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fpl_mcp_server-0.1.3.dist-info/METADATA +137 -0
- fpl_mcp_server-0.1.3.dist-info/RECORD +33 -0
- fpl_mcp_server-0.1.3.dist-info/WHEEL +4 -0
- fpl_mcp_server-0.1.3.dist-info/entry_points.txt +2 -0
- fpl_mcp_server-0.1.3.dist-info/licenses/LICENSE +21 -0
- src/cache.py +162 -0
- src/client.py +273 -0
- src/config.py +33 -0
- src/constants.py +118 -0
- src/exceptions.py +114 -0
- src/formatting.py +299 -0
- src/main.py +41 -0
- src/models.py +526 -0
- src/prompts/__init__.py +18 -0
- src/prompts/chips.py +127 -0
- src/prompts/league_analysis.py +250 -0
- src/prompts/player_analysis.py +141 -0
- src/prompts/squad_analysis.py +136 -0
- src/prompts/team_analysis.py +121 -0
- src/prompts/transfers.py +167 -0
- src/rate_limiter.py +101 -0
- src/resources/__init__.py +13 -0
- src/resources/bootstrap.py +183 -0
- src/state.py +443 -0
- src/tools/__init__.py +25 -0
- src/tools/fixtures.py +162 -0
- src/tools/gameweeks.py +392 -0
- src/tools/leagues.py +590 -0
- src/tools/players.py +840 -0
- src/tools/teams.py +397 -0
- src/tools/transfers.py +629 -0
- src/utils.py +226 -0
- src/validators.py +290 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FPL MCP Prompts - League Analysis and Differentials.
|
|
3
|
+
|
|
4
|
+
Prompts guide the LLM in analyzing league standings, comparing
|
|
5
|
+
managers, and finding differential players.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ..tools import mcp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@mcp.prompt()
|
|
12
|
+
def compare_managers(league_id: int, gameweek: int, *manager_names: str) -> str:
|
|
13
|
+
"""
|
|
14
|
+
Generate a prompt for comparing managers' teams in a league.
|
|
15
|
+
|
|
16
|
+
This prompt guides the LLM to analyze differences in team selection,
|
|
17
|
+
strategy, and performance between multiple managers.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
league_id: ID of the league (from FPL URL)
|
|
21
|
+
gameweek: Gameweek number to analyze
|
|
22
|
+
*manager_names: Variable number of manager names (2-4 managers)
|
|
23
|
+
"""
|
|
24
|
+
managers_str = ", ".join(manager_names) if manager_names else "{{manager1}}, {{manager2}}, ..."
|
|
25
|
+
num_managers = len(manager_names) if manager_names else "2-4"
|
|
26
|
+
|
|
27
|
+
return f"""Compare these managers' teams in league {league_id} for Gameweek {gameweek}: {managers_str}
|
|
28
|
+
|
|
29
|
+
**Comparison Framework:**
|
|
30
|
+
|
|
31
|
+
Analyze {num_managers} managers across multiple dimensions:
|
|
32
|
+
|
|
33
|
+
1. **Performance Summary:**
|
|
34
|
+
For each manager:
|
|
35
|
+
- Gameweek points scored
|
|
36
|
+
- Overall rank
|
|
37
|
+
- Total points for season
|
|
38
|
+
- Transfers made and cost
|
|
39
|
+
- Points left on bench
|
|
40
|
+
|
|
41
|
+
2. **Team Selection Analysis:**
|
|
42
|
+
|
|
43
|
+
**Captain Choices:**
|
|
44
|
+
- Who did each manager captain?
|
|
45
|
+
- Captain points scored
|
|
46
|
+
- Was it a differential or template choice?
|
|
47
|
+
|
|
48
|
+
**Formation & Structure:**
|
|
49
|
+
- Formation used (e.g., 3-4-3, 4-3-3)
|
|
50
|
+
- Premium player allocation
|
|
51
|
+
- Budget distribution
|
|
52
|
+
|
|
53
|
+
3. **Player Overlap Analysis:**
|
|
54
|
+
|
|
55
|
+
**Common Players:**
|
|
56
|
+
- Players owned by all managers
|
|
57
|
+
- Template players (high ownership)
|
|
58
|
+
- How many players in common?
|
|
59
|
+
|
|
60
|
+
**Differential Picks:**
|
|
61
|
+
- Unique players per manager
|
|
62
|
+
- Which differentials performed well?
|
|
63
|
+
- Which differentials flopped?
|
|
64
|
+
|
|
65
|
+
4. **Strategic Decisions:**
|
|
66
|
+
|
|
67
|
+
**Chip Usage:**
|
|
68
|
+
- Did anyone use a chip this gameweek?
|
|
69
|
+
- Impact of chip usage on points
|
|
70
|
+
|
|
71
|
+
**Transfer Strategy:**
|
|
72
|
+
- Number of transfers made
|
|
73
|
+
- Points hit taken (if any)
|
|
74
|
+
- Transfer effectiveness
|
|
75
|
+
|
|
76
|
+
5. **Performance Drivers:**
|
|
77
|
+
|
|
78
|
+
**Why did one manager outperform?**
|
|
79
|
+
- Better captain choice?
|
|
80
|
+
- Successful differentials?
|
|
81
|
+
- Avoided blanks?
|
|
82
|
+
- Chip usage?
|
|
83
|
+
|
|
84
|
+
**Key Differences:**
|
|
85
|
+
- Tactical variations
|
|
86
|
+
- Risk vs safety approach
|
|
87
|
+
- Budget allocation differences
|
|
88
|
+
|
|
89
|
+
6. **Bench Analysis:**
|
|
90
|
+
- Points left on bench per manager
|
|
91
|
+
- Bench strength comparison
|
|
92
|
+
- Auto-substitutions made
|
|
93
|
+
|
|
94
|
+
7. **xGI-Based Differential Analysis:**
|
|
95
|
+
|
|
96
|
+
For each unique differential pick:
|
|
97
|
+
- **xGI Output**: Player's xGI/90 over last 5 GW
|
|
98
|
+
- **xGI Delta**: Actual G+A minus xG+xA
|
|
99
|
+
* Positive delta (+2+): Overperformed (lucky haul, may not repeat)
|
|
100
|
+
* Negative delta (-2+): Underperformed (unlucky, due for improvement)
|
|
101
|
+
- **Verdict**: Was the differential choice based on strong underlying stats or recency bias?
|
|
102
|
+
|
|
103
|
+
**Data Access:**
|
|
104
|
+
|
|
105
|
+
Step 1: Get league standings to find manager names and team IDs:
|
|
106
|
+
- Tool: `fpl_get_league_standings`
|
|
107
|
+
- Parameters: league_id={league_id}
|
|
108
|
+
- Returns: List of managers with their team_id, entry_name, player_name, and points
|
|
109
|
+
|
|
110
|
+
Step 2: Compare managers using one of these approaches:
|
|
111
|
+
|
|
112
|
+
**Option A - Individual manager analysis:**
|
|
113
|
+
- Tool: `fpl_get_manager_gameweek_team`
|
|
114
|
+
- Parameters:
|
|
115
|
+
- manager_name: "Manager Name" (from league standings)
|
|
116
|
+
- league_id: {league_id}
|
|
117
|
+
- gameweek: {gameweek}
|
|
118
|
+
- Returns: Detailed team sheet with starting XI, bench, captain, transfers, points
|
|
119
|
+
|
|
120
|
+
**Option B - Side-by-side comparison:**
|
|
121
|
+
- Tool: `fpl_compare_managers`
|
|
122
|
+
- Parameters:
|
|
123
|
+
- manager_names: ["Manager1", "Manager2", "Manager3"] (2-4 managers)
|
|
124
|
+
- league_id: {league_id}
|
|
125
|
+
- gameweek: {gameweek}
|
|
126
|
+
- Returns: Comparison with common players, differentials, captain choices
|
|
127
|
+
|
|
128
|
+
**Additional data sources:**
|
|
129
|
+
- Resource `fpl://bootstrap/players` - All player details, ownership %, positions, prices
|
|
130
|
+
- Resource `fpl://current-gameweek` - Current gameweek status and deadline information
|
|
131
|
+
- For differentials: `fpl://player/{{{{player_name}}}}/summary` - Get xG, xA, xGI data
|
|
132
|
+
|
|
133
|
+
**Output Format:**
|
|
134
|
+
1. Performance summary table
|
|
135
|
+
2. Captain choices comparison
|
|
136
|
+
3. Common players list
|
|
137
|
+
4. Unique selections per manager
|
|
138
|
+
5. Key performance drivers analysis (include xGI context for differentials)
|
|
139
|
+
6. Strategic insights:
|
|
140
|
+
- What worked well? (underlying stats or luck?)
|
|
141
|
+
- What didn't work? (poor xGI or unlucky?)
|
|
142
|
+
- Lessons learned
|
|
143
|
+
7. Recommendations for catching up (if behind)"""
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@mcp.prompt()
|
|
147
|
+
def find_league_differentials(league_id: int, max_ownership: float = 30.0) -> str:
|
|
148
|
+
"""
|
|
149
|
+
Generate a prompt for finding differential players in a league.
|
|
150
|
+
|
|
151
|
+
This prompt guides the LLM to identify low-owned players that could
|
|
152
|
+
provide a competitive advantage in a specific league.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
league_id: ID of the league to analyze
|
|
156
|
+
max_ownership: Maximum ownership % to consider as differential (default: 30%)
|
|
157
|
+
"""
|
|
158
|
+
return f"""Find differential players for competitive advantage in league {league_id}.
|
|
159
|
+
|
|
160
|
+
**Differential Analysis Framework:**
|
|
161
|
+
|
|
162
|
+
1. **Definition:**
|
|
163
|
+
Differentials are players owned by <{max_ownership}% of managers in your league
|
|
164
|
+
who have strong potential for points.
|
|
165
|
+
|
|
166
|
+
2. **League Context Analysis:**
|
|
167
|
+
- Total managers in league
|
|
168
|
+
- Current league standings
|
|
169
|
+
- Template players (high ownership)
|
|
170
|
+
- Common captain choices
|
|
171
|
+
|
|
172
|
+
3. **Differential Categories:**
|
|
173
|
+
|
|
174
|
+
**Premium Differentials (£9m+):**
|
|
175
|
+
- High-priced players with low league ownership
|
|
176
|
+
- Potential for big hauls
|
|
177
|
+
- Higher risk but higher reward
|
|
178
|
+
|
|
179
|
+
**Mid-Price Differentials (£6-9m):**
|
|
180
|
+
- Value picks with good fixtures
|
|
181
|
+
- Consistent performers
|
|
182
|
+
- Lower risk, steady returns
|
|
183
|
+
|
|
184
|
+
**Budget Differentials (<£6m):**
|
|
185
|
+
- Enablers with attacking potential
|
|
186
|
+
- Rotation risks but cheap
|
|
187
|
+
- Good for bench options
|
|
188
|
+
|
|
189
|
+
4. **Evaluation Criteria (xGI-Based):**
|
|
190
|
+
For each differential candidate:
|
|
191
|
+
|
|
192
|
+
**Primary Metrics:**
|
|
193
|
+
- **xGI/90**: Expected goal involvements per 90 minutes (last 5 GW)
|
|
194
|
+
* >0.6 = Elite differential (rare but high upside)
|
|
195
|
+
* 0.4-0.6 = Strong differential (good balance of risk/reward)
|
|
196
|
+
* 0.2-0.4 = Budget differential (acceptable for cheap options)
|
|
197
|
+
* <0.2 = Avoid (poor underlying output)
|
|
198
|
+
|
|
199
|
+
- **xGI Delta**: Actual G+A minus xG+xA
|
|
200
|
+
* Negative delta (-2+): Unlucky, prime differential opportunity (buy low)
|
|
201
|
+
* Near zero: Performing to expectation
|
|
202
|
+
* Positive delta (+2+): Lucky, avoid (regression risk)
|
|
203
|
+
|
|
204
|
+
**Secondary Metrics:**
|
|
205
|
+
- Upcoming fixture difficulty (next 4-6 GW)
|
|
206
|
+
- Minutes played % (rotation risk if <70%)
|
|
207
|
+
- Injury status
|
|
208
|
+
- League ownership % vs global ownership %
|
|
209
|
+
- Price and value
|
|
210
|
+
|
|
211
|
+
5. **Strategic Recommendations:**
|
|
212
|
+
|
|
213
|
+
**When to use differentials:**
|
|
214
|
+
- Chasing league leaders (need to take risks)
|
|
215
|
+
- Good fixture runs ahead
|
|
216
|
+
- Template players have tough fixtures
|
|
217
|
+
|
|
218
|
+
**When to avoid differentials:**
|
|
219
|
+
- Leading the league (play it safe)
|
|
220
|
+
- Differential has injury concerns
|
|
221
|
+
- Rotation risk too high
|
|
222
|
+
|
|
223
|
+
6. **Risk Assessment:**
|
|
224
|
+
- High Risk: Low ownership, rotation risk, tough fixtures
|
|
225
|
+
- Medium Risk: Moderate ownership, some rotation, mixed fixtures
|
|
226
|
+
- Low Risk: Decent ownership, nailed on, good fixtures
|
|
227
|
+
|
|
228
|
+
**Data Access:**
|
|
229
|
+
- Use tool `fpl_get_league_standings` with league ID - League ownership patterns
|
|
230
|
+
- Tool `fpl_get_top_performers` - Identify current form players to find differential opportunities
|
|
231
|
+
- `fpl://bootstrap/players` - All players with ownership
|
|
232
|
+
- `fpl://player/{{{{player_name}}}}/summary` - Detailed player analysis
|
|
233
|
+
- `fpl://team/{{{{team_name}}}}/fixtures/{{{{num_gameweeks}}}}` - Fixture difficulty (default 5 GWs)
|
|
234
|
+
|
|
235
|
+
**Output Format:**
|
|
236
|
+
1. League template analysis (most owned players)
|
|
237
|
+
2. Differential candidates by price bracket:
|
|
238
|
+
- Premium differentials
|
|
239
|
+
- Mid-price differentials
|
|
240
|
+
- Budget differentials
|
|
241
|
+
3. For each differential:
|
|
242
|
+
- League ownership %
|
|
243
|
+
- Overall ownership %
|
|
244
|
+
- Form and fixtures
|
|
245
|
+
- Risk level
|
|
246
|
+
- Recommendation
|
|
247
|
+
4. Strategic advice:
|
|
248
|
+
- Best differentials for your situation
|
|
249
|
+
- Timing for bringing them in
|
|
250
|
+
- Risk vs reward assessment"""
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FPL MCP Prompts - Player Comparison and Analysis.
|
|
3
|
+
|
|
4
|
+
Prompts guide the LLM in comparing multiple players side-by-side
|
|
5
|
+
for informed transfer decisions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ..tools import mcp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@mcp.prompt()
|
|
12
|
+
def compare_players(*player_names: str) -> str:
|
|
13
|
+
"""
|
|
14
|
+
Compare players using underlying metrics and probability-based projections.
|
|
15
|
+
|
|
16
|
+
This prompt prioritizes xG/xA/xGI over retrospective points, identifies positive/negative
|
|
17
|
+
regression candidates, and accounts for ownership context.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
*player_names: 2-5 player names to compare
|
|
21
|
+
"""
|
|
22
|
+
players_str = ", ".join(player_names) if player_names else "{{player1}}, {{player2}}, ..."
|
|
23
|
+
|
|
24
|
+
return f"""Compare these FPL players: {players_str}
|
|
25
|
+
|
|
26
|
+
**CRITICAL: Prioritize underlying stats over retrospective points. Identify regression candidates.**
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 📊 **Comparison Matrix**
|
|
31
|
+
|
|
32
|
+
For each player, extract and compare:
|
|
33
|
+
|
|
34
|
+
### **1. Underlying Output Metrics (PRIMARY)**
|
|
35
|
+
- **npxG (Non-Penalty Expected Goals)**: Total over last 5 GW + per 90 min
|
|
36
|
+
- **xA (Expected Assists)**: Total over last 5 GW + per 90 min
|
|
37
|
+
- **xGI (Expected Goal Involvements)**: npxG + xA over last 5 GW + per 90 min
|
|
38
|
+
- **Big Chances Received**: Count over last 5 GW (proxy for service quality)
|
|
39
|
+
- **Touches in Penalty Box**: Per 90 min (attackers only)
|
|
40
|
+
- **Defensive Contribution**: Per 90 min (defenders/mids with defensive role)
|
|
41
|
+
|
|
42
|
+
### **2. Regression Analysis (CRITICAL)**
|
|
43
|
+
Calculate **xGI Delta** for each player:
|
|
44
|
+
- `Actual G+A (last 5 GW)` MINUS `xG + xA (last 5 GW)`
|
|
45
|
+
- **Positive Delta (+2 to +4)**: Player is OVERPERFORMING → Sell risk (negative regression incoming)
|
|
46
|
+
- **Negative Delta (-2 to -4)**: Player is UNDERPERFORMING → BUY OPPORTUNITY (positive regression likely)
|
|
47
|
+
- **Near Zero (-1 to +1)**: Performing to expectation → Stable asset
|
|
48
|
+
|
|
49
|
+
### **3. Price Efficiency (Secondary)**
|
|
50
|
+
- **Cost per xGI/90**: `Price ÷ (xGI per 90 minutes)`
|
|
51
|
+
*Lower = better value*
|
|
52
|
+
- **Recent Price Changes**: +/-0.1m in last 7 days?
|
|
53
|
+
*Rising price = urgency to buy before lockout*
|
|
54
|
+
- **Transfer Delta (last 3 GW)**: Net transfers in/out
|
|
55
|
+
*Rising ownership = potential price rise = urgency*
|
|
56
|
+
|
|
57
|
+
### **4. Fixture Analysis (4-6 GW Horizon)**
|
|
58
|
+
For next **6 gameweeks**:
|
|
59
|
+
- **Average FDR**: Simple mean of fixture difficulty (1-5)
|
|
60
|
+
- **Fixture Swing Detection**:
|
|
61
|
+
- If FDR drops by >1.0 after GW[X], note: "Target for GW[X] transfer"
|
|
62
|
+
- If DGW detected, FLAG with 🔥
|
|
63
|
+
- **Home/Away Balance**: Defenders favor HOME fixtures (higher clean sheet odds)
|
|
64
|
+
|
|
65
|
+
### **5. Ownership Context (Differential Math)**
|
|
66
|
+
- **Global Ownership %**: From bootstrap data
|
|
67
|
+
- **Effective Ownership (EO) Estimate**:
|
|
68
|
+
- If Top 100K avg = 25% but global = 15%, EO ≈ 25% (use Top 100K proxy)
|
|
69
|
+
- **Template Players**: EO >40% → Must own for *rank protection*
|
|
70
|
+
- **Differentials**: EO <15% → High risk, high reward if chasing rank
|
|
71
|
+
|
|
72
|
+
### **6. Availability & Minutes Security**
|
|
73
|
+
- **Status**: Available / Doubtful / Injured / Suspended
|
|
74
|
+
- **Minutes Played (last 5 GW)**: Total + % of available minutes
|
|
75
|
+
*<75% of possible minutes = rotation risk*
|
|
76
|
+
- **Benchings (last 5 GW)**: Count of games started on bench
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 🎯 **Output Format**
|
|
81
|
+
|
|
82
|
+
### **1. Quick Comparison Table**
|
|
83
|
+
Present side-by-side:
|
|
84
|
+
|
|
85
|
+
| Metric | {players_str} |
|
|
86
|
+
|--------|{"-" * (len(players_str) + 2)}|
|
|
87
|
+
| **npxG (5 GW)** | ... |
|
|
88
|
+
| **xA (5 GW)** | ... |
|
|
89
|
+
| **xGI (5 GW)** | ... |
|
|
90
|
+
| **xGI Delta** | ... (🔴 overperforming / 🟢 underperforming / ⚪ stable) |
|
|
91
|
+
| **Cost/xGI per 90** | ... |
|
|
92
|
+
| **Avg FDR (6 GW)** | ... |
|
|
93
|
+
| **Ownership %** | ... |
|
|
94
|
+
| **Minutes (5 GW)** | ... / 450 possible |
|
|
95
|
+
|
|
96
|
+
### **2. Regression Insights**
|
|
97
|
+
- **Positive Regression Targets** (underperforming xGI): [List players with negative delta]
|
|
98
|
+
→ *"Buy low, sell high" candidates*
|
|
99
|
+
- **Negative Regression Risks** (overperforming xGI): [List players with positive delta]
|
|
100
|
+
→ *Consider selling before decline*
|
|
101
|
+
|
|
102
|
+
### **3. Fixture Advantage**
|
|
103
|
+
- **Best Fixtures (Next 6 GW)**: [Player with lowest avg FDR]
|
|
104
|
+
- **Fixture Swing Alert**: [Any player with FDR drop >1.0]
|
|
105
|
+
- **DGW Candidates**: [Flag any players in teams with DGW detected]
|
|
106
|
+
|
|
107
|
+
### **4. Recommendation**
|
|
108
|
+
|
|
109
|
+
**Best Overall Bet:**
|
|
110
|
+
[Player name] — Justification using:
|
|
111
|
+
- xGI/90 dominance
|
|
112
|
+
- Positive regression potential (if negative xGI delta)
|
|
113
|
+
- Fixture advantage
|
|
114
|
+
- Price efficiency
|
|
115
|
+
|
|
116
|
+
**Differential Pick (if chasing rank):**
|
|
117
|
+
[Player with <15% ownership + strong xGI]
|
|
118
|
+
|
|
119
|
+
**Avoid:**
|
|
120
|
+
[Player with negative regression risk OR tough fixtures OR rotation risk]
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 🔧 **Tool Calls**
|
|
125
|
+
|
|
126
|
+
For each player, use:
|
|
127
|
+
1. **`fpl://player/{{{{player_name}}}}/summary`** → Get comprehensive stats, fixtures, history
|
|
128
|
+
*Provides: xG, xA, xGI, minutes, goals, assists, upcoming fixtures*
|
|
129
|
+
2. **`fpl://bootstrap/players`** → Get ownership %, price, transfer trends
|
|
130
|
+
*Provides: selected_by_percent, now_cost, transfers_in/out_event*
|
|
131
|
+
3. **`fpl_get_top_performers`** with `num_gameweeks=5` → Benchmark against top xGI players
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## ⚠️ **Critical Rules**
|
|
136
|
+
|
|
137
|
+
1. **NEVER recommend based on "form" or "PPG" alone** → Use xGI/90 + xGI delta
|
|
138
|
+
2. **ALWAYS calculate xGI Delta** → Regression is the #1 alpha source
|
|
139
|
+
3. **FLAG price rise urgency** → If transfers_in >50K last 3 days, note "Buy before rise"
|
|
140
|
+
4. **Context ownership** → Template (>40%) vs. Differential (<15%)
|
|
141
|
+
"""
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FPL MCP Prompts - Squad Performance Analysis.
|
|
3
|
+
|
|
4
|
+
Prompts guide the LLM in analyzing squad performance over recent gameweeks
|
|
5
|
+
using underlying metrics and regression analysis.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ..tools import mcp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@mcp.prompt()
|
|
12
|
+
def analyze_squad_performance(team_id: int, num_gameweeks: int = 5) -> str:
|
|
13
|
+
"""
|
|
14
|
+
Analyze squad performance using xGI-based metrics and regression analysis.
|
|
15
|
+
|
|
16
|
+
This prompt guides the LLM to identify underperforming/overperforming players
|
|
17
|
+
using underlying stats (xG, xA, xGI) rather than retrospective points.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
team_id: FPL team ID of the manager to analyze
|
|
21
|
+
num_gameweeks: Number of recent gameweeks to analyze (default: 5)
|
|
22
|
+
"""
|
|
23
|
+
return f"""Analyze FPL squad performance for team ID {team_id} over the last {num_gameweeks} gameweeks.
|
|
24
|
+
|
|
25
|
+
**OBJECTIVE: Identify transfer targets using xGI-based regression analysis, not retrospective points.**
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 📊 **Performance Analysis Framework**
|
|
30
|
+
|
|
31
|
+
For each player in the squad, analyze:
|
|
32
|
+
|
|
33
|
+
### **1. Underlying Output Metrics (PRIMARY)**
|
|
34
|
+
- **xGI/90 (Expected Goal Involvements per 90 min)**: Total xG + xA over last {num_gameweeks} GW, normalized per 90
|
|
35
|
+
- **Minutes Played**: Total minutes + % of available minutes
|
|
36
|
+
*<60% = rotation risk*
|
|
37
|
+
- **Games Played vs DNP**: Count starts, sub appearances, did not plays
|
|
38
|
+
|
|
39
|
+
### **2. Regression Analysis (CRITICAL)**
|
|
40
|
+
Calculate **xGI Delta** for each player:
|
|
41
|
+
- `Actual G+A (last {num_gameweeks} GW)` MINUS `xG + xA (last {num_gameweeks} GW)`
|
|
42
|
+
|
|
43
|
+
**Interpretation:**
|
|
44
|
+
- **Positive Delta (+2 to +4)**: OVERPERFORMING → Likely to regress (sell candidate)
|
|
45
|
+
- **Negative Delta (-2 to -4)**: UNDERPERFORMING → Due for improvement (keep/monitor)
|
|
46
|
+
- **Near Zero (-1 to +1)**: Performing to expectation (stable)
|
|
47
|
+
|
|
48
|
+
### **3. Player Categorization (xGI-Based)**
|
|
49
|
+
|
|
50
|
+
Instead of arbitrary PPG thresholds, use xGI/90:
|
|
51
|
+
|
|
52
|
+
- ⭐ **Elite Assets** (xGI/90 >0.6): Premium output, essential to keep
|
|
53
|
+
*Even if underperforming actual points (negative delta), underlying stats suggest improvement coming*
|
|
54
|
+
|
|
55
|
+
- ✅ **Strong Contributors** (xGI/90 0.35-0.6): Reliable options, monitor for regression
|
|
56
|
+
*If positive delta >+2, consider selling before decline*
|
|
57
|
+
|
|
58
|
+
- ⚠️ **Moderate Assets** (xGI/90 0.15-0.35): Acceptable for budget slots
|
|
59
|
+
*If negative delta <-2, potential buy-low candidates*
|
|
60
|
+
|
|
61
|
+
- 🚨 **Underperformers** (xGI/90 <0.15): Transfer candidates
|
|
62
|
+
*Low underlying output + poor fixtures = priority sell*
|
|
63
|
+
|
|
64
|
+
**Defenders/Goalkeepers:**
|
|
65
|
+
- Use defensive contribution + clean sheet odds instead of xGI
|
|
66
|
+
- xGC (Expected Goals Conceded) if available
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 🔍 **Transfer Priority Analysis**
|
|
71
|
+
|
|
72
|
+
### **For Each Underperformer (xGI/90 <0.15 OR injured):**
|
|
73
|
+
|
|
74
|
+
1. **Regression Context:**
|
|
75
|
+
- If negative xGI delta: "Unlucky, but underlying stats still poor → Sell"
|
|
76
|
+
- If positive xGI delta: "Overperforming low xGI → Definitely sell before regression"
|
|
77
|
+
|
|
78
|
+
2. **Availability Check:**
|
|
79
|
+
- Injured/Suspended → 🚨 **URGENT** (transfer immediately)
|
|
80
|
+
- DNP last 2 games → ⚠️ **HIGH** (rotation risk)
|
|
81
|
+
- Minutes <60% last {num_gameweeks} GW → 🟡 **MEDIUM**
|
|
82
|
+
|
|
83
|
+
3. **Fixture Difficulty (Next 4 GW):**
|
|
84
|
+
- Avg FDR >3.5 → Poor fixtures exacerbate low xGI
|
|
85
|
+
- Avg FDR <2.5 → Fixtures can't help poor underlying stats
|
|
86
|
+
|
|
87
|
+
4. **Ownership Context:**
|
|
88
|
+
- If template player (>30% ownership): May need to hold for rank protection
|
|
89
|
+
- If differential (<10% ownership): Easy sell, minimal rank impact
|
|
90
|
+
|
|
91
|
+
5. **Transfer Recommendation:**
|
|
92
|
+
- Provide urgency level: 🚨 URGENT / ⚠️ HIGH / 🟡 MEDIUM / 🟢 LOW
|
|
93
|
+
- Suggest xGI-based replacement targets from `fpl_get_top_performers`
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 📈 **Squad Health Summary**
|
|
98
|
+
|
|
99
|
+
1. **Player Counts by Category:**
|
|
100
|
+
- Elite Assets (xGI/90 >0.6): [X] players
|
|
101
|
+
- Strong Contributors (xGI/90 0.35-0.6): [X] players
|
|
102
|
+
- Moderate Assets (xGI/90 0.15-0.35): [X] players
|
|
103
|
+
- Underperformers (xGI/90 <0.15): [X] players
|
|
104
|
+
|
|
105
|
+
2. **Regression Risk Summary:**
|
|
106
|
+
- Players with xGI Delta >+2 (overperforming): [List names] → Potential sell targets
|
|
107
|
+
- Players with xGI Delta <-2 (underperforming): [List names] → Monitor for improvement
|
|
108
|
+
|
|
109
|
+
3. **Priority Transfer Target:**
|
|
110
|
+
- **Player Name** (xGI/90: [X.XX], xGI Delta: [+/-X.X], Fixtures: [avg FDR])
|
|
111
|
+
- **Reason:** [injury / low xGI / rotation / regression risk]
|
|
112
|
+
- **Urgency:** [URGENT/HIGH/MEDIUM/LOW]
|
|
113
|
+
|
|
114
|
+
4. **Overall Squad Health:**
|
|
115
|
+
- Healthy (8+ strong contributors) / Moderate (5-7) / Poor (<5)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🔧 **Tool Calls**
|
|
120
|
+
|
|
121
|
+
Use these tools and resources:
|
|
122
|
+
1. `fpl_get_manager_squad(team_id={team_id})` → Current squad composition
|
|
123
|
+
2. `fpl_get_top_performers(num_gameweeks={num_gameweeks})` → Benchmark against top xGI players
|
|
124
|
+
3. For each player:
|
|
125
|
+
- `fpl://player/{{{{player_name}}}}/summary` → xG, xA, xGI, minutes, fixtures
|
|
126
|
+
4. `fpl://bootstrap/players` → Ownership %, price, transfer trends
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## ⚠️ **Critical Rules**
|
|
131
|
+
|
|
132
|
+
1. **NEVER categorize by PPG alone** → Use xGI/90 for attackers, defensive contribution for defenders
|
|
133
|
+
2. **ALWAYS calculate xGI Delta** → Regression context is critical for sell decisions
|
|
134
|
+
3. **Account for ownership** → Template players need more justification to sell
|
|
135
|
+
4. **Prioritize injured/unavailable** → These are auto-sell regardless of xGI
|
|
136
|
+
"""
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FPL MCP Prompts - Team Fixture Analysis.
|
|
3
|
+
|
|
4
|
+
Prompts guide the LLM in analyzing team fixtures and identifying
|
|
5
|
+
optimal times to invest in or avoid team assets using fixture swing methodology.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ..tools import mcp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@mcp.prompt()
|
|
12
|
+
def analyze_team_fixtures(team_name: str, num_gameweeks: int = 6) -> str:
|
|
13
|
+
"""
|
|
14
|
+
Detect FDR trend shifts to time transfers optimally.
|
|
15
|
+
|
|
16
|
+
Accounts for:
|
|
17
|
+
- Fixture difficulty horizon (4-6 GW)
|
|
18
|
+
- DGW/BGW detection
|
|
19
|
+
- Home/away xG splits
|
|
20
|
+
- "Green arrow" timing (when to invest)
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
team_name: Team to analyze
|
|
24
|
+
num_gameweeks: Fixture horizon (default: 6 for trend detection)
|
|
25
|
+
"""
|
|
26
|
+
return f"""Analyze {team_name}'s fixtures for OPTIMAL TRANSFER TIMING using FIXTURE SWING methodology.
|
|
27
|
+
|
|
28
|
+
**OBJECTIVE: Identify "green arrow" periods (FDR improves) to time {team_name} asset acquisition.**
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 📅 **Fixture Difficulty Assessment (Next {num_gameweeks} GW)**
|
|
33
|
+
|
|
34
|
+
For each upcoming fixture:
|
|
35
|
+
|
|
36
|
+
### **1. Opponent Strength Proxy**
|
|
37
|
+
Instead of static FDR (1-5), use:
|
|
38
|
+
- **Opponent xGC (Expected Goals Conceded) per game** → Higher xGC = weaker defense = favorable for attackers
|
|
39
|
+
- **Opponent xGA (Expected Goals Against) per game** → Lower xGA = weaker attack = favorable for defenders
|
|
40
|
+
|
|
41
|
+
*Note: If xGC/xGA data unavailable, fall back to FDR but note as "proxy only"*
|
|
42
|
+
|
|
43
|
+
### **2. Home/Away Context**
|
|
44
|
+
For each fixture, note:
|
|
45
|
+
- **{team_name} Home/Away**
|
|
46
|
+
- **Historical Home/Away xG**: {team_name}'s average xG at home vs. away
|
|
47
|
+
*(Some teams like Newcastle are ELITE at home, average away)*
|
|
48
|
+
|
|
49
|
+
### **3. Double/Blank Gameweek Detection**
|
|
50
|
+
- **DGW**: If {team_name} plays TWICE in any GW → 🔥 **FLAG FOR CHIP STRATEGY**
|
|
51
|
+
- **BGW**: If {team_name} BLANKS (no fixture) → ⚠️ **AVOID or FREE HIT**
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 📈 **Fixture Swing Analysis (CRITICAL)**
|
|
56
|
+
|
|
57
|
+
Calculate **rolling 3-GW average FDR**:
|
|
58
|
+
|
|
59
|
+
| GW | Opponent | FDR | Rolling 3-GW Avg FDR |
|
|
60
|
+
|----|----------|-----|----------------------|
|
|
61
|
+
| 23 | Liverpool (H) | 4 | 3.7 |
|
|
62
|
+
| 24 | Bournemouth (A) | 2 | 3.3 |
|
|
63
|
+
| 25 | Luton (H) | 1 | 2.3 👈 **SWING DETECTED** |
|
|
64
|
+
| 26 | Fulham (A) | 2 | 1.7 |
|
|
65
|
+
|
|
66
|
+
**SWING LOGIC:**
|
|
67
|
+
- **Green Arrow** 🟢: Rolling avg drops by >1.0 → **OPTIMAL BUY WINDOW**
|
|
68
|
+
→ *"Transfer in {team_name} assets before GW[X] to maximize good fixtures"*
|
|
69
|
+
- **Red Arrow** 🔴: Rolling avg increases by >1.0 → **SELL WINDOW**
|
|
70
|
+
→ *"Avoid {team_name} assets during GW[X]-[Y]"*
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 🎯 **Strategic Recommendations**
|
|
75
|
+
|
|
76
|
+
### **For Attacking Assets (FWD/MID)**
|
|
77
|
+
1. **Best Acquisition Window**: GW[X] (before fixture swing to easy run)
|
|
78
|
+
*Rationale: FDR drops from [avg] to [avg] starting GW[X+1]*
|
|
79
|
+
2. **Captaincy Windows**: GW[Y], GW[Z] (lowest FDR + home fixtures)
|
|
80
|
+
3. **Avoid Period**: GW[A]-[B] (FDR >3.5 avg)
|
|
81
|
+
|
|
82
|
+
### **For Defensive Assets (DEF/GKP)**
|
|
83
|
+
1. **Clean Sheet Windows**: GW[X], GW[Y] (opponent xGA <1.0 + home fixture)
|
|
84
|
+
*Note: Home fixtures ~15% more likely for clean sheets*
|
|
85
|
+
2. **Bench These Weeks**: GW[Z] (facing Man City/Liverpool/Arsenal away)
|
|
86
|
+
|
|
87
|
+
### **DGW/BGW Impact**
|
|
88
|
+
- **If DGW Detected in GW[X]**:
|
|
89
|
+
→ Priority for Bench Boost / Triple Captain
|
|
90
|
+
→ Bring in {team_name} assets on GW[X-1] wildcard
|
|
91
|
+
- **If BGW Detected in GW[Y]**:
|
|
92
|
+
→ Free Hit opportunity OR transfer out before GW[Y]
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 📊 **Overall Fixture Run Classification**
|
|
97
|
+
|
|
98
|
+
- **GREEN (Favorable)**: Avg FDR <2.5 over {num_gameweeks} GW
|
|
99
|
+
→ *"Strong buy window for {team_name} assets"*
|
|
100
|
+
- **AMBER (Moderate)**: Avg FDR 2.5-3.5
|
|
101
|
+
→ *"Selective buy — premium assets only"*
|
|
102
|
+
- **RED (Difficult)**: Avg FDR >3.5
|
|
103
|
+
→ *"Avoid {team_name} assets OR sell before this period"*
|
|
104
|
+
|
|
105
|
+
**Current Classification**: [GREEN/AMBER/RED] (Avg FDR: [X.X])
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🔧 **Tool Calls**
|
|
110
|
+
|
|
111
|
+
Use: `fpl://team/{team_name}/fixtures?num_gameweeks={num_gameweeks}`
|
|
112
|
+
Enrich with: `fpl://bootstrap/teams` for opponent strength proxy (if xGC not available, use team strength rank)
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ⚠️ **Critical Rules**
|
|
117
|
+
|
|
118
|
+
1. **ALWAYS detect fixture swings** → Rolling 3-GW FDR changes >1.0
|
|
119
|
+
2. **FLAG all DGW/BGW** → These override normal fixture logic
|
|
120
|
+
3. **Account for home/away splits** → Especially for defensive assets
|
|
121
|
+
"""
|