@pipeworx/mcp-nhl 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +328 -0
- package/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# mcp-nhl
|
|
2
|
+
|
|
3
|
+
NHL MCP — live NHL data via the official NHL API
|
|
4
|
+
|
|
5
|
+
Part of the [Pipeworx](https://pipeworx.io) open MCP gateway.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
Add to your MCP client config:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"nhl": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/nhl/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or use the CLI:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx pipeworx use nhl
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-nhl",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NHL MCP — live NHL data via the official NHL API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "nhl"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-nhl"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/nhl",
|
|
4
|
+
"title": "nhl",
|
|
5
|
+
"description": "NHL MCP — live NHL data via the official NHL API",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/nhl",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-nhl",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/nhl/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
interface McpToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: 'object';
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface McpToolExport {
|
|
12
|
+
tools: McpToolDefinition[];
|
|
13
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* NHL MCP — live NHL data via the official NHL API
|
|
18
|
+
*
|
|
19
|
+
* Tools:
|
|
20
|
+
* - get_standings: Get current NHL standings
|
|
21
|
+
* - get_scores: Get today's NHL scores
|
|
22
|
+
* - get_schedule: Get the current schedule
|
|
23
|
+
* - get_player: Get detailed player profile by player ID
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const BASE_URL = 'https://api-web.nhle.com/v1';
|
|
28
|
+
|
|
29
|
+
// --- Raw API types ---
|
|
30
|
+
|
|
31
|
+
type RawTeamRecord = {
|
|
32
|
+
teamName?: { default?: string } | null;
|
|
33
|
+
teamAbbrev?: { default?: string } | null;
|
|
34
|
+
teamLogo?: string | null;
|
|
35
|
+
divisionName?: string | null;
|
|
36
|
+
conferenceName?: string | null;
|
|
37
|
+
wins?: number | null;
|
|
38
|
+
losses?: number | null;
|
|
39
|
+
otLosses?: number | null;
|
|
40
|
+
points?: number | null;
|
|
41
|
+
gamesPlayed?: number | null;
|
|
42
|
+
goalFor?: number | null;
|
|
43
|
+
goalAgainst?: number | null;
|
|
44
|
+
streakCode?: string | null;
|
|
45
|
+
streakCount?: number | null;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type RawStandingsResponse = {
|
|
49
|
+
standings: RawTeamRecord[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type RawGoal = {
|
|
53
|
+
playerId?: number | null;
|
|
54
|
+
name?: { default?: string } | null;
|
|
55
|
+
teamAbbrev?: string | null;
|
|
56
|
+
period?: number | null;
|
|
57
|
+
timeInPeriod?: string | null;
|
|
58
|
+
goalsToDate?: number | null;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type RawGame = {
|
|
62
|
+
id?: number | null;
|
|
63
|
+
gameState?: string | null;
|
|
64
|
+
awayTeam?: {
|
|
65
|
+
abbrev?: string | null;
|
|
66
|
+
name?: { default?: string } | null;
|
|
67
|
+
score?: number | null;
|
|
68
|
+
sog?: number | null;
|
|
69
|
+
} | null;
|
|
70
|
+
homeTeam?: {
|
|
71
|
+
abbrev?: string | null;
|
|
72
|
+
name?: { default?: string } | null;
|
|
73
|
+
score?: number | null;
|
|
74
|
+
sog?: number | null;
|
|
75
|
+
} | null;
|
|
76
|
+
startTimeUTC?: string | null;
|
|
77
|
+
period?: number | null;
|
|
78
|
+
periodDescriptor?: { number?: number; periodType?: string } | null;
|
|
79
|
+
goals?: RawGoal[] | null;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type RawScoreResponse = {
|
|
83
|
+
currentDate?: string | null;
|
|
84
|
+
games: RawGame[];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
type RawScheduleGame = {
|
|
88
|
+
id?: number | null;
|
|
89
|
+
gameDate?: string | null;
|
|
90
|
+
startTimeUTC?: string | null;
|
|
91
|
+
gameState?: string | null;
|
|
92
|
+
awayTeam?: { abbrev?: string | null; name?: { default?: string } | null } | null;
|
|
93
|
+
homeTeam?: { abbrev?: string | null; name?: { default?: string } | null } | null;
|
|
94
|
+
venue?: { default?: string } | null;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
type RawScheduleResponse = {
|
|
98
|
+
currentDate?: string | null;
|
|
99
|
+
gameWeek?: Array<{
|
|
100
|
+
date?: string;
|
|
101
|
+
games?: RawScheduleGame[];
|
|
102
|
+
}> | null;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
type RawPlayerLanding = {
|
|
106
|
+
playerId?: number | null;
|
|
107
|
+
firstName?: { default?: string } | null;
|
|
108
|
+
lastName?: { default?: string } | null;
|
|
109
|
+
sweaterNumber?: number | null;
|
|
110
|
+
position?: string | null;
|
|
111
|
+
headshot?: string | null;
|
|
112
|
+
birthDate?: string | null;
|
|
113
|
+
birthCity?: { default?: string } | null;
|
|
114
|
+
birthCountry?: string | null;
|
|
115
|
+
heightInInches?: number | null;
|
|
116
|
+
weightInPounds?: number | null;
|
|
117
|
+
currentTeamAbbrev?: string | null;
|
|
118
|
+
currentTeamName?: { default?: string } | null;
|
|
119
|
+
featuredStats?: {
|
|
120
|
+
season?: number | null;
|
|
121
|
+
regularSeason?: {
|
|
122
|
+
subSeason?: {
|
|
123
|
+
gamesPlayed?: number | null;
|
|
124
|
+
goals?: number | null;
|
|
125
|
+
assists?: number | null;
|
|
126
|
+
points?: number | null;
|
|
127
|
+
plusMinus?: number | null;
|
|
128
|
+
pim?: number | null;
|
|
129
|
+
};
|
|
130
|
+
} | null;
|
|
131
|
+
} | null;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// --- Formatters ---
|
|
135
|
+
|
|
136
|
+
function formatTeamRecord(team: RawTeamRecord) {
|
|
137
|
+
return {
|
|
138
|
+
name: team.teamName?.default ?? null,
|
|
139
|
+
abbrev: team.teamAbbrev?.default ?? null,
|
|
140
|
+
division: team.divisionName ?? null,
|
|
141
|
+
conference: team.conferenceName ?? null,
|
|
142
|
+
games_played: team.gamesPlayed ?? null,
|
|
143
|
+
wins: team.wins ?? null,
|
|
144
|
+
losses: team.losses ?? null,
|
|
145
|
+
ot_losses: team.otLosses ?? null,
|
|
146
|
+
points: team.points ?? null,
|
|
147
|
+
goals_for: team.goalFor ?? null,
|
|
148
|
+
goals_against: team.goalAgainst ?? null,
|
|
149
|
+
streak: team.streakCode && team.streakCount != null ? `${team.streakCode}${team.streakCount}` : null,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function formatGame(game: RawGame) {
|
|
154
|
+
return {
|
|
155
|
+
id: game.id ?? null,
|
|
156
|
+
state: game.gameState ?? null,
|
|
157
|
+
start_time_utc: game.startTimeUTC ?? null,
|
|
158
|
+
period: game.period ?? null,
|
|
159
|
+
away_team: game.awayTeam?.name?.default ?? game.awayTeam?.abbrev ?? null,
|
|
160
|
+
away_score: game.awayTeam?.score ?? null,
|
|
161
|
+
away_sog: game.awayTeam?.sog ?? null,
|
|
162
|
+
home_team: game.homeTeam?.name?.default ?? game.homeTeam?.abbrev ?? null,
|
|
163
|
+
home_score: game.homeTeam?.score ?? null,
|
|
164
|
+
home_sog: game.homeTeam?.sog ?? null,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function formatScheduleGame(game: RawScheduleGame) {
|
|
169
|
+
return {
|
|
170
|
+
id: game.id ?? null,
|
|
171
|
+
date: game.gameDate ?? null,
|
|
172
|
+
start_time_utc: game.startTimeUTC ?? null,
|
|
173
|
+
state: game.gameState ?? null,
|
|
174
|
+
away_team: game.awayTeam?.name?.default ?? game.awayTeam?.abbrev ?? null,
|
|
175
|
+
home_team: game.homeTeam?.name?.default ?? game.homeTeam?.abbrev ?? null,
|
|
176
|
+
venue: game.venue?.default ?? null,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function formatPlayer(p: RawPlayerLanding) {
|
|
181
|
+
const stats = p.featuredStats?.regularSeason?.subSeason;
|
|
182
|
+
return {
|
|
183
|
+
player_id: p.playerId ?? null,
|
|
184
|
+
name: [p.firstName?.default, p.lastName?.default].filter(Boolean).join(' ') || null,
|
|
185
|
+
number: p.sweaterNumber ?? null,
|
|
186
|
+
position: p.position ?? null,
|
|
187
|
+
team: p.currentTeamName?.default ?? null,
|
|
188
|
+
team_abbrev: p.currentTeamAbbrev ?? null,
|
|
189
|
+
birth_date: p.birthDate ?? null,
|
|
190
|
+
birth_city: p.birthCity?.default ?? null,
|
|
191
|
+
birth_country: p.birthCountry ?? null,
|
|
192
|
+
height_in: p.heightInInches ?? null,
|
|
193
|
+
weight_lbs: p.weightInPounds ?? null,
|
|
194
|
+
headshot: p.headshot ?? null,
|
|
195
|
+
current_season_stats: stats
|
|
196
|
+
? {
|
|
197
|
+
season: p.featuredStats?.season ?? null,
|
|
198
|
+
games_played: stats.gamesPlayed ?? null,
|
|
199
|
+
goals: stats.goals ?? null,
|
|
200
|
+
assists: stats.assists ?? null,
|
|
201
|
+
points: stats.points ?? null,
|
|
202
|
+
plus_minus: stats.plusMinus ?? null,
|
|
203
|
+
pim: stats.pim ?? null,
|
|
204
|
+
}
|
|
205
|
+
: null,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// --- Tool definitions ---
|
|
210
|
+
|
|
211
|
+
const tools: McpToolExport['tools'] = [
|
|
212
|
+
{
|
|
213
|
+
name: 'get_standings',
|
|
214
|
+
description:
|
|
215
|
+
'Get current NHL standings for all teams. Returns wins, losses, OT losses, points, goals for/against, and streak.',
|
|
216
|
+
inputSchema: {
|
|
217
|
+
type: 'object',
|
|
218
|
+
properties: {},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: 'get_scores',
|
|
223
|
+
description:
|
|
224
|
+
"Get today's NHL game scores and states (live, final, scheduled). Returns teams, scores, shots on goal, and period.",
|
|
225
|
+
inputSchema: {
|
|
226
|
+
type: 'object',
|
|
227
|
+
properties: {},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'get_schedule',
|
|
232
|
+
description:
|
|
233
|
+
'Get the current NHL weekly schedule. Returns upcoming and recent games with teams, dates, and venues.',
|
|
234
|
+
inputSchema: {
|
|
235
|
+
type: 'object',
|
|
236
|
+
properties: {},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: 'get_player',
|
|
241
|
+
description:
|
|
242
|
+
'Get detailed profile and current season stats for an NHL player by their numeric player ID.',
|
|
243
|
+
inputSchema: {
|
|
244
|
+
type: 'object',
|
|
245
|
+
properties: {
|
|
246
|
+
playerId: {
|
|
247
|
+
type: 'number',
|
|
248
|
+
description: 'NHL player ID (e.g., 8478402 for Connor McDavid)',
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
required: ['playerId'],
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
// --- callTool dispatcher ---
|
|
257
|
+
|
|
258
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
259
|
+
switch (name) {
|
|
260
|
+
case 'get_standings':
|
|
261
|
+
return getStandings();
|
|
262
|
+
case 'get_scores':
|
|
263
|
+
return getScores();
|
|
264
|
+
case 'get_schedule':
|
|
265
|
+
return getSchedule();
|
|
266
|
+
case 'get_player':
|
|
267
|
+
return getPlayer(args.playerId as number);
|
|
268
|
+
default:
|
|
269
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// --- Tool implementations ---
|
|
274
|
+
|
|
275
|
+
async function getStandings() {
|
|
276
|
+
const res = await fetch(`${BASE_URL}/standings/now`);
|
|
277
|
+
if (!res.ok) throw new Error(`NHL API error: ${res.status}`);
|
|
278
|
+
|
|
279
|
+
const data = (await res.json()) as RawStandingsResponse;
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
total: data.standings.length,
|
|
283
|
+
standings: data.standings.map(formatTeamRecord),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function getScores() {
|
|
288
|
+
const res = await fetch(`${BASE_URL}/score/now`);
|
|
289
|
+
if (!res.ok) throw new Error(`NHL API error: ${res.status}`);
|
|
290
|
+
|
|
291
|
+
const data = (await res.json()) as RawScoreResponse;
|
|
292
|
+
|
|
293
|
+
return {
|
|
294
|
+
date: data.currentDate ?? null,
|
|
295
|
+
total_games: data.games.length,
|
|
296
|
+
games: data.games.map(formatGame),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function getSchedule() {
|
|
301
|
+
const res = await fetch(`${BASE_URL}/schedule/now`);
|
|
302
|
+
if (!res.ok) throw new Error(`NHL API error: ${res.status}`);
|
|
303
|
+
|
|
304
|
+
const data = (await res.json()) as RawScheduleResponse;
|
|
305
|
+
|
|
306
|
+
const allGames: ReturnType<typeof formatScheduleGame>[] = [];
|
|
307
|
+
for (const week of data.gameWeek ?? []) {
|
|
308
|
+
for (const game of week.games ?? []) {
|
|
309
|
+
allGames.push(formatScheduleGame(game));
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return {
|
|
314
|
+
current_date: data.currentDate ?? null,
|
|
315
|
+
total_games: allGames.length,
|
|
316
|
+
games: allGames,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async function getPlayer(playerId: number) {
|
|
321
|
+
const res = await fetch(`${BASE_URL}/player/${playerId}/landing`);
|
|
322
|
+
if (!res.ok) throw new Error(`NHL API error: ${res.status}`);
|
|
323
|
+
|
|
324
|
+
const data = (await res.json()) as RawPlayerLanding;
|
|
325
|
+
return formatPlayer(data);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export default { tools, callTool } satisfies McpToolExport;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|