Skip to main content
Glama
justfeltlikerunning

Sleeper Fantasy MCP

get_league_info

Retrieve league settings and information from Sleeper Fantasy Football for ROAD_TO_GLORY or DYNASTY leagues to support fantasy football management decisions.

Instructions

Get league information and settings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leagueNoLeague name (ROAD_TO_GLORY or DYNASTY), defaults to configured default

Implementation Reference

  • The main handler function that fetches league settings and user list from Sleeper API using the provided league config, processes the data, and returns a formatted JSON response.
    async execute(args: any) {
      const leagueConfig = getLeagueConfig(args.league);
      
      if (!leagueConfig) {
        throw new Error(`League configuration not found for: ${args.league}`);
      }
    
      try {
        const [leagueResponse, usersResponse] = await Promise.all([
          fetch(`${config.api.baseUrl}/league/${leagueConfig.id}`),
          fetch(`${config.api.baseUrl}/league/${leagueConfig.id}/users`)
        ]);
    
        if (!leagueResponse.ok || !usersResponse.ok) {
          throw new Error('Failed to fetch league data');
        }
    
        const league: SleeperLeague = await leagueResponse.json();
        const users: SleeperUser[] = await usersResponse.json();
    
        const result = {
          league: {
            name: league.name,
            season: league.season,
            sport: league.sport,
            status: league.status,
            totalRosters: league.total_rosters,
            playoffWeekStart: league.settings.playoff_week_start,
            playoffTeams: league.settings.playoff_teams,
            waiverBudget: league.settings.waiver_budget
          },
          users: users.map(user => ({
            userId: user.user_id,
            username: user.username,
            displayName: user.display_name
          })),
          yourTeam: leagueConfig.teamName,
          leagueId: leagueConfig.id
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get league info: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Tool metadata including name, description, and input schema defining optional 'league' parameter.
    name = "get_league_info";
    description = "Get league information and settings";
    inputSchema = {
      type: "object",
      properties: {
        league: {
          type: "string",
          description: "League name (ROAD_TO_GLORY or DYNASTY), defaults to configured default",
          enum: ["ROAD_TO_GLORY", "DYNASTY"]
        }
      }
    };
  • src/index.ts:70-71 (registration)
    Registers the tool handler by dispatching 'get_league_info' calls to the LeagueTool's execute method in the MCP CallToolRequest handler.
    case "get_league_info":
      return await leagueTool.execute(args);
  • src/index.ts:49-62 (registration)
    Registers the LeagueTool instance (leagueTool) in the list of available tools returned by the MCP ListToolsRequest handler.
    tools: [
      leagueTool,
      rosterTool,
      matchupTool,
      playerTool,
      projectionsTool,
      matchupProjectionsTool,
      lineupOptimizerTool,
      trendingTool,
      historicalScoresTool,
      playerNewsTool,
      transactionsTool,
      stateScheduleTool,
    ],

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