Skip to main content
Glama
justfeltlikerunning

Sleeper Fantasy MCP

get_matchup_projections

Compare projected scores for your current fantasy football matchup to analyze performance expectations and make informed lineup decisions.

Instructions

Compare projected scores for your current matchup

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leagueNoLeague name (ROAD_TO_GLORY or DYNASTY), defaults to configured default
weekNoWeek number (defaults to current week)

Implementation Reference

  • The main handler function that orchestrates fetching of matchup, roster, user, player data from Sleeper API, retrieves individual player projections, calculates projected totals for user's and opponent's starting lineups, and returns a structured result with analysis including projected difference and winner confidence.
    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 {
        // Fetch matchup data
        const [matchupsResponse, rostersResponse, usersResponse, playersResponse] = await Promise.all([
          fetch(`${config.api.baseUrl}/league/${leagueConfig.id}/matchups/${week}`),
          fetch(`${config.api.baseUrl}/league/${leagueConfig.id}/rosters`),
          fetch(`${config.api.baseUrl}/league/${leagueConfig.id}/users`),
          fetch(`${config.api.baseUrl}/players/nfl`)
        ]);
    
        if (!matchupsResponse.ok || !rostersResponse.ok || !usersResponse.ok || !playersResponse.ok) {
          throw new Error('Failed to fetch matchup projection data');
        }
    
        const matchups: SleeperMatchup[] = await matchupsResponse.json();
        const rosters: SleeperRoster[] = await rostersResponse.json();
        const users: SleeperUser[] = await usersResponse.json();
        const players = await playersResponse.json();
    
        const userMap = new Map(users.map(user => [user.user_id, user]));
        const rosterMap = new Map(rosters.map(roster => [roster.roster_id, roster]));
    
        // Find user's roster and matchup
        const myRoster = rosters.find(roster => {
          const user = 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) {
          throw new Error(`Could not find roster for user: ${config.username}`);
        }
    
        const myMatchup = matchups.find(m => m.roster_id === myRoster.roster_id);
        if (!myMatchup) {
          throw new Error(`No matchup found for week ${week}`);
        }
    
        const opponentMatchup = matchups.find(m => 
          m.matchup_id === myMatchup.matchup_id && m.roster_id !== myRoster.roster_id
        );
    
        const getTeamProjections = async (roster: SleeperRoster, starters: string[]) => {
          // Fetch individual projections for each starter
          const projectionPromises = starters.map(async (playerId: string) => {
            try {
              const projectionResponse = await fetch(
                `https://api.sleeper.app/projections/nfl/player/${playerId}?season=${season}&season_type=regular&week=${week}`
              );
              if (projectionResponse.ok) {
                return await projectionResponse.json();
              }
              return null;
            } catch (error) {
              console.warn(`Failed to fetch projection for player ${playerId}:`, error);
              return null;
            }
          });
    
          const projectionResults = await Promise.all(projectionPromises);
    
          const projectedStarters = starters.map((playerId, index) => {
            const player = players[playerId];
            const projectionData = projectionResults[index];
            
            if (!player) return null;
            
            const projectionStats = projectionData?.stats || {};
            const projectedPoints = projectionStats.pts_ppr || 0;
    
            return {
              playerId,
              name: `${player.first_name} ${player.last_name}`,
              position: player.position,
              team: player.team,
              projectedPoints: Number(projectedPoints.toFixed(1))
            };
          }).filter(Boolean);
    
          const totalProjected = projectedStarters.reduce((sum, p: any) => sum + p.projectedPoints, 0);
          
          return {
            starters: projectedStarters,
            totalProjected: totalProjected.toFixed(1)
          };
        };
    
        const getTeamName = (rosterId: number) => {
          const roster = rosterMap.get(rosterId);
          if (roster) {
            const user = userMap.get(roster.owner_id);
            return user?.display_name || user?.username || 'Unknown Team';
          }
          return 'Unknown Team';
        };
    
        const myProjections = await getTeamProjections(myRoster, myMatchup.starters);
        const opponentProjections = opponentMatchup ? 
          await getTeamProjections(rosterMap.get(opponentMatchup.roster_id)!, opponentMatchup.starters) : null;
    
        const result = {
          week,
          season,
          league: args.league || config.defaultLeague,
          matchupId: myMatchup.matchup_id,
          
          myTeam: {
            name: leagueConfig.teamName,
            rosterId: myMatchup.roster_id,
            actualPoints: myMatchup.points,
            projectedPoints: myProjections.totalProjected,
            starters: myProjections.starters
          },
          
          opponent: opponentMatchup && opponentProjections ? {
            name: getTeamName(opponentMatchup.roster_id),
            rosterId: opponentMatchup.roster_id,
            actualPoints: opponentMatchup.points,
            projectedPoints: opponentProjections.totalProjected,
            starters: opponentProjections.starters
          } : null,
    
          analysis: opponentProjections ? {
            projectedDifference: (parseFloat(myProjections.totalProjected) - parseFloat(opponentProjections.totalProjected)).toFixed(1),
            projectedWinner: parseFloat(myProjections.totalProjected) > parseFloat(opponentProjections.totalProjected) ? 
              leagueConfig.teamName : getTeamName(opponentMatchup!.roster_id),
            confidence: Math.abs(parseFloat(myProjections.totalProjected) - parseFloat(opponentProjections.totalProjected)) > 10 ? 
              'High' : Math.abs(parseFloat(myProjections.totalProjected) - parseFloat(opponentProjections.totalProjected)) > 5 ? 
              'Medium' : 'Low'
          } : null
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get matchup projections: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Tool metadata including name, description, and input schema defining optional league and week parameters.
    export class MatchupProjectionsTool {
      name = "get_matchup_projections";
      description = "Compare projected scores for your current matchup";
      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
          }
        }
      };
  • src/index.ts:80-81 (registration)
    Registration in the main tool dispatcher switch statement that calls the tool's execute method when invoked.
    case "get_matchup_projections":
      return await matchupProjectionsTool.execute(args);
  • src/index.ts:55-55 (registration)
    The tool instance is registered by being included in the array returned for ListToolsRequest.
    matchupProjectionsTool,
  • Helper method to determine the current NFL week based on date relative to 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 for behavioral disclosure. While 'compare projected scores' implies a read-only operation, it doesn't specify what data is compared (teams? players?), the format of comparison, whether authentication is needed, or any rate limits. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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 that gets straight to the point with no wasted words. It's appropriately sized for the tool's apparent complexity and is perfectly front-loaded with the core functionality.

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?

Given no annotations, no output schema, and a description that only states the basic purpose, this is incomplete for a tool that presumably returns matchup comparison data. The description doesn't explain what 'compare' means operationally, what format the comparison takes, or what information users can expect to receive from this tool.

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%, with both parameters well-documented in the schema. The description adds no parameter-specific information beyond what's already in the schema. The baseline score of 3 is appropriate when the schema does the heavy lifting for parameter documentation.

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: 'Compare projected scores for your current matchup' - this specifies the action (compare), resource (projected scores), and scope (current matchup). It doesn't explicitly distinguish from siblings like 'get_my_matchup' or 'get_player_projections', but the focus on comparison and current matchup provides reasonable differentiation.

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 siblings like 'get_my_matchup', 'get_player_projections', and 'optimize_lineup' available, there's no indication of when this comparison tool is preferred over those other matchup or projection-related tools.

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