Skip to main content
Glama

get_player_projections

Retrieve projected fantasy football points for players this week to optimize lineup decisions and roster management.

Instructions

Get projected points for players this week

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leagueNoLeague name (ROAD_TO_GLORY or DYNASTY), defaults to configured default
weekNoWeek number (defaults to current week)
playersNoArray of player IDs to get projections for (optional - gets your roster if not provided)
positionNoFilter by position (QB, RB, WR, TE, K, DEF)

Implementation Reference

  • Main handler function that implements the get_player_projections tool logic. Fetches player IDs from roster if not provided, retrieves player master list, fetches projections from Sleeper API for the specified week/season, matches to players, applies filters, calculates/formats PPR projections, sorts by projected points, and returns JSON summary.
    async execute(args: any) { const leagueConfig = getLeagueConfig(args.league); if (!leagueConfig) { throw new Error(`League configuration not found for: ${args.league}`); } const week = args.week || this.getCurrentWeek(); const season = new Date().getFullYear().toString(); try { let playerIds = args.players; // If no specific players requested, get user's roster if (!playerIds) { const [rostersResponse, usersResponse] = await Promise.all([ fetch(`${config.api.baseUrl}/league/${leagueConfig.id}/rosters`), fetch(`${config.api.baseUrl}/league/${leagueConfig.id}/users`) ]); if (!rostersResponse.ok || !usersResponse.ok) { throw new Error('Failed to fetch roster data'); } const rosters = await rostersResponse.json(); const users = await usersResponse.json(); const userMap = new Map(users.map((user: any) => [user.user_id, user])); const myRoster = rosters.find((roster: any) => { const user: any = userMap.get(roster.owner_id); return user?.display_name === config.username || user?.username === config.username || user?.display_name === leagueConfig.teamName || user?.username === leagueConfig.teamName; }); if (myRoster) { playerIds = myRoster.players; } } if (!playerIds || playerIds.length === 0) { throw new Error('No players found to get projections for'); } // Fetch player data const playersResponse = await fetch(`${config.api.baseUrl}/players/nfl`); if (!playersResponse.ok) { throw new Error('Failed to fetch player data'); } const players = await playersResponse.json(); // Use bulk projections endpoint for better performance let allProjections: any[] = []; if (args.position) { // Fetch for specific position only const url = `https://api.sleeper.app/projections/nfl/${season}/${week}?season_type=regular&position[]=${args.position}`; const response = await fetch(url); if (response.ok) { allProjections = await response.json(); } } else { // Fetch for all fantasy positions const positions = ['QB', 'RB', 'WR', 'TE', 'K', 'DEF']; const projectionPromises = positions.map(pos => fetch(`https://api.sleeper.app/projections/nfl/${season}/${week}?season_type=regular&position[]=${pos}`) .then(res => res.ok ? res.json() : []) .catch(() => []) ); const positionProjections = await Promise.all(projectionPromises); allProjections = positionProjections.flat(); } // Create a map for quick lookup const projectionMap = new Map( allProjections.map(proj => [proj.player_id, proj]) ); // Filter and format player projections const playerProjections = []; for (const playerId of playerIds) { const projectionData = projectionMap.get(playerId); const player = players[playerId]; if (!player) continue; // Apply position filter if specified if (args.position && player.position !== args.position) { continue; } const projectionStats = projectionData?.stats || {}; const projectedPoints = projectionStats.pts_ppr || 0; playerProjections.push({ playerId, name: `${player.first_name} ${player.last_name}`, position: player.position, team: player.team, status: player.status, projectedPoints: Number(projectedPoints.toFixed(2)), detailedProjections: { passingYards: projectionStats.pass_yd || 0, passingTDs: projectionStats.pass_td || 0, rushingYards: projectionStats.rush_yd || 0, rushingTDs: projectionStats.rush_td || 0, receivingYards: projectionStats.rec_yd || 0, receivingTDs: projectionStats.rec_td || 0, receptions: projectionStats.rec || 0, fieldGoals: projectionStats.fgm || 0, extraPoints: projectionStats.xpm || 0, pprPoints: projectionStats.pts_ppr || 0, halfPprPoints: projectionStats.pts_half_ppr || 0, standardPoints: projectionStats.pts_std || 0 } }); } playerProjections.sort((a: any, b: any) => b.projectedPoints - a.projectedPoints); const result = { week, season, league: args.league || config.defaultLeague, totalPlayers: playerProjections.length, projections: playerProjections, summary: { totalProjectedPoints: playerProjections.reduce((sum: number, p: any) => sum + p.projectedPoints, 0), averageProjection: playerProjections.length > 0 ? (playerProjections.reduce((sum: number, p: any) => sum + p.projectedPoints, 0) / playerProjections.length).toFixed(1) : 0, topProjectedPlayer: playerProjections[0] || null } }; return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { throw new Error(`Failed to get projections: ${error instanceof Error ? error.message : String(error)}`); } }
  • Input schema defining the parameters for the get_player_projections tool: league, week, optional players array, optional position filter.
    inputSchema = { type: "object", properties: { league: { type: "string", description: "League name (ROAD_TO_GLORY or DYNASTY), defaults to configured default", enum: ["ROAD_TO_GLORY", "DYNASTY"] }, week: { type: "number", description: "Week number (defaults to current week)", minimum: 1, maximum: 18 }, players: { type: "array", description: "Array of player IDs to get projections for (optional - gets your roster if not provided)", items: { type: "string" } }, position: { type: "string", description: "Filter by position (QB, RB, WR, TE, K, DEF)", enum: ["QB", "RB", "WR", "TE", "K", "DEF"] } } };
  • src/index.ts:78-79 (registration)
    Registration in the tool call handler switch statement: dispatches 'get_player_projections' calls to projectionsTool.execute()
    case "get_player_projections": return await projectionsTool.execute(args);
  • src/index.ts:49-62 (registration)
    Tool registration in the ListToolsRequest handler: includes projectionsTool in the list of available tools.
    tools: [ leagueTool, rosterTool, matchupTool, playerTool, projectionsTool, matchupProjectionsTool, lineupOptimizerTool, trendingTool, historicalScoresTool, playerNewsTool, transactionsTool, stateScheduleTool, ],
  • Helper method to determine the current NFL week based on date since season start.
    private getCurrentWeek(): number { const now = new Date(); const seasonStart = new Date('2024-09-05'); const weeksSinceStart = Math.floor((now.getTime() - seasonStart.getTime()) / (7 * 24 * 60 * 60 * 1000)); return Math.max(1, Math.min(18, weeksSinceStart + 1)); }

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/justfeltlikerunning/sleeper-fantasy-mcp'

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