get_goalie_stats
Retrieve NHL goalie statistics including save percentage, goals against average, wins, and shutouts for specified seasons.
Instructions
Get statistics for NHL goalies including save percentage, GAA, wins, shutouts, and other goalie-specific metrics.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of goalies to return (defaults to 20) | |
| season | No | Season in format YYYYYYYY (e.g., 20242025), defaults to current season |
Implementation Reference
- src/index.ts:540-549 (handler)Handler for get_goalie_stats tool that fetches top goalie stats via NHLAPIClient and formats them for output.case 'get_goalie_stats': { const goalies = await client.getTopGoalies( parameters.limit as number | undefined, parameters.season as string | undefined ); const formatted = formatGoalieStats(goalies, 'savePctg'); return { content: [{ type: 'text', text: formatted }], }; }
- src/index.ts:109-125 (registration)Registration of the get_goalie_stats tool in the TOOLS array, including name, description, and input schema.{ name: 'get_goalie_stats', description: 'Get statistics for NHL goalies including save percentage, GAA, wins, shutouts, and other goalie-specific metrics.', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Number of goalies to return (defaults to 20)', }, season: { type: 'string', description: 'Season in format YYYYYYYY (e.g., 20242025), defaults to current season', }, }, }, },
- src/nhl-api.ts:84-101 (schema)TypeScript interface defining the structure of GoalieStats returned by the tool.export interface GoalieStats { id: number; firstName: { default: string; }; lastName: { default: string; }; sweaterNumber: number; headshot: string; teamAbbrev: string; teamName: { default: string; }; teamLogo: string; position: string; value: number; // The stat value (savePctg, wins, etc.) }
- src/nhl-api.ts:198-215 (helper)Helper method in NHLAPIClient that fetches top goalie statistics from the NHL API endpoints.async getTopGoalies(limit: number = 20, season?: string): Promise<GoalieStats[]> { const seasonStr = season || this.getCurrentSeason(); const category = 'savePctg'; // Default to save percentage if (!season) { // Use current stats leaders endpoint const data = await this.fetchJSON( `${NHL_API_BASE}/goalie-stats-leaders/current?categories=${category}&limit=${limit}` ); return data[category] || []; } else { // Use seasonal stats leaders endpoint const data = await this.fetchJSON( `${NHL_API_BASE}/goalie-stats-leaders/${seasonStr}/2?categories=${category}&limit=${limit}` ); return data[category] || []; } }
- src/index.ts:269-286 (helper)Utility function to format goalie statistics into a readable markdown table.function formatGoalieStats(goalies: GoalieStats[], category: string): string { let result = `Rank | Goalie | Team | ${category.toUpperCase()}\n`; result += '-'.repeat(60) + '\n'; goalies.forEach((goalie, index) => { const name = `${goalie.firstName.default} ${goalie.lastName.default}`; const displayName = name.substring(0, 25).padEnd(25); const team = goalie.teamAbbrev.padEnd(4); const value = category === 'savePctg' ? goalie.value.toFixed(3) : goalie.value.toString(); const rank = (index + 1).toString().padStart(3); result += `${rank} | ${displayName} | ${team} | ${value}\n`; }); return result; }