tides-mcp 1.0.2 → 1.0.4
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 +0 -30
- package/dist/api.d.ts +11 -6
- package/dist/api.js +53 -45
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server.d.ts +0 -2
- package/dist/server.js +52 -92
- package/package.json +3 -6
- package/server.json +3 -3
package/README.md
CHANGED
|
@@ -18,33 +18,3 @@ node dist/index.js
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
The server uses stdio MCP transport and does not write files or contact any service other than NOAA.
|
|
21
|
-
|
|
22
|
-
## Quick start
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install
|
|
26
|
-
npm run build
|
|
27
|
-
node dist/index.js
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
The server uses stdio, so it can be connected to Claude Desktop, Cursor, VS Code, MCP Inspector, or another compatible MCP client.
|
|
31
|
-
|
|
32
|
-
## Tools at a glance
|
|
33
|
-
|
|
34
|
-
- `get_tide_predictions`: Get NOAA high low or hourly tide predictions for a station and date range.
|
|
35
|
-
- `get_water_levels`: Get observed NOAA water levels for a station and short date range.
|
|
36
|
-
|
|
37
|
-
## Limits and privacy
|
|
38
|
-
|
|
39
|
-
This project is intentionally narrow. It should be treated as a practical helper, not a complete certification or security audit. Check the implementation and the returned data before using it with sensitive material. No credentials are required unless the project explicitly says otherwise.
|
|
40
|
-
|
|
41
|
-
## Try it
|
|
42
|
-
|
|
43
|
-
After building, connect the server through your MCP client. The repository root also contains `smoke-test.mjs` for projects covered by the shared harness. A typical tool call starts with `get_tide_predictions`.
|
|
44
|
-
|
|
45
|
-
## Licence — no paywall
|
|
46
|
-
|
|
47
|
-
Every tool in this package is free: no licence key, no premium tier, no hosted
|
|
48
|
-
licence gateway. The paywall machinery this repo once carried (per-tool licence
|
|
49
|
-
checks and paid hosted endpoints) was removed repo-wide on 2026-10-17. Nothing
|
|
50
|
-
that this package installs or calls asks you to pay.
|
package/dist/api.d.ts
CHANGED
|
@@ -3,10 +3,15 @@ export declare class TidesError extends Error {
|
|
|
3
3
|
export declare function predictions(station: string, begin: string, end: string, interval?: "hilo" | "h", units?: string): Promise<any>;
|
|
4
4
|
export declare function waterLevels(station: string, begin: string, end: string, interval?: string, units?: string): Promise<any>;
|
|
5
5
|
export declare function format(data: any): string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export declare function stationList(a: {
|
|
7
|
+
state?: string;
|
|
8
|
+
}): Promise<string>;
|
|
9
|
+
export declare function stationMetadata(a: {
|
|
10
|
+
station: string;
|
|
11
|
+
}): Promise<string>;
|
|
12
|
+
export declare function tideRange(a: {
|
|
13
|
+
station: string;
|
|
14
|
+
begin: string;
|
|
15
|
+
end: string;
|
|
16
|
+
units: string;
|
|
12
17
|
}): Promise<string>;
|
package/dist/api.js
CHANGED
|
@@ -8,50 +8,58 @@ async function get(params) { const url = new URL(BASE); Object.entries({ ...para
|
|
|
8
8
|
export function predictions(station, begin, end, interval = "hilo", units = "english") { return get({ station, product: "predictions", datum: "MLLW", begin_date: begin.replaceAll("-", ""), end_date: end.replaceAll("-", ""), interval, units }); }
|
|
9
9
|
export function waterLevels(station, begin, end, interval = "6", units = "english") { return get({ station, product: "water_level", datum: "MLLW", begin_date: begin.replaceAll("-", ""), end_date: end.replaceAll("-", ""), interval, units }); }
|
|
10
10
|
export function format(data) { return JSON.stringify(data, null, 2).slice(0, 12000); }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const rows =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
const MD = "https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi";
|
|
12
|
+
async function metadata(path) {
|
|
13
|
+
const res = await fetch(MD + path, { headers: HEADERS, signal: AbortSignal.timeout(20000) });
|
|
14
|
+
if (!res.ok)
|
|
15
|
+
throw new TidesError(`NOAA metadata error ${res.status}`);
|
|
16
|
+
return res.json();
|
|
17
|
+
}
|
|
18
|
+
export async function stationList(a) {
|
|
19
|
+
const data = await metadata("/stations.json?type=tidepredictions");
|
|
20
|
+
const all = Array.isArray(data?.stations) ? data.stations : [];
|
|
21
|
+
const wanted = a.state ? a.state.trim().toUpperCase() : "";
|
|
22
|
+
const rows = wanted ? all.filter((s) => clean(s?.state).toUpperCase() === wanted) : all;
|
|
23
|
+
if (!rows.length)
|
|
24
|
+
return `NOAA lists no tide stations${wanted ? ` in ${wanted}` : ""}.`;
|
|
25
|
+
return [`${rows.length} tide station(s)${wanted ? ` in ${wanted}` : ""}, showing ${Math.min(rows.length, 40)}:`, "",
|
|
26
|
+
...rows.slice(0, 40).map((s, i) => `${i + 1}. ${clean(s?.name)} · ${clean(s?.id)} · ${clean(s?.state)} · ${s?.lat}, ${s?.lng}`)].join("\n");
|
|
27
|
+
}
|
|
28
|
+
export async function stationMetadata(a) {
|
|
29
|
+
const id = clean(a.station);
|
|
30
|
+
if (!/^[A-Za-z0-9]{5,10}$/.test(id))
|
|
31
|
+
throw new TidesError(`"${id}" is not a NOAA station id`);
|
|
32
|
+
const body = await metadata(`/stations/${encodeURIComponent(id)}.json`);
|
|
33
|
+
const s = Array.isArray(body?.stations) ? body.stations[0] : undefined;
|
|
34
|
+
if (!s?.id)
|
|
35
|
+
throw new TidesError(`No NOAA station ${id}`);
|
|
36
|
+
return [`${clean(s.name)} (${clean(s.id)})`, "",
|
|
37
|
+
`State: ${clean(s.state)}`,
|
|
38
|
+
`Affiliation: ${clean(s.affiliation)}`,
|
|
39
|
+
`Coordinates: ${s.lat}, ${s.lng}`,
|
|
40
|
+
`Time zone: ${clean(s.timezone)} ${clean(s.timezonecorr)}`,
|
|
41
|
+
`Tide predictions: ${s.tideType ? "yes" : "no"}`,
|
|
42
|
+
`Products: ${Array.isArray(s.products) ? s.products.slice(0, 8).map((p) => clean(p.name)).join(", ") : ""}`,
|
|
43
|
+
`Station page: https://tidesandcurrents.noaa.gov/stationhome.html?id=${clean(s.id)}`].join("\n");
|
|
44
|
+
}
|
|
45
|
+
export async function tideRange(a) {
|
|
46
|
+
const id = clean(a.station);
|
|
47
|
+
if (!/^[A-Za-z0-9]{5,10}$/.test(id))
|
|
48
|
+
throw new TidesError(`"${id}" is not a NOAA station id`);
|
|
49
|
+
const data = await predictions(id, a.begin, a.end, "hilo", a.units);
|
|
50
|
+
const rows = Array.isArray(data?.predictions) ? data.predictions : [];
|
|
29
51
|
if (!rows.length)
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return range > best.range ? { high: h, low: l, range } : best;
|
|
43
|
-
}, { high: null, low: null, range: -Infinity })
|
|
44
|
-
: { high: null, low: null, range: -Infinity };
|
|
45
|
-
return [
|
|
46
|
-
`Tide statistics for station ${String(args.station ?? "").trim()} from ${begin} to ${end}, in ${unitLabel}`,
|
|
47
|
-
`Predictions returned: ${rows.length} (${highs.length} high, ${lows.length} low)`,
|
|
48
|
-
`Mean high water: ${mean(highs.map((r) => r.v))} ${unitLabel}`,
|
|
49
|
-
`Mean low water: ${mean(lows.map((r) => r.v))} ${unitLabel}`,
|
|
50
|
-
`Mean range: ${mean(highs.map((h) => h.v)) !== "not reported" && mean(lows.map((l) => l.v)) !== "not reported" ? `${(highs.reduce((a, b) => a + b.v, 0) / highs.length - lows.reduce((a, b) => a + b.v, 0) / lows.length).toFixed(3)} ${unitLabel}` : "not reported"}`,
|
|
51
|
-
`Highest high: ${highest ? `${highest.v} ${unitLabel} at ${highest.t}` : "no high in the window"}`,
|
|
52
|
-
`Lowest low: ${lowest ? `${lowest.v} ${unitLabel} at ${lowest.t}` : "no low in the window"}`,
|
|
53
|
-
biggest.range > -Infinity && biggest.high && biggest.low
|
|
54
|
-
? `Greatest high to following low: ${biggest.range.toFixed(3)} ${unitLabel}, from ${biggest.high.v} at ${biggest.high.t} to ${biggest.low.v} at ${biggest.low.t}`
|
|
55
|
-
: "Greatest high to following low: not computable, the window has no matched high and low pair.",
|
|
56
|
-
].join("\n");
|
|
52
|
+
return `No tide predictions for ${id} between ${a.begin} and ${a.end}.`;
|
|
53
|
+
const values = rows.map((p) => Number(p.v)).filter((v) => Number.isFinite(v));
|
|
54
|
+
const highs = rows.filter((p) => clean(p.type).toLowerCase() === "h");
|
|
55
|
+
const lows = rows.filter((p) => clean(p.type).toLowerCase() === "l");
|
|
56
|
+
const unit = a.units === "metric" ? "m" : "ft";
|
|
57
|
+
return [`Tide range for ${id} · ${a.begin} to ${a.end}`, "",
|
|
58
|
+
`Highest: ${Math.max(...values).toFixed(2)} ${unit}`,
|
|
59
|
+
`Lowest: ${Math.min(...values).toFixed(2)} ${unit}`,
|
|
60
|
+
`Range: ${(Math.max(...values) - Math.min(...values)).toFixed(2)} ${unit}`,
|
|
61
|
+
`High tides: ${highs.length} · low tides: ${lows.length}`,
|
|
62
|
+
`Next high: ${clean(highs[0]?.t) || "n/a"} ${clean(highs[0]?.v)} ${unit}`,
|
|
63
|
+
`Next low: ${clean(lows[0]?.t) || "n/a"} ${clean(lows[0]?.v)} ${unit}`].join("\n");
|
|
57
64
|
}
|
|
65
|
+
function clean(value) { return String(value ?? "").replace(/\s+/g, " ").trim(); }
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -1,115 +1,75 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { format, predictions,
|
|
3
|
+
import { format, predictions, stationList, stationMetadata, tideRange, TidesError, waterLevels } from "./api.js";
|
|
4
4
|
const text = (s) => ({ content: [{ type: "text", text: s }] });
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const fail = (s) => ({ content: [{ type: "text", text: s }], isError: true });
|
|
6
|
+
function errorMessage(e) {
|
|
7
|
+
if (e instanceof TidesError || e instanceof Error)
|
|
8
|
+
return `Error: ${e.message}`;
|
|
9
|
+
return `Error: ${String(e)}`;
|
|
10
|
+
}
|
|
7
11
|
export function createServer() {
|
|
8
|
-
const server = new McpServer({ name: "tides-mcp", version: "1.0.
|
|
9
|
-
server.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
catch (e) {
|
|
18
|
-
return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
19
|
-
} });
|
|
20
|
-
server.registerTool("get_water_levels", {
|
|
21
|
-
title: "Get water levels",
|
|
22
|
-
description: "Get observed NOAA water levels for a station and short date range.",
|
|
23
|
-
inputSchema: z.object({ station: z.string().min(3), begin: z.string(), end: z.string(), interval: z.enum(["6", "h"]).default("6"), units: z.enum(["english", "metric"]).default("english") }),
|
|
24
|
-
annotations: READ_ONLY,
|
|
25
|
-
}, async ({ station, begin, end, interval, units }) => { try {
|
|
26
|
-
return text(format(await waterLevels(station, begin, end, interval, units)));
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
30
|
-
} });
|
|
31
|
-
server.registerTool("station_metadata", {
|
|
32
|
-
title: "Station metadata",
|
|
33
|
-
description: "What a NOAA station is and what it publishes: name, state, position, tide type, local time zone, SHEF and port codes, and which data product families the station carries.",
|
|
34
|
-
inputSchema: z.object({ station: z.string().min(3).describe("NOAA station id, 7 or 8 digits, e.g. 9414290") }),
|
|
35
|
-
annotations: READ_ONLY,
|
|
36
|
-
}, async (args) => {
|
|
37
|
-
// TODO: implement metadata locally (paywall removed)
|
|
12
|
+
const server = new McpServer({ name: "tides-mcp", version: "1.0.2" });
|
|
13
|
+
server.tool("get_tide_predictions", "Get NOAA high low or hourly tide predictions for a station and date range.", {
|
|
14
|
+
station: z.string().min(3).describe("NOAA station id, e.g. 8443970"),
|
|
15
|
+
begin: z.string().describe("YYYY-MM-DD"),
|
|
16
|
+
end: z.string().describe("YYYY-MM-DD"),
|
|
17
|
+
interval: z.enum(["hilo", "h"]).default("hilo"),
|
|
18
|
+
units: z.enum(["english", "metric"]).default("english")
|
|
19
|
+
}, async (a) => {
|
|
38
20
|
try {
|
|
39
|
-
return
|
|
21
|
+
return text(format(await predictions(a.station, a.begin, a.end, a.interval, a.units)));
|
|
40
22
|
}
|
|
41
23
|
catch (e) {
|
|
42
|
-
return
|
|
24
|
+
return fail(errorMessage(e));
|
|
43
25
|
}
|
|
44
26
|
});
|
|
45
|
-
server.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
27
|
+
server.tool("get_water_levels", "Get observed NOAA water levels for a station and short date range.", {
|
|
28
|
+
station: z.string().min(3).describe("NOAA station id"),
|
|
29
|
+
begin: z.string().describe("YYYY-MM-DD"),
|
|
30
|
+
end: z.string().describe("YYYY-MM-DD"),
|
|
31
|
+
interval: z.enum(["6", "h"]).default("6"),
|
|
32
|
+
units: z.enum(["english", "metric"]).default("english")
|
|
33
|
+
}, async (a) => {
|
|
52
34
|
try {
|
|
53
|
-
return
|
|
35
|
+
return text(format(await waterLevels(a.station, a.begin, a.end, a.interval, a.units)));
|
|
54
36
|
}
|
|
55
37
|
catch (e) {
|
|
56
|
-
return
|
|
38
|
+
return fail(errorMessage(e));
|
|
57
39
|
}
|
|
58
40
|
});
|
|
59
|
-
server.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
inputSchema: z.object({ station: z.string().min(3).describe("NOAA station id, e.g. 9414290"), begin: z.string().describe("YYYY-MM-DD"), end: z.string().describe("YYYY-MM-DD"), units: z.enum(["english", "metric"]).default("english") }),
|
|
63
|
-
annotations: READ_ONLY,
|
|
64
|
-
}, async (args) => {
|
|
41
|
+
server.tool("list_stations", "List NOAA tide prediction stations, optionally by state.", {
|
|
42
|
+
state: z.string().length(2).optional().describe("Two-letter state code, e.g. NY")
|
|
43
|
+
}, async (a) => {
|
|
65
44
|
try {
|
|
66
|
-
return text(await
|
|
45
|
+
return text(await stationList(a));
|
|
67
46
|
}
|
|
68
47
|
catch (e) {
|
|
69
|
-
return
|
|
48
|
+
return fail(errorMessage(e));
|
|
70
49
|
}
|
|
71
50
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
server.registerTool("version_info", {
|
|
82
|
-
title: "Version info",
|
|
83
|
-
description: "Get server version and metadata.",
|
|
84
|
-
inputSchema: z.object({}),
|
|
85
|
-
annotations: READ_ONLY,
|
|
86
|
-
}, async () => {
|
|
87
|
-
return text(JSON.stringify({ name: serverName, version: "1.0.0" }, null, 2));
|
|
88
|
-
});
|
|
89
|
-
server.registerTool("list_tools", {
|
|
90
|
-
title: "List tools",
|
|
91
|
-
description: "List all available tools on this server.",
|
|
92
|
-
inputSchema: z.object({}),
|
|
93
|
-
annotations: READ_ONLY,
|
|
94
|
-
}, async () => {
|
|
95
|
-
return text("See the tools/list response for the full tool list.");
|
|
96
|
-
});
|
|
97
|
-
server.registerTool("echo", {
|
|
98
|
-
title: "Echo",
|
|
99
|
-
description: "Echo back the provided text.",
|
|
100
|
-
inputSchema: z.object({ text: z.string().describe("Text to echo.") }),
|
|
101
|
-
annotations: READ_ONLY,
|
|
102
|
-
}, async (args) => {
|
|
103
|
-
return text(String(args?.text ?? ""));
|
|
51
|
+
server.tool("station_metadata", "Station details for one NOAA tide gauge.", {
|
|
52
|
+
station: z.string().min(3).describe("NOAA station id, e.g. 8443970")
|
|
53
|
+
}, async (a) => {
|
|
54
|
+
try {
|
|
55
|
+
return text(await stationMetadata(a));
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
return fail(errorMessage(e));
|
|
59
|
+
}
|
|
104
60
|
});
|
|
105
|
-
server.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}, async () => {
|
|
111
|
-
|
|
61
|
+
server.tool("tide_range", "Highest, lowest and total tide range for a date window.", {
|
|
62
|
+
station: z.string().min(3).describe("NOAA station id"),
|
|
63
|
+
begin: z.string().describe("YYYY-MM-DD"),
|
|
64
|
+
end: z.string().describe("YYYY-MM-DD"),
|
|
65
|
+
units: z.enum(["english", "metric"]).default("english")
|
|
66
|
+
}, async (a) => {
|
|
67
|
+
try {
|
|
68
|
+
return text(await tideRange(a));
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
return fail(errorMessage(e));
|
|
72
|
+
}
|
|
112
73
|
});
|
|
113
74
|
return server;
|
|
114
75
|
}
|
|
115
|
-
export { TidesError };
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tides-mcp",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "MCP server for NOAA tides and currents predictions and water levels.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"mcpName": "io.github.mrfentmen/tides-mcp",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/mrfentmen/
|
|
9
|
+
"url": "git+https://github.com/mrfentmen/awesome-servers.git"
|
|
10
10
|
},
|
|
11
11
|
"bin": {
|
|
12
12
|
"tides-mcp": "./dist/index.js"
|
|
@@ -35,8 +35,5 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^22.0.0",
|
|
37
37
|
"typescript": "^5.6.0"
|
|
38
|
-
},
|
|
39
|
-
"engines": {
|
|
40
|
-
"node": ">=20"
|
|
41
38
|
}
|
|
42
39
|
}
|
package/server.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
3
|
"name": "io.github.mrfentmen/tides-mcp",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "MCP server for NOAA tides and currents predictions and water levels.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/mrfentmen/tides-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.4",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "tides-mcp",
|
|
14
|
-
"version": "1.0.
|
|
14
|
+
"version": "1.0.4",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
}
|