Skip to main content
Glama
argotdev

NHL MCP Server

by argotdev

compare_teams

Compare head-to-head statistics between two NHL teams, including recent matchups and historical records, to analyze team performance and rivalries.

Instructions

Compare head-to-head statistics between two NHL teams including recent matchups and historical records.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
team1YesFirst team abbreviation (e.g., TOR)
team2YesSecond team abbreviation (e.g., MTL)
seasonNoSeason in format YYYYYYYY (optional, defaults to current)

Implementation Reference

  • The core handler function that implements the compare_teams tool logic by fetching team schedules from NHLAPIClient, filtering head-to-head matchups, calculating wins, and formatting the comparison results.
    async function compareTeamsHeadToHead(team1: string, team2: string, season?: string): Promise<string> { try { const schedule1 = await client.getTeamSchedule(team1, season); if (!schedule1.games) { return `No schedule data found for ${team1}`; } // Find games between these two teams const matchups = schedule1.games.filter((game: any) => { return ( (game.homeTeam.abbrev === team1 && game.awayTeam.abbrev === team2) || (game.homeTeam.abbrev === team2 && game.awayTeam.abbrev === team1) ); }); if (matchups.length === 0) { return `No matchups found between ${team1} and ${team2} this season`; } let team1Wins = 0; let team2Wins = 0; const results: string[] = []; matchups.forEach((game: any) => { const isTeam1Home = game.homeTeam.abbrev === team1; const team1Score = isTeam1Home ? game.homeTeam.score : game.awayTeam.score; const team2Score = isTeam1Home ? game.awayTeam.score : game.homeTeam.score; if (game.gameState === 'OFF' || game.gameState === 'FINAL') { if (team1Score > team2Score) { team1Wins++; results.push(`${game.gameDate}: ${team1} ${team1Score}, ${team2} ${team2Score} - ${team1} WIN`); } else { team2Wins++; results.push(`${game.gameDate}: ${team1} ${team1Score}, ${team2} ${team2Score} - ${team2} WIN`); } } else if (game.gameState === 'FUT') { results.push(`${game.gameDate}: Upcoming game`); } else { results.push(`${game.gameDate}: ${team1} ${team1Score}, ${team2} ${team2Score} - IN PROGRESS`); } }); return `Head-to-Head: ${team1} vs ${team2}\n\nSeason Series: ${team1} ${team1Wins}-${team2Wins} ${team2}\n\nGames:\n${results.join('\n')}`; } catch (error: any) { return `Error comparing teams: ${error.message}`; } }
  • The tool schema definition including name, description, input schema with properties for team1, team2 (required), and optional season.
    { name: 'compare_teams', description: 'Compare head-to-head statistics between two NHL teams including recent matchups and historical records.', inputSchema: { type: 'object', properties: { team1: { type: 'string', description: 'First team abbreviation (e.g., TOR)', }, team2: { type: 'string', description: 'Second team abbreviation (e.g., MTL)', }, season: { type: 'string', description: 'Season in format YYYYYYYY (optional, defaults to current)', }, }, required: ['team1', 'team2'], }, },
  • src/index.ts:575-584 (registration)
    The registration and dispatch logic in the CallToolRequestSchema handler that matches the tool name and calls the compareTeamsHeadToHead handler with parsed parameters.
    case 'compare_teams': { const comparison = await compareTeamsHeadToHead( parameters.team1 as string, parameters.team2 as string, parameters.season as string | undefined ); return { content: [{ type: 'text', text: comparison }], }; }

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/argotdev/nhl-mcp-ts'

If you have feedback or need assistance with the MCP directory API, please join our Discord server