tides-mcp 1.0.1 → 1.0.3
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 -42
- package/dist/api.d.ts +9 -14
- package/dist/api.js +49 -128
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server.d.ts +0 -2
- package/dist/server.js +54 -62
- package/package.json +3 -6
- package/server.json +3 -3
- package/dist/license.d.ts +0 -8
- package/dist/license.js +0 -79
package/README.md
CHANGED
|
@@ -18,45 +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
|
-
<!-- paywall -->
|
|
46
|
-
## Premium tools
|
|
47
|
-
|
|
48
|
-
These tools need a license key:
|
|
49
|
-
|
|
50
|
-
* `station_metadata`
|
|
51
|
-
* `harmonic_constituents`
|
|
52
|
-
|
|
53
|
-
Buy a key at https://mcp-marketplace.io/server/io-github-mrfentmen-tides-mcp and set it in your MCP client config:
|
|
54
|
-
|
|
55
|
-
```json
|
|
56
|
-
"env": { "MCP_LICENSE_KEY": "mcp_live_..." }
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
The key is checked against MCP Marketplace, cached for 24 hours, and keeps
|
|
60
|
-
working offline once one check has succeeded. Every other tool on this server
|
|
61
|
-
stays free.
|
|
62
|
-
<!-- /paywall -->
|
package/dist/api.d.ts
CHANGED
|
@@ -3,20 +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
|
-
station?: string;
|
|
6
|
+
export declare function stationList(a: {
|
|
7
|
+
state?: string;
|
|
9
8
|
}): Promise<string>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
station?: string;
|
|
13
|
-
units?: string;
|
|
14
|
-
limit?: number;
|
|
9
|
+
export declare function stationMetadata(a: {
|
|
10
|
+
station: string;
|
|
15
11
|
}): Promise<string>;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
units?: string;
|
|
12
|
+
export declare function tideRange(a: {
|
|
13
|
+
station: string;
|
|
14
|
+
begin: string;
|
|
15
|
+
end: string;
|
|
16
|
+
units: string;
|
|
22
17
|
}): Promise<string>;
|
package/dist/api.js
CHANGED
|
@@ -8,137 +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
|
-
|
|
14
|
-
const res = await fetch(url, { headers: HEADERS, signal: AbortSignal.timeout(20000) });
|
|
15
|
-
if (res.status === 404)
|
|
16
|
-
throw new TidesError("NOAA has no record at that address.");
|
|
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) });
|
|
17
14
|
if (!res.ok)
|
|
18
|
-
throw new TidesError(`NOAA error ${res.status}`);
|
|
19
|
-
|
|
20
|
-
if (data?.error)
|
|
21
|
-
throw new TidesError(data.error.message ?? "NOAA returned an error");
|
|
22
|
-
return data;
|
|
15
|
+
throw new TidesError(`NOAA metadata error ${res.status}`);
|
|
16
|
+
return res.json();
|
|
23
17
|
}
|
|
24
|
-
function
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
function yesNo(value) {
|
|
31
|
-
if (value === undefined)
|
|
32
|
-
return "not reported";
|
|
33
|
-
return value ? "yes" : "no";
|
|
34
|
-
}
|
|
35
|
-
/** What a NOAA station is and what it publishes: identity, position, tide type, and the product families it carries. */
|
|
36
|
-
export async function stationMetadata(args) {
|
|
37
|
-
const id = clean(args.station ?? "");
|
|
38
|
-
const data = await metaGet(`${METADATA}/${encodeURIComponent(id)}.json`);
|
|
39
|
-
const s = data.stations?.[0];
|
|
40
|
-
if (!s)
|
|
41
|
-
throw new TidesError(`NOAA has no station with id ${id}.`);
|
|
42
|
-
const products = [
|
|
43
|
-
["Tide predictions", yesNo(s.forecast)],
|
|
44
|
-
["Observed water levels", yesNo(s.observedst)],
|
|
45
|
-
["Flood levels", yesNo(s.floodlevels)],
|
|
46
|
-
["Inundation database", yesNo(s.inundationdb)],
|
|
47
|
-
["Storm surge outlooks", yesNo(s.outlook)],
|
|
48
|
-
["Storm surge products", yesNo(s.stormsurge)],
|
|
49
|
-
["Historical tide factors", yesNo(s.HTFhistorical)],
|
|
50
|
-
["Monthly mean tides", yesNo(s.HTFmonthly)],
|
|
51
|
-
];
|
|
52
|
-
const available = products.filter(([, v]) => v === "yes").map(([k]) => k);
|
|
53
|
-
return [
|
|
54
|
-
`NOAA station ${s.id ?? id}: ${s.name ?? "name not reported"}${s.state ? `, ${s.state}` : ""}`,
|
|
55
|
-
`Position: ${s.lat === undefined ? "not reported" : s.lat}, ${s.lng === undefined ? "not reported" : s.lng}`,
|
|
56
|
-
`Tidal station: ${yesNo(s.tidal)}${s.greatlakes ? " (Great Lakes station)" : ""}`,
|
|
57
|
-
`Tide type: ${s.tideType ?? "not reported"}`,
|
|
58
|
-
`Local time zone: ${s.timezone ?? "not reported"}${s.timezonecorr === undefined ? "" : ` (offset ${s.timezonecorr} hours from GMT)`}`,
|
|
59
|
-
`SHEF code: ${s.shefcode ?? "not reported"}`,
|
|
60
|
-
`Port code: ${s.portscode ? s.portscode : "none reported"}`,
|
|
61
|
-
`Affiliations: ${s.affiliations ? s.affiliations : "none reported"}`,
|
|
62
|
-
`Marked non-navigational: ${yesNo(s.nonNavigational)}`,
|
|
63
|
-
`Data product families published (${available.length} of ${products.length}): ${available.join(", ") || "none reported"}`,
|
|
64
|
-
].join("\n");
|
|
65
|
-
}
|
|
66
|
-
/** The harmonic constants behind a station's tide: which constituents dominate, and whether the tide is semidiurnal, mixed or diurnal. */
|
|
67
|
-
export async function harmonicConstituents(args) {
|
|
68
|
-
const id = clean(args.station ?? "");
|
|
69
|
-
const units = args.units === "metric" ? "metric" : "english";
|
|
70
|
-
const limit = Math.max(1, Math.min(Math.floor(args.limit ?? 10), 30));
|
|
71
|
-
const data = await metaGet(`${METADATA}/${encodeURIComponent(id)}/harcon.json?units=${units}`);
|
|
72
|
-
const rows = data.HarmonicConstituents ?? [];
|
|
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;
|
|
73
23
|
if (!rows.length)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return [
|
|
87
|
-
`
|
|
88
|
-
`
|
|
89
|
-
`
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
`
|
|
94
|
-
...ranked.slice(0, limit).map((c) => `- ${c.name ?? "unnamed"}: ${c.amplitude === undefined ? "amplitude not reported" : c.amplitude} ${unitLabel}, local phase ${c.phase_local ?? "not reported"} degrees, speed ${c.speed ?? "not reported"} deg/h, ${c.description ?? "no description"}`),
|
|
95
|
-
ranked.length > limit ? `... and ${ranked.length - limit} more constituent(s).` : "",
|
|
96
|
-
].filter(Boolean).join("\n");
|
|
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");
|
|
97
44
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
if (end < begin)
|
|
106
|
-
throw new TidesError("The end date must not be before the begin date.");
|
|
107
|
-
const units = args.units === "metric" ? "metric" : "english";
|
|
108
|
-
const data = await predictions(String(args.station ?? "").trim(), begin, end, "hilo", units);
|
|
109
|
-
const rows = [];
|
|
110
|
-
for (const r of (data.predictions ?? [])) {
|
|
111
|
-
const v = Number(r.v);
|
|
112
|
-
if (!Number.isFinite(v))
|
|
113
|
-
continue;
|
|
114
|
-
rows.push({ t: String(r.t ?? "time not reported"), v, type: String(r.type ?? "?") });
|
|
115
|
-
}
|
|
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 : [];
|
|
116
51
|
if (!rows.length)
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return range > best.range ? { high: h, low: l, range } : best;
|
|
130
|
-
}, { high: null, low: null, range: -Infinity })
|
|
131
|
-
: { high: null, low: null, range: -Infinity };
|
|
132
|
-
return [
|
|
133
|
-
`Tide statistics for station ${String(args.station ?? "").trim()} from ${begin} to ${end}, in ${unitLabel}`,
|
|
134
|
-
`Predictions returned: ${rows.length} (${highs.length} high, ${lows.length} low)`,
|
|
135
|
-
`Mean high water: ${mean(highs.map((r) => r.v))} ${unitLabel}`,
|
|
136
|
-
`Mean low water: ${mean(lows.map((r) => r.v))} ${unitLabel}`,
|
|
137
|
-
`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"}`,
|
|
138
|
-
`Highest high: ${highest ? `${highest.v} ${unitLabel} at ${highest.t}` : "no high in the window"}`,
|
|
139
|
-
`Lowest low: ${lowest ? `${lowest.v} ${unitLabel} at ${lowest.t}` : "no low in the window"}`,
|
|
140
|
-
biggest.range > -Infinity && biggest.high && biggest.low
|
|
141
|
-
? `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}`
|
|
142
|
-
: "Greatest high to following low: not computable, the window has no matched high and low pair.",
|
|
143
|
-
].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");
|
|
144
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,83 +1,75 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { format,
|
|
4
|
-
import { premiumRequired } from "./license.js";
|
|
3
|
+
import { format, predictions, stationList, stationMetadata, tideRange, TidesError, waterLevels } from "./api.js";
|
|
5
4
|
const text = (s) => ({ content: [{ type: "text", text: s }] });
|
|
6
|
-
const
|
|
7
|
-
|
|
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
|
+
}
|
|
8
11
|
export function createServer() {
|
|
9
|
-
const server = new McpServer({ name: "tides-mcp", version: "1.0.
|
|
10
|
-
server.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
42
|
-
// ---- paywall: end ----
|
|
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) => {
|
|
20
|
+
try {
|
|
21
|
+
return text(format(await predictions(a.station, a.begin, a.end, a.interval, a.units)));
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
return fail(errorMessage(e));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
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) => {
|
|
34
|
+
try {
|
|
35
|
+
return text(format(await waterLevels(a.station, a.begin, a.end, a.interval, a.units)));
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
return fail(errorMessage(e));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
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) => {
|
|
43
44
|
try {
|
|
44
|
-
return text(await
|
|
45
|
+
return text(await stationList(a));
|
|
45
46
|
}
|
|
46
47
|
catch (e) {
|
|
47
|
-
return
|
|
48
|
+
return fail(errorMessage(e));
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
|
-
server.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
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() }),
|
|
54
|
-
annotations: READ_ONLY,
|
|
55
|
-
}, async (args) => {
|
|
56
|
-
// ---- paywall: harmonic_constituents ----
|
|
57
|
-
const paywallMessage = await premiumRequired("harmonic_constituents");
|
|
58
|
-
if (paywallMessage)
|
|
59
|
-
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
60
|
-
// ---- paywall: end ----
|
|
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) => {
|
|
61
54
|
try {
|
|
62
|
-
return text(await
|
|
55
|
+
return text(await stationMetadata(a));
|
|
63
56
|
}
|
|
64
57
|
catch (e) {
|
|
65
|
-
return
|
|
58
|
+
return fail(errorMessage(e));
|
|
66
59
|
}
|
|
67
60
|
});
|
|
68
|
-
server.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, async (
|
|
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) => {
|
|
74
67
|
try {
|
|
75
|
-
return text(await
|
|
68
|
+
return text(await tideRange(a));
|
|
76
69
|
}
|
|
77
70
|
catch (e) {
|
|
78
|
-
return
|
|
71
|
+
return fail(errorMessage(e));
|
|
79
72
|
}
|
|
80
73
|
});
|
|
81
74
|
return server;
|
|
82
75
|
}
|
|
83
|
-
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.3",
|
|
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.3",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "tides-mcp",
|
|
14
|
-
"version": "1.0.
|
|
14
|
+
"version": "1.0.3",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
}
|
package/dist/license.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns null when the caller may run the tool, or a short message telling
|
|
3
|
-
* them how to get a key.
|
|
4
|
-
*
|
|
5
|
-
* A good key is remembered for an hour, so a busy session does not hit the
|
|
6
|
-
* license server on every call and keeps working through a brief outage.
|
|
7
|
-
*/
|
|
8
|
-
export declare function premiumRequired(tool: string): Promise<string | null>;
|
package/dist/license.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// Premium tools on this server need a license key bought from MCP Marketplace.
|
|
2
|
-
// Buyers put the key in their MCP client config as MCP_LICENSE_KEY. Every tool
|
|
3
|
-
// that is not listed in PREMIUM keeps working without a key.
|
|
4
|
-
const SLUG = "tides-mcp";
|
|
5
|
-
// Tools that need a key. Everything else is free.
|
|
6
|
-
const PREMIUM = new Set([
|
|
7
|
-
"station_metadata",
|
|
8
|
-
"harmonic_constituents",
|
|
9
|
-
]);
|
|
10
|
-
const BUY_URL = `https://mcp-marketplace.io/server/io-github-mrfentmen-${SLUG}`;
|
|
11
|
-
// The license check calls the marketplace's verify endpoint directly instead of
|
|
12
|
-
// using @mcp_marketplace/license. That SDK sends no `apikey` header, so every
|
|
13
|
-
// check it makes is rejected by Supabase before it reaches the function. The
|
|
14
|
-
// publishable key below is public by design - it ships in mcp-marketplace.io's
|
|
15
|
-
// own JavaScript and only ever reaches their licence check.
|
|
16
|
-
const DEFAULT_VERIFY_URL = "https://virupvwhtkpkjsiskckg.supabase.co/functions/v1/verify-key";
|
|
17
|
-
const PUBLISHABLE_KEY = "sb_publishable_BuqlW96Ke8C_zzJG-LQv1Q_YHi_r_4h";
|
|
18
|
-
const OK_CACHE_MS = 60 * 60 * 1000;
|
|
19
|
-
const BAD_CACHE_MS = 60 * 1000;
|
|
20
|
-
const seen = new Map();
|
|
21
|
-
const REASONS = {
|
|
22
|
-
missing_key: "no key is set",
|
|
23
|
-
invalid_format: "that key is not a valid MCP Marketplace key",
|
|
24
|
-
not_found: "that key was not found",
|
|
25
|
-
revoked: "that key has been revoked",
|
|
26
|
-
rotated: "that key was rotated, use your new one",
|
|
27
|
-
expired: "that key has expired, renew it",
|
|
28
|
-
rate_limited: "there were too many checks just now, try again shortly",
|
|
29
|
-
network_error: "the license server could not be reached",
|
|
30
|
-
};
|
|
31
|
-
function blocked(tool, reason) {
|
|
32
|
-
const why = REASONS[reason] ?? `the license server answered "${reason}"`;
|
|
33
|
-
return `"${tool}" needs a license key, but ${why}. ` +
|
|
34
|
-
`Set MCP_LICENSE_KEY in your MCP client config. Get a key: ${BUY_URL}`;
|
|
35
|
-
}
|
|
36
|
-
async function verify(key) {
|
|
37
|
-
const res = await fetch(process.env.MCP_LICENSE_VERIFY_URL || DEFAULT_VERIFY_URL, {
|
|
38
|
-
method: "POST",
|
|
39
|
-
headers: {
|
|
40
|
-
apikey: PUBLISHABLE_KEY,
|
|
41
|
-
Authorization: `Bearer ${PUBLISHABLE_KEY}`,
|
|
42
|
-
"Content-Type": "application/json",
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify({ key, slug: SLUG }),
|
|
45
|
-
// an unusable key answers 400 with a JSON body, so read the body either way
|
|
46
|
-
signal: AbortSignal.timeout(15000),
|
|
47
|
-
});
|
|
48
|
-
const data = (await res.json());
|
|
49
|
-
if (typeof data?.valid !== "boolean")
|
|
50
|
-
return { valid: false, reason: "unexpected_response" };
|
|
51
|
-
return data;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Returns null when the caller may run the tool, or a short message telling
|
|
55
|
-
* them how to get a key.
|
|
56
|
-
*
|
|
57
|
-
* A good key is remembered for an hour, so a busy session does not hit the
|
|
58
|
-
* license server on every call and keeps working through a brief outage.
|
|
59
|
-
*/
|
|
60
|
-
export async function premiumRequired(tool) {
|
|
61
|
-
if (!PREMIUM.has(tool))
|
|
62
|
-
return null;
|
|
63
|
-
const key = process.env.MCP_LICENSE_KEY;
|
|
64
|
-
if (!key)
|
|
65
|
-
return blocked(tool, "missing_key");
|
|
66
|
-
const hit = seen.get(key);
|
|
67
|
-
if (hit && Date.now() - hit.at < (hit.valid ? OK_CACHE_MS : BAD_CACHE_MS)) {
|
|
68
|
-
return hit.valid ? null : blocked(tool, hit.reason ?? "invalid");
|
|
69
|
-
}
|
|
70
|
-
let result;
|
|
71
|
-
try {
|
|
72
|
-
result = await verify(key);
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
result = { valid: false, reason: "network_error" };
|
|
76
|
-
}
|
|
77
|
-
seen.set(key, { ...result, at: Date.now() });
|
|
78
|
-
return result.valid ? null : blocked(tool, result.reason ?? "invalid");
|
|
79
|
-
}
|