@mrfentmen/f1-data-mcp 0.0.0-stage → 1.0.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/README.md CHANGED
@@ -1,3 +1,25 @@
1
- # Temporary Holding Version
1
+ # f1-data-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ MCP server for Formula 1 data. Keyless: it reads the Jolpica API, the community Ergast replacement.
4
+
5
+ ## Tools
6
+
7
+ | Tool | What it returns |
8
+ | --- | --- |
9
+ | `get_races` | Race calendar for a season |
10
+ | `get_driver_standings` | Driver championship order |
11
+
12
+ Season: a year like `2026`, or `current`.
13
+
14
+ ## Run
15
+
16
+ ```bash
17
+ npx -y @mrfentmen/f1-data-mcp
18
+ ```
19
+
20
+ ## Build and test
21
+
22
+ ```bash
23
+ npm install
24
+ npm test
25
+ ```
package/dist/api.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export declare class F1DataError extends Error {
2
+ }
3
+ export interface Race {
4
+ round: string;
5
+ name: string;
6
+ circuit: string;
7
+ place: string;
8
+ date: string;
9
+ }
10
+ export declare function races(season: string): Promise<{
11
+ season: string;
12
+ list: Race[];
13
+ }>;
14
+ export declare function formatRaces(season: string, list: Race[]): string;
15
+ export declare function standings(season: string): Promise<{
16
+ season: string;
17
+ list: string[];
18
+ }>;
19
+ export declare function formatStandings(season: string, list: string[]): string;
package/dist/api.js ADDED
@@ -0,0 +1,77 @@
1
+ const API = "https://api.jolpi.ca/ergast/f1";
2
+ const H = {
3
+ "User-Agent": "mrfentmen-f1-data-mcp/1.0 (+https://github.com/mrfentmen/awesome-servers)",
4
+ Accept: "application/json",
5
+ };
6
+ export class F1DataError extends Error {
7
+ }
8
+ function seasonNumber(value) {
9
+ const trimmed = value.trim().toLowerCase();
10
+ if (trimmed === "current")
11
+ return "current";
12
+ if (!/^\d{4}$/.test(trimmed))
13
+ throw new F1DataError(`not a season: ${value}`);
14
+ return trimmed;
15
+ }
16
+ async function get(url) {
17
+ try {
18
+ const response = await fetch(url, { headers: H, signal: AbortSignal.timeout(20000) });
19
+ if (!response.ok)
20
+ throw new F1DataError(`Jolpica answered ${response.status}`);
21
+ return (await response.json());
22
+ }
23
+ catch (error) {
24
+ if (error instanceof F1DataError)
25
+ throw error;
26
+ throw new F1DataError(`Jolpica unreachable: ${error instanceof Error ? error.message : String(error)}`);
27
+ }
28
+ }
29
+ export async function races(season) {
30
+ const id = seasonNumber(season);
31
+ const url = new URL(`${API}/${id}/races.json`);
32
+ url.searchParams.set("limit", "30");
33
+ const json = await get(url);
34
+ const table = json.MRData?.RaceTable;
35
+ const list = (table?.Races ?? [])
36
+ .filter((race) => race.round && race.raceName)
37
+ .map((race) => {
38
+ const place = [race.Circuit?.Location?.locality, race.Circuit?.Location?.country]
39
+ .filter(Boolean)
40
+ .join(", ");
41
+ return {
42
+ round: race.round,
43
+ name: race.raceName,
44
+ circuit: race.Circuit?.circuitName ?? "unknown circuit",
45
+ place,
46
+ date: race.date ?? "unknown",
47
+ };
48
+ });
49
+ if (list.length === 0)
50
+ throw new F1DataError(`No races found for season ${season}`);
51
+ return { season: table?.season ?? season, list };
52
+ }
53
+ export function formatRaces(season, list) {
54
+ const lines = list.map((race, index) => {
55
+ return `${index + 1}. Round ${race.round} — ${race.name} — ${race.circuit}, ${race.place} — ${race.date}`;
56
+ });
57
+ return `# F1 races, season ${season}\n\n${lines.join("\n")}`;
58
+ }
59
+ export async function standings(season) {
60
+ const id = seasonNumber(season);
61
+ const url = new URL(`${API}/${id}/driverstandings.json`);
62
+ const json = await get(url);
63
+ const table = json.MRData?.StandingsTable;
64
+ const list = (table?.StandingsLists?.[0]?.DriverStandings ?? [])
65
+ .filter((standing) => standing.Driver?.familyName)
66
+ .map((standing) => {
67
+ const name = `${standing.Driver?.givenName ?? ""} ${standing.Driver?.familyName ?? ""}`.trim();
68
+ const team = standing.Constructors?.[0]?.name ? ` (${standing.Constructors[0].name})` : "";
69
+ return `${standing.position ?? "?"}. ${name}${team} — ${standing.points ?? "0"} points, ${standing.wins ?? "0"} wins`;
70
+ });
71
+ if (list.length === 0)
72
+ throw new F1DataError(`No driver standings found for season ${season}`);
73
+ return { season: id, list };
74
+ }
75
+ export function formatStandings(season, list) {
76
+ return `# F1 driver standings, season ${season}\n\n${list.join("\n")}`;
77
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { createServer } from "./server.js";
4
+ async function main() {
5
+ const server = createServer();
6
+ const transport = new StdioServerTransport();
7
+ await server.connect(transport);
8
+ console.error("f1-data-mcp running on stdio");
9
+ }
10
+ main().catch((error) => {
11
+ console.error("Fatal error:", error);
12
+ process.exit(1);
13
+ });
@@ -0,0 +1,2 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function createServer(): McpServer;
package/dist/server.js ADDED
@@ -0,0 +1,31 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { formatRaces, formatStandings, races, standings } from "./api.js";
4
+ const text = (value) => ({ content: [{ type: "text", text: value }] });
5
+ const failed = (error) => text(`Error: ${error instanceof Error ? error.message : String(error)}`);
6
+ export function createServer() {
7
+ const server = new McpServer({ name: "f1-data-mcp", version: "1.0.0" });
8
+ server.tool("get_races", "Formula 1 race calendar for a season.", {
9
+ season: z.string().default("current").describe("A year, or current"),
10
+ }, async ({ season }) => {
11
+ try {
12
+ const found = await races(season);
13
+ return text(formatRaces(found.season, found.list));
14
+ }
15
+ catch (error) {
16
+ return failed(error);
17
+ }
18
+ });
19
+ server.tool("get_driver_standings", "Formula 1 driver championship standings for a season.", {
20
+ season: z.string().default("current").describe("A year, or current"),
21
+ }, async ({ season }) => {
22
+ try {
23
+ const found = await standings(season);
24
+ return text(formatStandings(found.season, found.list));
25
+ }
26
+ catch (error) {
27
+ return failed(error);
28
+ }
29
+ });
30
+ return server;
31
+ }
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@mrfentmen/f1-data-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Formula 1 MCP: race calendar and driver standings. Keyless.",
5
+ "type": "module",
6
+ "mcpName": "io.github.mrfentmen/f1-data-mcp",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mrfentmen/awesome-servers.git"
10
+ },
11
+ "bin": {
12
+ "f1-data-mcp": "./dist/index.js"
13
+ },
14
+ "main": "./dist/index.js",
15
+ "files": [
16
+ "dist",
17
+ "server.json",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json",
22
+ "start": "node dist/index.js",
23
+ "test": "npm run build && node --test tests/tools.test.mjs"
24
+ },
25
+ "keywords": [
26
+ "mcp",
27
+ "formula-1",
28
+ "f1",
29
+ "racing",
30
+ "video-games"
31
+ ],
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@modelcontextprotocol/sdk": "^1.0.4",
35
+ "zod": "^3.23.8"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^22.0.0",
39
+ "typescript": "^5.6.0"
40
+ }
41
+ }
package/server.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.mrfentmen/f1-data-mcp",
4
+ "description": "Formula 1 MCP: race calendar and driver standings. Keyless.",
5
+ "repository": {
6
+ "url": "https://github.com/mrfentmen/awesome-servers",
7
+ "source": "github"
8
+ },
9
+ "version": "1.0.0",
10
+ "packages": [
11
+ {
12
+ "registryType": "npm",
13
+ "identifier": "@mrfentmen/f1-data-mcp",
14
+ "version": "1.0.0",
15
+ "transport": {
16
+ "type": "stdio"
17
+ }
18
+ }
19
+ ]
20
+ }