tides-mcp 1.0.2 → 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 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
- /** 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;
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
- /** 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
- }
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
- 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");
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
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
2
3
  import { createServer } from "./server.js";
3
4
  async function main() {
package/dist/server.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { TidesError } from "./api.js";
3
2
  export declare function createServer(): McpServer;
4
- export { TidesError };
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, tideStatistics, TidesError, waterLevels } from "./api.js";
3
+ import { format, predictions, stationList, stationMetadata, tideRange, TidesError, waterLevels } from "./api.js";
4
4
  const text = (s) => ({ content: [{ type: "text", text: s }] });
5
- const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
6
- const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
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.0" });
9
- server.registerTool("get_tide_predictions", {
10
- title: "Get tide predictions",
11
- description: "Get NOAA high low or hourly tide predictions for a station and date range.",
12
- inputSchema: z.object({ station: z.string().min(3), begin: z.string().describe("YYYY-MM-DD"), end: z.string().describe("YYYY-MM-DD"), interval: z.enum(["hilo", "h"]).default("hilo"), units: z.enum(["english", "metric"]).default("english") }),
13
- annotations: READ_ONLY,
14
- }, async ({ station, begin, end, interval, units }) => { try {
15
- return text(format(await predictions(station, begin, end, interval, units)));
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 textError("Not yet implemented: metadata");
21
+ return text(format(await predictions(a.station, a.begin, a.end, a.interval, a.units)));
40
22
  }
41
23
  catch (e) {
42
- return textError(String(e));
24
+ return fail(errorMessage(e));
43
25
  }
44
26
  });
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)
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 textError("Not yet implemented: constituents");
35
+ return text(format(await waterLevels(a.station, a.begin, a.end, a.interval, a.units)));
54
36
  }
55
37
  catch (e) {
56
- return textError(String(e));
38
+ return fail(errorMessage(e));
57
39
  }
58
40
  });
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) => {
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 tideStatistics(args));
45
+ return text(await stationList(a));
67
46
  }
68
47
  catch (e) {
69
- return textError(`Error: ${e instanceof Error ? e.message : String(e)}`);
48
+ return fail(errorMessage(e));
70
49
  }
71
50
  });
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 ?? ""));
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.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());
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.2",
4
- "description": "Use this MCP server to NOAA tides and currents predictions and water levels. Tools include get tide predictions, get water levels",
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/tides-mcp.git"
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": "Use this MCP server to NOAA tides and currents predictions and water levels. Tools include get...",
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.0",
9
+ "version": "1.0.3",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "tides-mcp",
14
- "version": "1.0.0",
14
+ "version": "1.0.3",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  }