Skip to main content
Glama
justfeltlikerunning

Sleeper Fantasy MCP

get_my_matchup

Retrieve current week fantasy football matchup details including scores, players, and projections to analyze your team's performance and make informed lineup decisions.

Instructions

Get your current week matchup details

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 executes the tool logic: fetches current matchup data from Sleeper API for the user's team, including starters, points, and opponent details.
    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();
    
      try {
        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 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]));
        
        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 team: ${leagueConfig.teamName}`);
        }
    
        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 getPlayerInfo = (playerId: string) => {
          const player = players[playerId];
          return player ? {
            name: `${player.first_name} ${player.last_name}`,
            position: player.position,
            team: player.team
          } : { name: 'Unknown Player', position: 'UNK', team: 'UNK' };
        };
    
        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 result = {
          week,
          myTeam: {
            name: leagueConfig.teamName,
            rosterId: myMatchup.roster_id,
            points: myMatchup.points,
            starters: myMatchup.starters.map((playerId, index) => ({
              playerId,
              points: myMatchup.starters_points[index],
              ...getPlayerInfo(playerId)
            }))
          },
          opponent: opponentMatchup ? {
            name: getTeamName(opponentMatchup.roster_id),
            rosterId: opponentMatchup.roster_id,
            points: opponentMatchup.points,
            starters: opponentMatchup.starters.map((playerId, index) => ({
              playerId,
              points: opponentMatchup.starters_points[index],
              ...getPlayerInfo(playerId)
            }))
          } : null,
          matchupId: myMatchup.matchup_id,
          isWinning: opponentMatchup ? myMatchup.points > opponentMatchup.points : null
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get matchup: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema defining optional league and week parameters for the tool.
    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:74-75 (registration)
    Registration in the tool dispatch switch statement, mapping 'get_my_matchup' calls to the MatchupTool's execute method.
    case "get_my_matchup":
      return await matchupTool.execute(args);
  • src/index.ts:48-63 (registration)
    Registers the MatchupTool instance in the list of available tools served to MCP clients.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        leagueTool,
        rosterTool,
        matchupTool,
        playerTool,
        projectionsTool,
        matchupProjectionsTool,
        lineupOptimizerTool,
        trendingTool,
        historicalScoresTool,
        playerNewsTool,
        transactionsTool,
        stateScheduleTool,
      ],
    }));
  • Utility method to compute the current week number based on the NFL season start date.
    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 the full burden of behavioral disclosure. It states the tool retrieves 'matchup details' but doesn't explain what those details include (e.g., scores, teams, status), whether it requires authentication, if it's read-only (implied by 'get'), or any rate limits. For a tool with no annotations, this is a significant gap in transparency.

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 front-loads the core purpose ('Get your current week matchup details') with zero wasted words. It's appropriately sized for a simple retrieval tool, making it easy for an agent to parse quickly.

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 and no output schema, the description is incomplete for a tool that likely returns complex matchup data. It doesn't specify what 'matchup details' include (e.g., scores, players, status), how data is structured, or any behavioral traits like authentication needs. For a retrieval tool with potential complexity, this leaves significant gaps for an agent.

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 both parameters (league and week) with descriptions, enums, and constraints. The description adds no additional parameter information beyond what's in the schema, such as explaining how 'current week' is determined or the implications of league choice. Baseline 3 is appropriate when the schema does the heavy lifting.

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 as 'Get your current week matchup details', which specifies the action (get), resource (matchup details), and scope (current week, your matchup). It distinguishes from siblings like get_historical_scores (past data) and get_my_roster (roster vs. matchup), though not explicitly. A 5 would require explicit sibling 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. It doesn't mention siblings like get_matchup_projections (for future estimates) or get_historical_scores (for past data), nor does it specify prerequisites or context for usage. This leaves the agent to infer usage from the name and description alone.

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