@pipeworx/mcp-sports 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 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-sports
2
+
3
+ Sports MCP — wraps TheSportsDB API (free tier, test key "3", no auth required)
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
+ "sports": {
20
+ "url": "https://gateway.pipeworx.io/sports/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or use the CLI:
27
+
28
+ ```bash
29
+ npx pipeworx use sports
30
+ ```
31
+
32
+ ## License
33
+
34
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-sports",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for sports data — teams, players, standings, and match results via TheSportsDB",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "sports"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-sports"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/sports",
4
+ "title": "sports",
5
+ "description": "Sports MCP — wraps TheSportsDB API (free tier, test key "3", no auth required)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/sports",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-sports",
10
+ "source": "github"
11
+ },
12
+ "packages": [
13
+ {
14
+ "registryType": "npm",
15
+ "identifier": "@pipeworx/mcp-sports",
16
+ "version": "0.1.0"
17
+ }
18
+ ],
19
+ "remotes": [
20
+ {
21
+ "type": "streamable-http",
22
+ "url": "https://gateway.pipeworx.io/sports/mcp"
23
+ }
24
+ ]
25
+ }
package/src/index.ts ADDED
@@ -0,0 +1,319 @@
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
+ * Sports MCP — wraps TheSportsDB API (free tier, test key "3", no auth required)
18
+ *
19
+ * Tools:
20
+ * - search_teams: Search sports teams by name
21
+ * - search_players: Search players by name
22
+ * - get_league_table: Get current standings for a league and season
23
+ * - get_last_events: Get last 15 events/matches for a team
24
+ * - get_next_events: Get next 15 upcoming events for a team
25
+ */
26
+
27
+
28
+ const BASE_URL = 'https://www.thesportsdb.com/api/v1/json/3';
29
+
30
+ // --- Raw API types ---
31
+
32
+ type RawTeam = {
33
+ idTeam: string;
34
+ strTeam: string;
35
+ strSport?: string;
36
+ strLeague?: string;
37
+ strCountry?: string;
38
+ strStadium?: string;
39
+ strDescriptionEN?: string;
40
+ strTeamBadge?: string;
41
+ };
42
+
43
+ type RawPlayer = {
44
+ idPlayer: string;
45
+ strPlayer: string;
46
+ strTeam?: string;
47
+ strNationality?: string;
48
+ strPosition?: string;
49
+ strDescriptionEN?: string;
50
+ strThumb?: string;
51
+ };
52
+
53
+ type RawTableEntry = {
54
+ idTeam: string;
55
+ strTeam: string;
56
+ intPlayed?: string;
57
+ intWin?: string;
58
+ intDraw?: string;
59
+ intLoss?: string;
60
+ intGoalsFor?: string;
61
+ intGoalsAgainst?: string;
62
+ intPoints?: string;
63
+ };
64
+
65
+ type RawEvent = {
66
+ idEvent: string;
67
+ strEvent: string;
68
+ dateEvent?: string;
69
+ strHomeTeam?: string;
70
+ strAwayTeam?: string;
71
+ intHomeScore?: string | null;
72
+ intAwayScore?: string | null;
73
+ strLeague?: string;
74
+ };
75
+
76
+ // --- Tool definitions ---
77
+
78
+ const tools: McpToolExport['tools'] = [
79
+ {
80
+ name: 'search_teams',
81
+ description:
82
+ 'Search for sports teams by name. Returns team name, sport, league, country, stadium, description, and badge URL.',
83
+ inputSchema: {
84
+ type: 'object',
85
+ properties: {
86
+ query: { type: 'string', description: 'Team name or partial name to search for' },
87
+ },
88
+ required: ['query'],
89
+ },
90
+ },
91
+ {
92
+ name: 'search_players',
93
+ description:
94
+ 'Search for players by name. Returns player name, team, nationality, position, description, and thumbnail URL.',
95
+ inputSchema: {
96
+ type: 'object',
97
+ properties: {
98
+ query: { type: 'string', description: 'Player name or partial name to search for' },
99
+ },
100
+ required: ['query'],
101
+ },
102
+ },
103
+ {
104
+ name: 'get_league_table',
105
+ description:
106
+ 'Get current standings/table for a league and season. Returns team, played, wins, draws, losses, goals for, goals against, and points.',
107
+ inputSchema: {
108
+ type: 'object',
109
+ properties: {
110
+ league_id: {
111
+ type: 'string',
112
+ description: 'TheSportsDB league ID (e.g., "4328" for English Premier League)',
113
+ },
114
+ season: {
115
+ type: 'string',
116
+ description: 'Season string (e.g., "2024-2025")',
117
+ },
118
+ },
119
+ required: ['league_id', 'season'],
120
+ },
121
+ },
122
+ {
123
+ name: 'get_last_events',
124
+ description:
125
+ 'Get the last 15 events/matches played by a team. Returns event name, date, home team, away team, scores, and league.',
126
+ inputSchema: {
127
+ type: 'object',
128
+ properties: {
129
+ team_id: {
130
+ type: 'string',
131
+ description: 'TheSportsDB team ID (e.g., "133604" for Arsenal)',
132
+ },
133
+ },
134
+ required: ['team_id'],
135
+ },
136
+ },
137
+ {
138
+ name: 'get_next_events',
139
+ description:
140
+ 'Get the next 15 upcoming events/matches for a team. Returns event name, date, home team, away team, and league.',
141
+ inputSchema: {
142
+ type: 'object',
143
+ properties: {
144
+ team_id: {
145
+ type: 'string',
146
+ description: 'TheSportsDB team ID (e.g., "133604" for Arsenal)',
147
+ },
148
+ },
149
+ required: ['team_id'],
150
+ },
151
+ },
152
+ ];
153
+
154
+ // --- callTool dispatcher ---
155
+
156
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
157
+ switch (name) {
158
+ case 'search_teams':
159
+ return searchTeams(args.query as string);
160
+ case 'search_players':
161
+ return searchPlayers(args.query as string);
162
+ case 'get_league_table':
163
+ return getLeagueTable(args.league_id as string, args.season as string);
164
+ case 'get_last_events':
165
+ return getLastEvents(args.team_id as string);
166
+ case 'get_next_events':
167
+ return getNextEvents(args.team_id as string);
168
+ default:
169
+ throw new Error(`Unknown tool: ${name}`);
170
+ }
171
+ }
172
+
173
+ // --- Formatters ---
174
+
175
+ function formatTeam(team: RawTeam) {
176
+ return {
177
+ id: team.idTeam,
178
+ name: team.strTeam,
179
+ sport: team.strSport ?? null,
180
+ league: team.strLeague ?? null,
181
+ country: team.strCountry ?? null,
182
+ stadium: team.strStadium ?? null,
183
+ description: team.strDescriptionEN ?? null,
184
+ badge_url: team.strTeamBadge ?? null,
185
+ };
186
+ }
187
+
188
+ function formatPlayer(player: RawPlayer) {
189
+ return {
190
+ id: player.idPlayer,
191
+ name: player.strPlayer,
192
+ team: player.strTeam ?? null,
193
+ nationality: player.strNationality ?? null,
194
+ position: player.strPosition ?? null,
195
+ description: player.strDescriptionEN ?? null,
196
+ thumbnail_url: player.strThumb ?? null,
197
+ };
198
+ }
199
+
200
+ function formatTableEntry(entry: RawTableEntry) {
201
+ return {
202
+ id: entry.idTeam,
203
+ team: entry.strTeam,
204
+ played: entry.intPlayed != null ? Number(entry.intPlayed) : null,
205
+ wins: entry.intWin != null ? Number(entry.intWin) : null,
206
+ draws: entry.intDraw != null ? Number(entry.intDraw) : null,
207
+ losses: entry.intLoss != null ? Number(entry.intLoss) : null,
208
+ goals_for: entry.intGoalsFor != null ? Number(entry.intGoalsFor) : null,
209
+ goals_against: entry.intGoalsAgainst != null ? Number(entry.intGoalsAgainst) : null,
210
+ points: entry.intPoints != null ? Number(entry.intPoints) : null,
211
+ };
212
+ }
213
+
214
+ function formatEvent(event: RawEvent) {
215
+ return {
216
+ id: event.idEvent,
217
+ name: event.strEvent,
218
+ date: event.dateEvent ?? null,
219
+ home_team: event.strHomeTeam ?? null,
220
+ away_team: event.strAwayTeam ?? null,
221
+ home_score: event.intHomeScore != null ? event.intHomeScore : null,
222
+ away_score: event.intAwayScore != null ? event.intAwayScore : null,
223
+ league: event.strLeague ?? null,
224
+ };
225
+ }
226
+
227
+ function formatUpcomingEvent(event: RawEvent) {
228
+ return {
229
+ id: event.idEvent,
230
+ name: event.strEvent,
231
+ date: event.dateEvent ?? null,
232
+ home_team: event.strHomeTeam ?? null,
233
+ away_team: event.strAwayTeam ?? null,
234
+ league: event.strLeague ?? null,
235
+ };
236
+ }
237
+
238
+ // --- Tool implementations ---
239
+
240
+ async function searchTeams(query: string) {
241
+ const res = await fetch(
242
+ `${BASE_URL}/searchteams.php?t=${encodeURIComponent(query)}`,
243
+ );
244
+ if (!res.ok) throw new Error(`TheSportsDB error: ${res.status}`);
245
+
246
+ const data = (await res.json()) as { teams: RawTeam[] | null };
247
+ if (!data.teams) return { teams: [], total: 0 };
248
+
249
+ return {
250
+ total: data.teams.length,
251
+ teams: data.teams.map(formatTeam),
252
+ };
253
+ }
254
+
255
+ async function searchPlayers(query: string) {
256
+ const res = await fetch(
257
+ `${BASE_URL}/searchplayers.php?p=${encodeURIComponent(query)}`,
258
+ );
259
+ if (!res.ok) throw new Error(`TheSportsDB error: ${res.status}`);
260
+
261
+ const data = (await res.json()) as { player: RawPlayer[] | null };
262
+ if (!data.player) return { players: [], total: 0 };
263
+
264
+ return {
265
+ total: data.player.length,
266
+ players: data.player.map(formatPlayer),
267
+ };
268
+ }
269
+
270
+ async function getLeagueTable(leagueId: string, season: string) {
271
+ const res = await fetch(
272
+ `${BASE_URL}/lookuptable.php?l=${encodeURIComponent(leagueId)}&s=${encodeURIComponent(season)}`,
273
+ );
274
+ if (!res.ok) throw new Error(`TheSportsDB error: ${res.status}`);
275
+
276
+ const data = (await res.json()) as { table: RawTableEntry[] | null };
277
+ if (!data.table) return { league_id: leagueId, season, standings: [], total: 0 };
278
+
279
+ return {
280
+ league_id: leagueId,
281
+ season,
282
+ total: data.table.length,
283
+ standings: data.table.map(formatTableEntry),
284
+ };
285
+ }
286
+
287
+ async function getLastEvents(teamId: string) {
288
+ const res = await fetch(
289
+ `${BASE_URL}/eventslast.php?id=${encodeURIComponent(teamId)}`,
290
+ );
291
+ if (!res.ok) throw new Error(`TheSportsDB error: ${res.status}`);
292
+
293
+ const data = (await res.json()) as { results: RawEvent[] | null };
294
+ if (!data.results) return { team_id: teamId, events: [], total: 0 };
295
+
296
+ return {
297
+ team_id: teamId,
298
+ total: data.results.length,
299
+ events: data.results.map(formatEvent),
300
+ };
301
+ }
302
+
303
+ async function getNextEvents(teamId: string) {
304
+ const res = await fetch(
305
+ `${BASE_URL}/eventsnext.php?id=${encodeURIComponent(teamId)}`,
306
+ );
307
+ if (!res.ok) throw new Error(`TheSportsDB error: ${res.status}`);
308
+
309
+ const data = (await res.json()) as { events: RawEvent[] | null };
310
+ if (!data.events) return { team_id: teamId, events: [], total: 0 };
311
+
312
+ return {
313
+ team_id: teamId,
314
+ total: data.events.length,
315
+ events: data.events.map(formatUpcomingEvent),
316
+ };
317
+ }
318
+
319
+ 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
+ }