tides-mcp 1.0.1 → 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 CHANGED
@@ -42,21 +42,9 @@ This project is intentionally narrow. It should be treated as a practical helper
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
44
 
45
- <!-- paywall -->
46
- ## Premium tools
45
+ ## Licence — no paywall
47
46
 
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 -->
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,16 +3,6 @@ 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
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. */
17
7
  export declare function tideStatistics(args: {
18
8
  station?: string;
package/dist/api.js CHANGED
@@ -8,93 +8,6 @@ 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
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. */
99
12
  export async function tideStatistics(args) {
100
13
  const begin = (args.begin ?? "").trim();
package/dist/server.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { z } from "zod";
3
- import { format, harmonicConstituents, predictions, stationMetadata, tideStatistics, TidesError, waterLevels } from "./api.js";
4
- import { premiumRequired } from "./license.js";
3
+ import { format, predictions, tideStatistics, TidesError, waterLevels } from "./api.js";
5
4
  const text = (s) => ({ content: [{ type: "text", text: s }] });
6
5
  const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
7
6
  const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
@@ -35,16 +34,12 @@ export function createServer() {
35
34
  inputSchema: z.object({ station: z.string().min(3).describe("NOAA station id, 7 or 8 digits, e.g. 9414290") }),
36
35
  annotations: READ_ONLY,
37
36
  }, 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 ----
37
+ // TODO: implement metadata locally (paywall removed)
43
38
  try {
44
- return text(await stationMetadata(args));
39
+ return textError("Not yet implemented: metadata");
45
40
  }
46
41
  catch (e) {
47
- return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
42
+ return textError(String(e));
48
43
  }
49
44
  });
50
45
  server.registerTool("harmonic_constituents", {
@@ -53,16 +48,12 @@ export function createServer() {
53
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() }),
54
49
  annotations: READ_ONLY,
55
50
  }, 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
+ // TODO: implement constituents locally (paywall removed)
61
52
  try {
62
- return text(await harmonicConstituents(args));
53
+ return textError("Not yet implemented: constituents");
63
54
  }
64
55
  catch (e) {
65
- return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
56
+ return textError(String(e));
66
57
  }
67
58
  });
68
59
  server.registerTool("tide_statistics", {
@@ -78,6 +69,47 @@ export function createServer() {
78
69
  return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
79
70
  }
80
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
+ });
81
113
  return server;
82
114
  }
83
115
  export { TidesError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tides-mcp",
3
- "version": "1.0.1",
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",
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
- }