get_live_games
Retrieve live NHL game scores, period status, and venue details for today or a specified date to track ongoing hockey matches.
Instructions
Get live NHL game scores and status for today or a specific date. Shows current scores, period, game state, and venue information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Date in YYYY-MM-DD format (optional, defaults to today) |
Implementation Reference
- src/index.ts:472-485 (handler)MCP tool handler for 'get_live_games' that fetches games via NHLAPIClient.getTodaysScores, handles empty case, formats output using formatGameScore, and returns as MCP content.case 'get_live_games': { const games = await client.getTodaysScores(parameters.date as string | undefined); if (games.length === 0) { return { content: [ { type: 'text', text: 'No games scheduled for this date' }, ], }; } const formatted = games.map(formatGameScore).join('\n\n'); return { content: [{ type: 'text', text: formatted }], }; }
- src/index.ts:22-34 (schema)Tool schema definition in the TOOLS array, including name, description, and inputSchema for date parameter.{ name: 'get_live_games', description: 'Get live NHL game scores and status for today or a specific date. Shows current scores, period, game state, and venue information.', inputSchema: { type: 'object', properties: { date: { type: 'string', description: 'Date in YYYY-MM-DD format (optional, defaults to today)', }, }, }, },
- src/index.ts:460-462 (registration)Registration of the tool list handler that returns the TOOLS array containing 'get_live_games'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS }; });
- src/nhl-api.ts:115-119 (helper)Core implementation in NHLAPIClient that fetches live game scores from NHL API for a given date.async getTodaysScores(date?: string): Promise<GameScore[]> { const dateStr = date || new Date().toISOString().split('T')[0]; const data = await this.fetchJSON(`${NHL_API_BASE}/score/${dateStr}`); return data.games || []; }
- src/index.ts:216-227 (helper)Helper function to format individual game score information for display.function formatGameScore(game: GameScore): string { const status = game.gameState === 'LIVE' || game.gameState === 'CRIT' ? `LIVE - Period ${game.period}` : game.gameState === 'FUT' ? 'Scheduled' : game.gameState === 'FINAL' || game.gameState === 'OFF' ? 'Final' : game.gameState; return `${game.awayTeam.abbrev} ${game.awayTeam.score} @ ${game.homeTeam.abbrev} ${game.homeTeam.score} - ${status}\nVenue: ${game.venue}\nDate: ${game.gameDate}\nGame ID: ${game.id}`; }