baycheck-mcp 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/dist/server.js +19 -1
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -163,6 +163,21 @@ const STATE_NAMES = {
163
163
  WV: "west virginia",
164
164
  WY: "wyoming"
165
165
  };
166
+ function normalize(text) {
167
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
168
+ }
169
+ function matchTier(s, tokens) {
170
+ const stateWords = /* @__PURE__ */ new Set([s.state.toLowerCase(), ...(STATE_NAMES[s.state.toUpperCase()] ?? "").split(" ")]);
171
+ const placeTokens = tokens.filter((t) => !stateWords.has(t));
172
+ const phrase = normalize(placeTokens.join(" "));
173
+ if (!phrase) return 3;
174
+ const name = normalize(s.name);
175
+ const mainPlace = normalize(s.name.split(/[,(]/)[0]);
176
+ if (mainPlace === phrase) return 0;
177
+ if (name === phrase || name.startsWith(`${phrase} `)) return 1;
178
+ if (` ${name} `.includes(` ${phrase} `)) return 2;
179
+ return 3;
180
+ }
166
181
  function search(stations, query) {
167
182
  const tokens = query.toLowerCase().split(/\s+/).filter(Boolean);
168
183
  if (tokens.length === 0) return [];
@@ -173,7 +188,10 @@ function search(stations, query) {
173
188
  const haystack = `${s.name} ${s.state} ${stateName}`.toLowerCase();
174
189
  return tokens.every((t) => haystack.includes(t));
175
190
  });
191
+ const tiers = new Map(matches.map((s) => [s.id, matchTier(s, tokens)]));
176
192
  matches.sort((a, b) => {
193
+ const tier = tiers.get(a.id) - tiers.get(b.id);
194
+ if (tier !== 0) return tier;
177
195
  if (a.type === "R" && b.type !== "R") return -1;
178
196
  if (a.type !== "R" && b.type === "R") return 1;
179
197
  return a.name.localeCompare(b.name);
@@ -545,7 +563,7 @@ function summarize(data) {
545
563
  lines.push(`Source: ${data.source === "noaa" ? "NOAA CO-OPS published predictions" : "local harmonic computation from NOAA constituents"}.`);
546
564
  return lines.join("\n");
547
565
  }
548
- const version = "0.1.0";
566
+ const version = "0.1.1";
549
567
  const pkg = {
550
568
  version
551
569
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baycheck-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "NOAA tide predictions for any US coastal station, with an interactive tide chart (MCP Apps). From baycheck.info.",
5
5
  "type": "module",
6
6
  "license": "MIT",