Skip to main content
Glama
justfeltlikerunning

Sleeper Fantasy MCP

get_available_players

Find free agent players in your Sleeper fantasy football league with filtering by position, team, and projections, plus sorting options to optimize roster decisions.

Instructions

Get available players (free agents) for your league with enhanced filtering and sorting

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leagueNoLeague name (ROAD_TO_GLORY or DYNASTY), defaults to configured default
positionNoFilter by position (QB, RB, WR, TE, K, DEF)
limitNoMaximum number of players to return (default: 20)
sortByNoSort players by criteria (projections, trending, ownership, alphabetical)projections
weekNoWeek number for projections (defaults to current week)
minProjectionNoMinimum projected points filter
teamNoFilter by NFL team (e.g., 'PHI', 'SF')

Implementation Reference

  • Core handler function that implements the get_available_players tool logic: processes input args, fetches league rosters, NFL players, trending data, identifies free agents, fetches and filters by projections, sorts by specified criteria, computes summaries, and formats response.
    async execute(args: any) {
      const leagueConfig = getLeagueConfig(args.league);
      
      if (!leagueConfig) {
        throw new Error(`League configuration not found for: ${args.league}`);
      }
    
      const limit = args.limit || 20;
      const position = args.position;
      const sortBy = args.sortBy || 'projections';
      const week = args.week || this.getCurrentWeek();
      const minProjection = args.minProjection || 0;
      const team = args.team;
      const season = new Date().getFullYear().toString();
    
      try {
        const fetchPromises = [
          fetch(`${config.api.baseUrl}/league/${leagueConfig.id}/rosters`),
          fetch(`${config.api.baseUrl}/players/nfl`),
          fetch(`${config.api.baseUrl}/players/nfl/trending/add?lookback_hours=24&limit=100`),
          fetch(`${config.api.baseUrl}/players/nfl/trending/drop?lookback_hours=24&limit=50`)
        ];
    
        const responses = await Promise.all(fetchPromises);
        
        if (responses.some(r => !r.ok)) {
          throw new Error('Failed to fetch player data');
        }
    
        const rosters: SleeperRoster[] = await responses[0].json();
        const players = await responses[1].json();
        const trendingAdd = await responses[2].json();
        const trendingDrop = await responses[3].json();
    
        const ownedPlayerIds = new Set(
          rosters.flatMap(roster => roster.players || [])
        );
    
        // Filter players first
        const filteredPlayers = Object.entries(players)
          .filter(([playerId, player]: [string, any]) => {
            if (ownedPlayerIds.has(playerId)) return false;
            if (!player.position || player.position === 'UNK') return false;
            if (player.status === 'Inactive' || player.status === 'PUP') return false;
            if (position && player.position !== position) return false;
            if (team && player.team !== team) return false;
            return true;
          })
          .slice(0, Math.min(limit * 2, 100)); // Limit pre-projection fetching
    
        // Fetch projections only if needed and only for filtered players
        const playerProjections: Record<string, any> = {};
        if (sortBy === 'projections' || minProjection > 0) {
          const projectionPromises = filteredPlayers.map(async ([playerId]) => {
            try {
              const projectionResponse = await fetch(
                `https://api.sleeper.app/projections/nfl/player/${playerId}?season=${season}&season_type=regular&week=${week}`
              );
              if (projectionResponse.ok) {
                const data = await projectionResponse.json();
                playerProjections[playerId] = data.stats?.pts_ppr || 0;
              }
            } catch (error) {
              // Ignore projection fetch errors
            }
          });
          
          await Promise.all(projectionPromises);
        }
    
        const availablePlayers = filteredPlayers
          .map(([playerId, player]: [string, any]) => {
            const isTrendingAdd = trendingAdd.some((trend: any) => trend.player_id === playerId);
            const isTrendingDrop = trendingDrop.some((trend: any) => trend.player_id === playerId);
            const projectedPoints = playerProjections[playerId] || 0;
            
            // Apply minimum projection filter
            if (minProjection > 0 && projectedPoints < minProjection) return null;
            
            return {
              playerId,
              name: `${player.first_name} ${player.last_name}`,
              position: player.position,
              team: player.team,
              age: player.age,
              status: player.status,
              fantasyPositions: player.fantasy_positions,
              isTrendingAdd,
              isTrendingDrop,
              projectedPoints: Number(projectedPoints.toFixed(1)),
              trend: isTrendingAdd ? 'Adding' : isTrendingDrop ? 'Dropping' : 'Stable'
            };
          })
          .filter(Boolean)
          .sort((a: any, b: any) => {
            switch (sortBy) {
              case 'projections':
                return parseFloat(b.projectedPoints) - parseFloat(a.projectedPoints);
              case 'trending':
                if (a.isTrendingAdd && !b.isTrendingAdd) return -1;
                if (!a.isTrendingAdd && b.isTrendingAdd) return 1;
                return parseFloat(b.projectedPoints) - parseFloat(a.projectedPoints);
              case 'alphabetical':
                return a.name.localeCompare(b.name);
              case 'ownership':
                // For now, use trending as proxy for ownership changes
                if (a.isTrendingAdd && !b.isTrendingAdd) return -1;
                if (!a.isTrendingAdd && b.isTrendingAdd) return 1;
                return a.name.localeCompare(b.name);
              default:
                return parseFloat(b.projectedPoints) - parseFloat(a.projectedPoints);
            }
          })
          .slice(0, limit);
    
        const result = {
          league: args.league || config.defaultLeague,
          week,
          filters: {
            position: position || 'ALL',
            team: team || 'ALL',
            minProjection: minProjection,
            sortBy: sortBy
          },
          totalAvailable: availablePlayers.length,
          players: availablePlayers,
          summary: {
            byPosition: this.getPositionSummary(availablePlayers),
            trending: {
              adding: availablePlayers.filter((p: any) => p?.isTrendingAdd).length,
              dropping: availablePlayers.filter((p: any) => p?.isTrendingDrop).length
            },
            avgProjection: availablePlayers.length > 0 ? 
              (availablePlayers.reduce((sum, p: any) => sum + parseFloat(p.projectedPoints), 0) / availablePlayers.length).toFixed(1) : 0
          }
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get available players: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Defines the input schema for the tool, including parameters for league, position filter, limit, sorting, week, minimum projection, and team.
    inputSchema = {
      type: "object",
      properties: {
        league: {
          type: "string",
          description: "League name (ROAD_TO_GLORY or DYNASTY), defaults to configured default",
          enum: ["ROAD_TO_GLORY", "DYNASTY"]
        },
        position: {
          type: "string",
          description: "Filter by position (QB, RB, WR, TE, K, DEF)",
          enum: ["QB", "RB", "WR", "TE", "K", "DEF"]
        },
        limit: {
          type: "number",
          description: "Maximum number of players to return (default: 20)",
          minimum: 1,
          maximum: 100,
          default: 20
        },
        sortBy: {
          type: "string",
          description: "Sort players by criteria (projections, trending, ownership, alphabetical)",
          enum: ["projections", "trending", "ownership", "alphabetical"],
          default: "projections"
        },
        week: {
          type: "number",
          description: "Week number for projections (defaults to current week)",
          minimum: 1,
          maximum: 18
        },
        minProjection: {
          type: "number",
          description: "Minimum projected points filter",
          minimum: 0
        },
        team: {
          type: "string",
          description: "Filter by NFL team (e.g., 'PHI', 'SF')"
        }
      }
    };
  • src/index.ts:76-77 (registration)
    In the CallToolRequest handler switch statement, routes calls to 'get_available_players' to the playerTool's execute method.
    case "get_available_players":
      return await playerTool.execute(args);
  • src/index.ts:50-62 (registration)
    Registers the playerTool instance in the array of tools returned by the ListToolsRequest handler.
      leagueTool,
      rosterTool,
      matchupTool,
      playerTool,
      projectionsTool,
      matchupProjectionsTool,
      lineupOptimizerTool,
      trendingTool,
      historicalScoresTool,
      playerNewsTool,
      transactionsTool,
      stateScheduleTool,
    ],
  • src/index.ts:26-26 (registration)
    Instantiates the PlayerTool class for use in tool registration and dispatching.
    const playerTool = new PlayerTool();
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 'enhanced filtering and sorting' but doesn't disclose key behavioral traits: whether this is a read-only operation, if it requires authentication, rate limits, pagination, or what the return format looks like (e.g., list of players with stats). For a tool with 7 parameters and no annotations, this is inadequate.

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

Conciseness4/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. It avoids redundancy but could be slightly more structured (e.g., separating purpose from capabilities). Every word earns its place, making it appropriately concise for the tool's complexity.

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 7 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what data is returned (e.g., player attributes, projections), behavioral constraints, or error handling. For a filtering/sorting tool with rich parameters, more context is needed to guide effective use.

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 7 parameters with descriptions, enums, defaults, and constraints. The description adds no additional parameter semantics beyond implying filtering/sorting capabilities, which are already covered in the schema. Baseline 3 is appropriate when schema does all the work.

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 verb ('Get') and resource ('available players/free agents'), specifying the domain ('for your league'). It distinguishes itself from siblings like 'get_my_roster' or 'get_player_projections' by focusing on free agents with filtering/sorting, though it doesn't explicitly name alternatives. The purpose is specific but could be more differentiated.

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

Usage Guidelines3/5

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

The description implies usage when needing free agents with enhanced filtering/sorting, but provides no explicit guidance on when to use this tool versus alternatives like 'get_trending_players' or 'get_player_projections'. It mentions the context ('for your league') but lacks exclusions or clear comparisons with sibling 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