get_league_info
Retrieve league settings and configuration details for Sleeper Fantasy Football leagues to support team management and strategic decision-making.
Instructions
Get league information and settings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| league | No | League name (ROAD_TO_GLORY or DYNASTY), defaults to configured default |
Implementation Reference
- src/tools/LeagueTool.ts:18-69 (handler)The main handler function that fetches league settings and user list from the Sleeper API using the specified league configuration.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)}`); } }
- src/tools/LeagueTool.ts:7-16 (schema)Input schema defining the optional 'league' parameter for selecting the league (ROAD_TO_GLORY or DYNASTY).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:49-62 (registration)Registers the LeagueTool instance in the list of tools returned by the ListToolsRequest handler.tools: [ leagueTool, rosterTool, matchupTool, playerTool, projectionsTool, matchupProjectionsTool, lineupOptimizerTool, trendingTool, historicalScoresTool, playerNewsTool, transactionsTool, stateScheduleTool, ],
- src/index.ts:70-71 (registration)Routes calls to 'get_league_info' to the LeagueTool's execute method in the CallToolRequest handler.case "get_league_info": return await leagueTool.execute(args);