Skip to main content
Glama
justfeltlikerunning

Sleeper Fantasy MCP

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));
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'projected points' but doesn't disclose behavioral traits like what data source provides projections, whether projections are real-time or cached, if there are rate limits, authentication requirements, or what happens when parameters are omitted. The description is minimal and lacks operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for a straightforward data retrieval tool. Every word contributes to understanding what the tool does.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 4 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what 'projected points' means in this context, how results are structured, or any prerequisites. The lack of behavioral transparency and output information leaves significant gaps for an AI agent to use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 4 parameters. The description adds no parameter-specific information beyond implying a temporal context ('this week') that loosely relates to the 'week' parameter. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get projected points for players this week' - a specific verb ('Get') and resource ('projected points for players') with temporal scope ('this week'). However, it doesn't distinguish this from sibling tools like 'get_matchup_projections' or 'get_historical_scores', which might also involve projections or player data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'get_matchup_projections' and 'get_historical_scores' available, there's no indication of how this tool differs or when it's preferred. The temporal scope 'this week' is mentioned but not contrasted with other timeframes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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