compare_seasons
Analyze NHL team or player statistics across different seasons to identify trends and performance changes.
Instructions
Compare team or player statistics across multiple NHL seasons.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| teamAbbrev | No | Team abbreviation to compare (optional) | |
| seasons | Yes | Array of seasons to compare in format YYYYYYYY (e.g., ["20232024", "20242025"]) |
Implementation Reference
- src/index.ts:192-212 (registration)Tool registration in the TOOLS array, including name, description, and input schema.{ name: 'compare_seasons', description: 'Compare team or player statistics across multiple NHL seasons.', inputSchema: { type: 'object', properties: { teamAbbrev: { type: 'string', description: 'Team abbreviation to compare (optional)', }, seasons: { type: 'array', items: { type: 'string', }, description: 'Array of seasons to compare in format YYYYYYYY (e.g., ["20232024", "20242025"])', }, }, required: ['seasons'], }, },
- src/index.ts:393-444 (handler)The handler function that executes the compare_seasons tool, fetching and comparing standings data across specified seasons for a team or league-wide.async function compareSeasons(seasons: string[], teamAbbrev?: string): Promise<string> { try { if (!teamAbbrev) { // Compare league-wide stats const results: string[] = []; for (const season of seasons) { const standings = await client.getStandingsBySeason(season); const teams = standings.standings || []; const totalGoals = teams.reduce((sum, t) => sum + t.goalFor, 0); const totalGames = teams.reduce((sum, t) => sum + t.gamesPlayed, 0); results.push( `Season ${client.formatSeason(season)}:\n` + ` Total teams: ${teams.length}\n` + ` Total goals: ${totalGoals}\n` + ` Avg goals/game: ${(totalGoals / totalGames).toFixed(2)}` ); } return `Season Comparison:\n\n${results.join('\n\n')}`; } else { // Compare specific team across seasons const results: string[] = []; for (const season of seasons) { const standings = await client.getStandingsBySeason(season); const team = (standings.standings || []).find( (t) => t.teamAbbrev.default === teamAbbrev ); if (team) { results.push( `${client.formatSeason(season)} - ${teamAbbrev}:\n` + ` Record: ${team.wins}-${team.losses}-${team.otLosses}\n` + ` Points: ${team.points}\n` + ` Goals For: ${team.goalFor}\n` + ` Goals Against: ${team.goalAgainst}\n` + ` Goal Diff: ${team.goalDifferential}` ); } else { results.push(`${client.formatSeason(season)} - ${teamAbbrev}: No data found`); } } return `Season Comparison for ${teamAbbrev}:\n\n${results.join('\n\n')}`; } } catch (error: any) { return `Error comparing seasons: ${error.message}`; } }
- src/index.ts:593-601 (registration)Registration in the switch statement of the CallToolRequestSchema handler, dispatching to the compareSeasons function.case 'compare_seasons': { const comparison = await compareSeasons( parameters.seasons as string[], parameters.teamAbbrev as string | undefined ); return { content: [{ type: 'text', text: comparison }], }; }