tides-mcp 1.0.0 → 1.0.1
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 +19 -0
- package/dist/api.d.ts +17 -0
- package/dist/api.js +134 -0
- package/dist/license.d.ts +8 -0
- package/dist/license.js +79 -0
- package/dist/server.js +51 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,3 +41,22 @@ 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
|
+
<!-- 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,3 +3,20 @@ 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 NOAA station is and what it publishes: identity, position, tide type, and the product families it carries. */
|
|
7
|
+
export declare function stationMetadata(args: {
|
|
8
|
+
station?: string;
|
|
9
|
+
}): Promise<string>;
|
|
10
|
+
/** The harmonic constants behind a station's tide: which constituents dominate, and whether the tide is semidiurnal, mixed or diurnal. */
|
|
11
|
+
export declare function harmonicConstituents(args: {
|
|
12
|
+
station?: string;
|
|
13
|
+
units?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
}): Promise<string>;
|
|
16
|
+
/** 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. */
|
|
17
|
+
export declare function tideStatistics(args: {
|
|
18
|
+
station?: string;
|
|
19
|
+
begin?: string;
|
|
20
|
+
end?: string;
|
|
21
|
+
units?: string;
|
|
22
|
+
}): Promise<string>;
|
package/dist/api.js
CHANGED
|
@@ -8,3 +8,137 @@ 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
|
+
// ---- muxF tools:
|
|
12
|
+
const METADATA = "https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/stations";
|
|
13
|
+
async function metaGet(url) {
|
|
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.");
|
|
17
|
+
if (!res.ok)
|
|
18
|
+
throw new TidesError(`NOAA error ${res.status}`);
|
|
19
|
+
const data = (await res.json());
|
|
20
|
+
if (data?.error)
|
|
21
|
+
throw new TidesError(data.error.message ?? "NOAA returned an error");
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function clean(station) {
|
|
25
|
+
const value = (station ?? "").trim();
|
|
26
|
+
if (!/^[A-Za-z0-9]{7,12}$/.test(value))
|
|
27
|
+
throw new TidesError(`Not a NOAA station id: "${station}". Use the 7 or 8 digit station number.`);
|
|
28
|
+
return value;
|
|
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 ?? [];
|
|
73
|
+
if (!rows.length)
|
|
74
|
+
throw new TidesError(`NOAA publishes no harmonic constituents for station ${id}.`);
|
|
75
|
+
const unitLabel = data.units === "metric" ? "metres" : "feet";
|
|
76
|
+
const byName = new Map(rows.map((r) => [String(r.name ?? ""), r]));
|
|
77
|
+
const amplitude = (name) => Number(byName.get(name)?.amplitude ?? 0);
|
|
78
|
+
const m2 = amplitude("M2");
|
|
79
|
+
const s2 = amplitude("S2");
|
|
80
|
+
const k1 = amplitude("K1");
|
|
81
|
+
const o1 = amplitude("O1");
|
|
82
|
+
const form = m2 + s2 > 0 ? (k1 + o1) / (m2 + s2) : NaN;
|
|
83
|
+
const kind = !Number.isFinite(form) ? "not classifiable, no semidiurnal energy reported" : form < 0.5 ? "predominantly semidiurnal" : form <= 2 ? "mixed mainly semidiurnal" : "predominantly diurnal";
|
|
84
|
+
const ranked = [...rows].sort((a, b) => (Number(b.amplitude) || 0) - (Number(a.amplitude) || 0));
|
|
85
|
+
const principal = ["M2", "S2", "K1", "O1"].filter((n) => byName.has(n));
|
|
86
|
+
return [
|
|
87
|
+
`Harmonic constituents at NOAA station ${id}, amplitudes in ${unitLabel}`,
|
|
88
|
+
`Constituents on file: ${rows.length}`,
|
|
89
|
+
`Form number F = (K1+O1)/(M2+S2) = ${Number.isFinite(form) ? form.toFixed(3) : "not reported"}, so the tide is ${kind}`,
|
|
90
|
+
principal.length
|
|
91
|
+
? `Principal constituents: ${principal.map((n) => `${n} ${amplitude(n)} ${unitLabel} at local phase ${byName.get(n)?.phase_local ?? "not reported"} degrees`).join("; ")}`
|
|
92
|
+
: "Principal constituents: none of M2, S2, K1 or O1 are on file for this station.",
|
|
93
|
+
`Strongest ${Math.min(limit, ranked.length)} by amplitude:`,
|
|
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");
|
|
97
|
+
}
|
|
98
|
+
/** 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. */
|
|
99
|
+
export async function tideStatistics(args) {
|
|
100
|
+
const begin = (args.begin ?? "").trim();
|
|
101
|
+
const end = (args.end ?? "").trim();
|
|
102
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(begin) || !/^\d{4}-\d{2}-\d{2}$/.test(end)) {
|
|
103
|
+
throw new TidesError("Give both dates as YYYY-MM-DD.");
|
|
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
|
+
}
|
|
116
|
+
if (!rows.length)
|
|
117
|
+
throw new TidesError("NOAA returned no high or low predictions for that station and window.");
|
|
118
|
+
const highs = rows.filter((r) => r.type.toUpperCase().startsWith("H"));
|
|
119
|
+
const lows = rows.filter((r) => r.type.toUpperCase().startsWith("L"));
|
|
120
|
+
const unitLabel = units === "metric" ? "m" : "ft";
|
|
121
|
+
const mean = (values) => (values.length ? (values.reduce((a, b) => a + b, 0) / values.length).toFixed(3) : "not reported");
|
|
122
|
+
const highest = highs.length ? highs.reduce((a, b) => (b.v > a.v ? b : a)) : null;
|
|
123
|
+
const lowest = lows.length ? lows.reduce((a, b) => (b.v < a.v ? b : a)) : null;
|
|
124
|
+
const biggest = highs.length && lows.length
|
|
125
|
+
? highs.reduce((best, h) => {
|
|
126
|
+
const after = lows.filter((l) => l.t > h.t);
|
|
127
|
+
const l = after.length ? after.reduce((a, b) => (a.v < b.v ? a : b)) : null;
|
|
128
|
+
const range = l ? h.v - l.v : -Infinity;
|
|
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");
|
|
144
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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, harmonicConstituents, predictions, stationMetadata, tideStatistics, TidesError, waterLevels } from "./api.js";
|
|
4
|
+
import { premiumRequired } from "./license.js";
|
|
4
5
|
const text = (s) => ({ content: [{ type: "text", text: s }] });
|
|
5
6
|
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
6
7
|
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
@@ -28,6 +29,55 @@ export function createServer() {
|
|
|
28
29
|
catch (e) {
|
|
29
30
|
return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
30
31
|
} });
|
|
32
|
+
server.registerTool("station_metadata", {
|
|
33
|
+
title: "Station metadata",
|
|
34
|
+
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.",
|
|
35
|
+
inputSchema: z.object({ station: z.string().min(3).describe("NOAA station id, 7 or 8 digits, e.g. 9414290") }),
|
|
36
|
+
annotations: READ_ONLY,
|
|
37
|
+
}, async (args) => {
|
|
38
|
+
// ---- paywall: station_metadata ----
|
|
39
|
+
const paywallMessage = await premiumRequired("station_metadata");
|
|
40
|
+
if (paywallMessage)
|
|
41
|
+
return { content: [{ type: "text", text: paywallMessage }], isError: true };
|
|
42
|
+
// ---- paywall: end ----
|
|
43
|
+
try {
|
|
44
|
+
return text(await stationMetadata(args));
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
server.registerTool("harmonic_constituents", {
|
|
51
|
+
title: "Harmonic constituents",
|
|
52
|
+
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.",
|
|
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 ----
|
|
61
|
+
try {
|
|
62
|
+
return text(await harmonicConstituents(args));
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
server.registerTool("tide_statistics", {
|
|
69
|
+
title: "Tide statistics",
|
|
70
|
+
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.",
|
|
71
|
+
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") }),
|
|
72
|
+
annotations: READ_ONLY,
|
|
73
|
+
}, async (args) => {
|
|
74
|
+
try {
|
|
75
|
+
return text(await tideStatistics(args));
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
31
81
|
return server;
|
|
32
82
|
}
|
|
33
83
|
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.1",
|
|
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",
|