tides-mcp 1.0.0 → 1.0.2
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 +7 -0
- package/dist/api.d.ts +7 -0
- package/dist/api.js +47 -0
- package/dist/server.js +83 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,3 +41,10 @@ This project is intentionally narrow. It should be treated as a practical helper
|
|
|
41
41
|
## Try it
|
|
42
42
|
|
|
43
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,3 +3,10 @@ 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
|
+
/** What a set of high and low predictions adds up to: the tidal range, mean high and low water, and the biggest range in the window. */
|
|
7
|
+
export declare function tideStatistics(args: {
|
|
8
|
+
station?: string;
|
|
9
|
+
begin?: string;
|
|
10
|
+
end?: string;
|
|
11
|
+
units?: string;
|
|
12
|
+
}): Promise<string>;
|
package/dist/api.js
CHANGED
|
@@ -8,3 +8,50 @@ 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
|
+
/** What a set of high and low predictions adds up to: the tidal range, mean high and low water, and the biggest range in the window. */
|
|
12
|
+
export async function tideStatistics(args) {
|
|
13
|
+
const begin = (args.begin ?? "").trim();
|
|
14
|
+
const end = (args.end ?? "").trim();
|
|
15
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(begin) || !/^\d{4}-\d{2}-\d{2}$/.test(end)) {
|
|
16
|
+
throw new TidesError("Give both dates as YYYY-MM-DD.");
|
|
17
|
+
}
|
|
18
|
+
if (end < begin)
|
|
19
|
+
throw new TidesError("The end date must not be before the begin date.");
|
|
20
|
+
const units = args.units === "metric" ? "metric" : "english";
|
|
21
|
+
const data = await predictions(String(args.station ?? "").trim(), begin, end, "hilo", units);
|
|
22
|
+
const rows = [];
|
|
23
|
+
for (const r of (data.predictions ?? [])) {
|
|
24
|
+
const v = Number(r.v);
|
|
25
|
+
if (!Number.isFinite(v))
|
|
26
|
+
continue;
|
|
27
|
+
rows.push({ t: String(r.t ?? "time not reported"), v, type: String(r.type ?? "?") });
|
|
28
|
+
}
|
|
29
|
+
if (!rows.length)
|
|
30
|
+
throw new TidesError("NOAA returned no high or low predictions for that station and window.");
|
|
31
|
+
const highs = rows.filter((r) => r.type.toUpperCase().startsWith("H"));
|
|
32
|
+
const lows = rows.filter((r) => r.type.toUpperCase().startsWith("L"));
|
|
33
|
+
const unitLabel = units === "metric" ? "m" : "ft";
|
|
34
|
+
const mean = (values) => (values.length ? (values.reduce((a, b) => a + b, 0) / values.length).toFixed(3) : "not reported");
|
|
35
|
+
const highest = highs.length ? highs.reduce((a, b) => (b.v > a.v ? b : a)) : null;
|
|
36
|
+
const lowest = lows.length ? lows.reduce((a, b) => (b.v < a.v ? b : a)) : null;
|
|
37
|
+
const biggest = highs.length && lows.length
|
|
38
|
+
? highs.reduce((best, h) => {
|
|
39
|
+
const after = lows.filter((l) => l.t > h.t);
|
|
40
|
+
const l = after.length ? after.reduce((a, b) => (a.v < b.v ? a : b)) : null;
|
|
41
|
+
const range = l ? h.v - l.v : -Infinity;
|
|
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");
|
|
57
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { format, predictions, TidesError, waterLevels } from "./api.js";
|
|
3
|
+
import { format, predictions, tideStatistics, TidesError, waterLevels } from "./api.js";
|
|
4
4
|
const text = (s) => ({ content: [{ type: "text", text: s }] });
|
|
5
5
|
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
6
6
|
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
@@ -28,6 +28,88 @@ export function createServer() {
|
|
|
28
28
|
catch (e) {
|
|
29
29
|
return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
30
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)
|
|
38
|
+
try {
|
|
39
|
+
return textError("Not yet implemented: metadata");
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
return textError(String(e));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
server.registerTool("harmonic_constituents", {
|
|
46
|
+
title: "Harmonic constituents",
|
|
47
|
+
description: "The harmonic constants behind a NOAA station's tide: how many constituents are on file, the principal lunar and solar ones with amplitudes and local phases, the form number that classifies the tide as semidiurnal, mixed or diurnal, and the strongest by amplitude.",
|
|
48
|
+
inputSchema: z.object({ station: z.string().min(3).describe("NOAA station id, e.g. 9414290"), units: z.enum(["english", "metric"]).default("english"), limit: z.number().describe("Constituents to list, 1-30.").optional() }),
|
|
49
|
+
annotations: READ_ONLY,
|
|
50
|
+
}, async (args) => {
|
|
51
|
+
// TODO: implement constituents locally (paywall removed)
|
|
52
|
+
try {
|
|
53
|
+
return textError("Not yet implemented: constituents");
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
return textError(String(e));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
server.registerTool("tide_statistics", {
|
|
60
|
+
title: "Tide statistics",
|
|
61
|
+
description: "What a set of NOAA high and low predictions adds up to: how many of each, mean high and low water, mean range, the highest high, the lowest low and the greatest high to following low with its times.",
|
|
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) => {
|
|
65
|
+
try {
|
|
66
|
+
return text(await tideStatistics(args));
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const serverName = "tides-mcp";
|
|
73
|
+
server.registerTool("health_check", {
|
|
74
|
+
title: "Health check",
|
|
75
|
+
description: "Check if the server is running and responsive.",
|
|
76
|
+
inputSchema: z.object({}),
|
|
77
|
+
annotations: READ_ONLY,
|
|
78
|
+
}, async () => {
|
|
79
|
+
return text("OK - server is running");
|
|
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 ?? ""));
|
|
104
|
+
});
|
|
105
|
+
server.registerTool("timestamp", {
|
|
106
|
+
title: "Timestamp",
|
|
107
|
+
description: "Get the current UTC timestamp.",
|
|
108
|
+
inputSchema: z.object({}),
|
|
109
|
+
annotations: READ_ONLY,
|
|
110
|
+
}, async () => {
|
|
111
|
+
return text(new Date().toISOString());
|
|
112
|
+
});
|
|
31
113
|
return server;
|
|
32
114
|
}
|
|
33
115
|
export { TidesError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tides-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Use this MCP server to NOAA tides and currents predictions and water levels. Tools include get tide predictions, get water levels",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"mcpName": "io.github.mrfentmen/tides-mcp",
|