@cyanheads/earthquake-mcp-server 0.2.0 → 0.3.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 (47) hide show
  1. package/CLAUDE.md +2 -2
  2. package/README.md +18 -9
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/mcp-server/resources/definitions/earthquake-event.resource.d.ts +72 -4
  6. package/dist/mcp-server/resources/definitions/earthquake-event.resource.d.ts.map +1 -1
  7. package/dist/mcp-server/resources/definitions/earthquake-event.resource.js +52 -8
  8. package/dist/mcp-server/resources/definitions/earthquake-event.resource.js.map +1 -1
  9. package/dist/mcp-server/tools/definitions/earthquake-count.tool.d.ts +21 -1
  10. package/dist/mcp-server/tools/definitions/earthquake-count.tool.d.ts.map +1 -1
  11. package/dist/mcp-server/tools/definitions/earthquake-count.tool.js +83 -5
  12. package/dist/mcp-server/tools/definitions/earthquake-count.tool.js.map +1 -1
  13. package/dist/mcp-server/tools/definitions/earthquake-get-event.tool.d.ts +65 -3
  14. package/dist/mcp-server/tools/definitions/earthquake-get-event.tool.d.ts.map +1 -1
  15. package/dist/mcp-server/tools/definitions/earthquake-get-event.tool.js +49 -10
  16. package/dist/mcp-server/tools/definitions/earthquake-get-event.tool.js.map +1 -1
  17. package/dist/mcp-server/tools/definitions/earthquake-get-feed.tool.d.ts +14 -4
  18. package/dist/mcp-server/tools/definitions/earthquake-get-feed.tool.d.ts.map +1 -1
  19. package/dist/mcp-server/tools/definitions/earthquake-get-feed.tool.js +17 -1
  20. package/dist/mcp-server/tools/definitions/earthquake-get-feed.tool.js.map +1 -1
  21. package/dist/mcp-server/tools/definitions/earthquake-search.tool.d.ts +27 -4
  22. package/dist/mcp-server/tools/definitions/earthquake-search.tool.d.ts.map +1 -1
  23. package/dist/mcp-server/tools/definitions/earthquake-search.tool.js +85 -7
  24. package/dist/mcp-server/tools/definitions/earthquake-search.tool.js.map +1 -1
  25. package/dist/mcp-server/tools/fdsn-error.d.ts +33 -0
  26. package/dist/mcp-server/tools/fdsn-error.d.ts.map +1 -0
  27. package/dist/mcp-server/tools/fdsn-error.js +84 -0
  28. package/dist/mcp-server/tools/fdsn-error.js.map +1 -0
  29. package/dist/mcp-server/tools/query-params.d.ts +8 -1
  30. package/dist/mcp-server/tools/query-params.d.ts.map +1 -1
  31. package/dist/mcp-server/tools/query-params.js +19 -1
  32. package/dist/mcp-server/tools/query-params.js.map +1 -1
  33. package/dist/mcp-server/tools/schemas.d.ts +65 -3
  34. package/dist/mcp-server/tools/schemas.d.ts.map +1 -1
  35. package/dist/mcp-server/tools/schemas.js +246 -12
  36. package/dist/mcp-server/tools/schemas.js.map +1 -1
  37. package/dist/services/emsc/emsc-service.d.ts.map +1 -1
  38. package/dist/services/emsc/emsc-service.js +14 -3
  39. package/dist/services/emsc/emsc-service.js.map +1 -1
  40. package/dist/services/usgs/types.d.ts +125 -4
  41. package/dist/services/usgs/types.d.ts.map +1 -1
  42. package/dist/services/usgs/usgs-service.d.ts +11 -3
  43. package/dist/services/usgs/usgs-service.d.ts.map +1 -1
  44. package/dist/services/usgs/usgs-service.js +115 -3
  45. package/dist/services/usgs/usgs-service.js.map +1 -1
  46. package/package.json +2 -2
  47. package/server.json +3 -3
package/CLAUDE.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  **Server:** earthquake-mcp-server
4
4
  **Package:** `@cyanheads/earthquake-mcp-server`
5
- **Version:** 0.2.0
6
- **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.10.16`
5
+ **Version:** 0.3.1
6
+ **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.10.17`
7
7
  **Engines:** Bun ≥1.3.0, Node ≥24.0.0
8
8
  **MCP SDK:** `@modelcontextprotocol/sdk` ^1.29.0
9
9
  **Zod:** ^4.4.3
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  <div align="center">
9
9
 
10
- [![Version](https://img.shields.io/badge/Version-0.2.0-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/earthquake-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/earthquake-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/earthquake-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)
10
+ [![Version](https://img.shields.io/badge/Version-0.3.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/earthquake-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/earthquake-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/earthquake-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
11
 
12
12
  </div>
13
13
 
@@ -56,15 +56,16 @@ Fetch a USGS pre-computed real-time earthquake feed by magnitude tier and time w
56
56
 
57
57
  Search earthquakes by time range, magnitude, depth, location radius, PAGER alert level, or felt reports.
58
58
 
59
- - Dual-source: USGS (global, richer metadata) or EMSC (European-Mediterranean, independent catalog for cross-verification)
59
+ - Dual-source: USGS (global, richer metadata) or EMSC (an independent global catalog from the European-Mediterranean Seismological Centre, for cross-verification anywhere)
60
60
  - Full FDSN ComCat query API parameters: time range, magnitude, depth, location radius
61
- - USGS-specific filters: PAGER alert level (`green`/`yellow`/`orange`/`red`), DYFI felt reports count, significance score
61
+ - USGS-specific filters: PAGER alert level (`green`/`yellow`/`orange`/`red`), DYFI felt reports count, significance score, event type
62
+ - Every event carries its upstream `event_type` — USGS spells it out (`earthquake`, `quarry blast`, `explosion`, `ice quake`), EMSC publishes a code (`ke` known earthquake, `ue` unknown event) — and the `event_type` filter narrows to one of them on USGS
62
63
  - Location-based queries: provide `latitude`, `longitude`, and `radius_km` together
63
64
  - Sort by time (newest first) or magnitude (largest first), ascending or descending
64
65
  - One call returns at most 20,000 events; page beyond that with `offset`, forwarded straight to the upstream FDSN `offset` parameter on both sources
65
66
  - `offset` counts from 1, matching both upstream APIs — a capped result carries `totalCount` and the `nextOffset` to pass on the following call
66
67
  - Use `earthquake_count` first to gauge result size
67
- - USGS-specific filters are silently ignored when `source=emsc`
68
+ - USGS-specific filters are not supported by EMSC — when `source=emsc` they are dropped and named in `ignoredFilters`, so an unconstrained result set is never mistaken for a filtered one
68
69
 
69
70
  ---
70
71
 
@@ -73,10 +74,12 @@ Search earthquakes by time range, magnitude, depth, location radius, PAGER alert
73
74
  Count earthquakes matching filters without fetching full records.
74
75
 
75
76
  - Lightweight alternative to `earthquake_search` for statistical queries ("how many M5+ events in 2025?")
76
- - Same filter surface as `earthquake_search`: time, magnitude, depth, location radius, PAGER, DYFI, significance
77
+ - Same filter surface as `earthquake_search`: time, magnitude, depth, location radius, PAGER, DYFI, significance, event type
78
+ - A radius over a mining region counts quarry blasts alongside earthquakes — pass `event_type="earthquake"` on USGS to exclude them
77
79
  - Returns `exceeds_limit` flag when count exceeds 20,000 — signals a full search needs paging
78
80
  - Echoes the effective query back as `queryEcho`, including the resolved time window — omitting `start_time` counts only the last 30 days
79
81
  - USGS returns the `max_allowed` cap (20,000); EMSC count endpoint does not expose this field (`max_allowed` will be null)
82
+ - USGS-specific filters are dropped and named in `ignoredFilters` when `source=emsc`, the same as on `earthquake_search`
80
83
 
81
84
  ---
82
85
 
@@ -84,7 +87,9 @@ Count earthquakes matching filters without fetching full records.
84
87
 
85
88
  Fetch complete detail for a specific earthquake by USGS event ID.
86
89
 
87
- - Returns the full USGS property set: felt reports count (DYFI), ShakeMap maximum intensity (MMI), PAGER alert level, tsunami flag, and magnitude type
90
+ - Returns the normalized event a search result already carries, plus `detail` a projection of the analysis products only the single-event response holds
91
+ - `detail` groups: PAGER alert and report link, ShakeMap peak MMI/PGA/PGV and intensity map, DYFI response count and max CDI, moment-tensor scalar moment and nodal planes, landslide and liquefaction alerts, origin quality (azimuthal gap, station count, location and depth uncertainty), finite-fault rupture length and width
92
+ - A group is omitted when USGS produced no such product — a small automatic event usually has none, a large reviewed one has most of them
88
93
  - Event IDs appear in the `id` field of `earthquake_get_feed` and `earthquake_search` results (e.g. `us6000sznj`, `hv74966427`)
89
94
  - USGS-only — EMSC events have no per-event detail endpoint
90
95
 
@@ -93,7 +98,7 @@ Fetch complete detail for a specific earthquake by USGS event ID.
93
98
  | Type | URI pattern | Description |
94
99
  |:---|:---|:---|
95
100
  | Resource | `earthquake://feed/{magnitude_tier}/{time_window}` | USGS real-time earthquake feed as injectable context — returns the whole feed, so use the `earthquake_get_feed` tool for the broad tiers |
96
- | Resource | `earthquake://event/{event_id}` | Full USGS earthquake event detail by ID as injectable context |
101
+ | Resource | `earthquake://event/{event_id}` | Full USGS earthquake event detail by ID as injectable context, including the same `detail` product projection as `earthquake_get_event` |
97
102
 
98
103
  ## Features
99
104
 
@@ -108,7 +113,7 @@ Built on [`@cyanheads/mcp-ts-core`](https://github.com/cyanheads/mcp-ts-core):
108
113
 
109
114
  Earthquake-specific:
110
115
 
111
- - Two independent data sources: USGS ComCat (global, full metadata) and EMSC SeismicPortal (European-Mediterranean, independent catalog)
116
+ - Two independent global data sources: USGS ComCat (full metadata) and EMSC SeismicPortal (an independent catalog from the European-Mediterranean Seismological Centre, with no PAGER/DYFI/ShakeMap metadata and station coverage densest around Europe and the Mediterranean)
112
117
  - USGS real-time GeoJSON feeds (CDN-cached, fast availability) plus FDSN event query API
113
118
  - EMSC FDSN-WS event and count endpoints
114
119
  - No API key required — both USGS and EMSC are fully public
@@ -117,7 +122,11 @@ Agent-friendly output:
117
122
 
118
123
  - Source attribution on every response (`usgs` / `emsc`) so agents can reason about data provenance
119
124
  - `exceeds_limit` flag on count responses surfaces truncation risk before a full search
120
- - USGS-specific fields (`alert_level`, `felt`, `mmi`, `tsunami`) clearly labeled as USGS-only to prevent misattribution on EMSC results
125
+ - Fields a source does not publish come back `null`, never as a fabricated zero — `tsunami` and `status` are null on EMSC events, and the rendered text says "not published by source" rather than "no tsunami" or "reviewed"
126
+ - `source_catalog` and `auth` carry provenance (which catalog and which authoritative agency produced a solution) so agents can weigh two sources against each other
127
+ - USGS-only filters dropped for an EMSC query are named in `ignoredFilters` on both `earthquake_search` and `earthquake_count`
128
+ - An upstream rejection surfaces the service's own explanation (the offending parameter and its accepted format) in the error message, not just a status code; when the service explains nothing, the error says so under its own reason rather than passing the raw upstream body through
129
+ - `event_type` travels with every event, so a quarry blast or explosion is never silently read as an earthquake
121
130
 
122
131
  ## Getting started
123
132
 
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ await createApp({
19
19
  instructions: 'Use the earthquake_* tools to query seismic data from USGS ComCat and the EMSC SeismicPortal; no API key required. ' +
20
20
  'earthquake_get_feed gives USGS real-time magnitude tiers for current activity; earthquake_search handles historical or filtered queries, sized first with earthquake_count (search caps at 20,000 events). ' +
21
21
  'Both emit network-specific event IDs (e.g. us6000sznj) for earthquake_get_event, which returns full USGS detail (EMSC has no per-event endpoint). ' +
22
- 'USGS carries richer metadata (PAGER, DYFI, ShakeMap); source=emsc uses the independent European-Mediterranean catalog and ignores USGS-only filters.',
22
+ 'USGS carries richer metadata (PAGER, DYFI, ShakeMap); source=emsc is an independent global catalog from the European-Mediterranean Seismological Centre, useful for cross-checking an event of any region against a separate network, and does not apply USGS-only filters (the response names them in ignoredFilters).',
23
23
  tools: [earthquakeGetFeed, earthquakeSearch, earthquakeGetEvent, earthquakeCount],
24
24
  resources: [earthquakeFeedResource, earthquakeEventResource],
25
25
  prompts: [],
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iEAAiE,CAAC;AAC1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,gEAAgE,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,yDAAyD,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,4DAA4D,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,SAAS,CAAC;IACd,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,uBAAuB;IAC9B,YAAY,EACV,qHAAqH;QACrH,6MAA6M;QAC7M,oJAAoJ;QACpJ,sJAAsJ;IACxJ,KAAK,EAAE,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;IACjF,SAAS,EAAE,CAAC,sBAAsB,EAAE,uBAAu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B,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;IACjF,SAAS,EAAE,CAAC,sBAAsB,EAAE,uBAAuB,CAAC;IAC5D,OAAO,EAAE,EAAE;IACX,OAAO,EAAE;QACP,0EAA0E;QAC1E,2FAA2F;QAC3F,WAAW,EAAE,KAAK;KACnB;IACD,KAAK,CAAC,IAAI;QACR,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;QACjC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACxF,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC1F,CAAC;CACF,CAAC,CAAC"}
@@ -3,6 +3,7 @@
3
3
  * @module mcp-server/resources/definitions/earthquake-event.resource
4
4
  */
5
5
  import { z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
6
7
  export declare const earthquakeEventResource: import("@cyanheads/mcp-ts-core").ResourceDefinition<z.ZodObject<{
7
8
  event_id: z.ZodString;
8
9
  }, z.core.$strip>, z.ZodObject<{
@@ -26,15 +27,82 @@ export declare const earthquakeEventResource: import("@cyanheads/mcp-ts-core").R
26
27
  orange: "orange";
27
28
  red: "red";
28
29
  }>>;
29
- tsunami: z.ZodNumber;
30
+ tsunami: z.ZodNullable<z.ZodNumber>;
30
31
  significance: z.ZodNullable<z.ZodNumber>;
31
- status: z.ZodEnum<{
32
+ status: z.ZodNullable<z.ZodEnum<{
32
33
  automatic: "automatic";
33
34
  reviewed: "reviewed";
34
35
  deleted: "deleted";
35
- }>;
36
+ }>>;
37
+ source_catalog: z.ZodOptional<z.ZodString>;
38
+ auth: z.ZodOptional<z.ZodString>;
39
+ event_type: z.ZodOptional<z.ZodString>;
36
40
  event_url: z.ZodOptional<z.ZodString>;
37
41
  detail_url: z.ZodOptional<z.ZodString>;
38
42
  }, z.core.$strip>;
39
- }, z.core.$strip>, undefined>;
43
+ detail: z.ZodOptional<z.ZodObject<{
44
+ losspager: z.ZodOptional<z.ZodObject<{
45
+ alert_level: z.ZodOptional<z.ZodString>;
46
+ report_url: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strip>>;
48
+ shakemap: z.ZodOptional<z.ZodObject<{
49
+ max_mmi: z.ZodOptional<z.ZodNumber>;
50
+ max_pga: z.ZodOptional<z.ZodNumber>;
51
+ max_pgv: z.ZodOptional<z.ZodNumber>;
52
+ intensity_map_url: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$strip>>;
54
+ dyfi: z.ZodOptional<z.ZodObject<{
55
+ responses: z.ZodOptional<z.ZodNumber>;
56
+ max_cdi: z.ZodOptional<z.ZodNumber>;
57
+ map_url: z.ZodOptional<z.ZodString>;
58
+ }, z.core.$strip>>;
59
+ moment_tensor: z.ZodOptional<z.ZodObject<{
60
+ scalar_moment_nm: z.ZodOptional<z.ZodNumber>;
61
+ derived_depth_km: z.ZodOptional<z.ZodNumber>;
62
+ nodal_plane_1: z.ZodOptional<z.ZodObject<{
63
+ strike: z.ZodNumber;
64
+ dip: z.ZodNumber;
65
+ rake: z.ZodNumber;
66
+ }, z.core.$strip>>;
67
+ nodal_plane_2: z.ZodOptional<z.ZodObject<{
68
+ strike: z.ZodNumber;
69
+ dip: z.ZodNumber;
70
+ rake: z.ZodNumber;
71
+ }, z.core.$strip>>;
72
+ }, z.core.$strip>>;
73
+ ground_failure: z.ZodOptional<z.ZodObject<{
74
+ landslide_alert: z.ZodOptional<z.ZodString>;
75
+ liquefaction_alert: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strip>>;
77
+ origin: z.ZodOptional<z.ZodObject<{
78
+ azimuthal_gap_deg: z.ZodOptional<z.ZodNumber>;
79
+ num_stations_used: z.ZodOptional<z.ZodNumber>;
80
+ horizontal_error_km: z.ZodOptional<z.ZodNumber>;
81
+ depth_error_km: z.ZodOptional<z.ZodNumber>;
82
+ review_status: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>>;
84
+ finite_fault: z.ZodOptional<z.ZodObject<{
85
+ rupture_length_km: z.ZodOptional<z.ZodNumber>;
86
+ rupture_width_km: z.ZodOptional<z.ZodNumber>;
87
+ model_url: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$strip>>;
89
+ }, z.core.$strip>>;
90
+ }, z.core.$strip>, readonly [{
91
+ readonly reason: "not_found";
92
+ readonly code: JsonRpcErrorCode.NotFound;
93
+ readonly when: "No event matches the provided event_id.";
94
+ readonly recovery: string;
95
+ }, {
96
+ readonly reason: "source_unavailable";
97
+ readonly code: JsonRpcErrorCode.ServiceUnavailable;
98
+ readonly when: "The USGS event API returns a 5xx, serves HTML, or is unreachable.";
99
+ readonly retryable: true;
100
+ readonly recovery: string;
101
+ }, {
102
+ readonly reason: "source_timeout";
103
+ readonly code: JsonRpcErrorCode.Timeout;
104
+ readonly when: "The USGS event API did not answer before the request deadline.";
105
+ readonly retryable: true;
106
+ readonly recovery: string;
107
+ }]>;
40
108
  //# sourceMappingURL=earthquake-event.resource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"earthquake-event.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/earthquake-event.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAMrD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAkClC,CAAC"}
1
+ {"version":3,"file":"earthquake-event.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/earthquake-event.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAY,MAAM,+BAA+B,CAAC;AAI3E,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFlC,CAAC"}
@@ -3,35 +3,79 @@
3
3
  * @module mcp-server/resources/definitions/earthquake-event.resource
4
4
  */
5
5
  import { resource, z } from '@cyanheads/mcp-ts-core';
6
- import { JsonRpcErrorCode, McpError, notFound } from '@cyanheads/mcp-ts-core/errors';
7
- import { EarthquakeEventSchema } from '../../../mcp-server/tools/schemas.js';
6
+ import { JsonRpcErrorCode, McpError } from '@cyanheads/mcp-ts-core/errors';
7
+ import { EarthquakeDetailSchema, EarthquakeEventSchema } from '../../../mcp-server/tools/schemas.js';
8
8
  import { getUsgsService } from '../../../services/usgs/usgs-service.js';
9
9
  export const earthquakeEventResource = resource('earthquake://event/{event_id}', {
10
10
  name: 'earthquake-event',
11
11
  title: 'USGS Earthquake Event',
12
12
  description: 'Earthquake event detail by USGS event ID as injectable context. ' +
13
- 'Returns felt reports, ShakeMap intensity, PAGER alert, tsunami flag, and magnitude type. ' +
14
- 'Use event IDs from earthquake_get_feed or earthquake_search results.',
13
+ 'Returns the normalized event plus the analysis products only the single-event response ' +
14
+ 'holds: PAGER alert, ShakeMap ground motion, DYFI felt reports, moment tensor, ground-failure ' +
15
+ 'alerts, origin quality, and finite-fault rupture dimensions, each omitted when USGS ' +
16
+ 'produced none. Use event IDs from earthquake_get_feed or earthquake_search results.',
15
17
  mimeType: 'application/json',
16
18
  params: z.object({
17
19
  event_id: z.string().describe('USGS event ID, e.g. "us6000sznj" or "hv74966427".'),
18
20
  }),
19
21
  output: z.object({
20
22
  event: EarthquakeEventSchema.describe('Full earthquake event detail.'),
23
+ detail: EarthquakeDetailSchema.optional().describe('Analysis products USGS attached to this event. Absent when the event carries none — ' +
24
+ 'that means no product was produced, not that impact was zero.'),
21
25
  }),
26
+ errors: [
27
+ {
28
+ reason: 'not_found',
29
+ code: JsonRpcErrorCode.NotFound,
30
+ when: 'No event matches the provided event_id.',
31
+ recovery: 'Verify the event ID from a feed or search result. ' +
32
+ 'IDs are network-specific strings like "us6000sznj" or "hv74966427".',
33
+ },
34
+ {
35
+ reason: 'source_unavailable',
36
+ code: JsonRpcErrorCode.ServiceUnavailable,
37
+ when: 'The USGS event API returns a 5xx, serves HTML, or is unreachable.',
38
+ retryable: true,
39
+ recovery: 'Retry after a short delay. The same event also appears in earthquake_search and ' +
40
+ 'earthquake_get_feed results, which carry the normalized record without the products.',
41
+ },
42
+ {
43
+ reason: 'source_timeout',
44
+ code: JsonRpcErrorCode.Timeout,
45
+ when: 'The USGS event API did not answer before the request deadline.',
46
+ retryable: true,
47
+ recovery: 'Retry the same event ID — a single-event lookup carries no filters to reduce. If it ' +
48
+ 'keeps timing out, read the event from an earthquake_search or earthquake_get_feed result.',
49
+ },
50
+ ],
22
51
  async handler(params, ctx) {
23
52
  ctx.log.debug('Fetching event resource', { event_id: params.event_id });
24
- let event;
53
+ let result;
25
54
  try {
26
- event = await getUsgsService().getEvent(params.event_id, ctx);
55
+ result = await getUsgsService().getEvent(params.event_id, ctx);
27
56
  }
28
57
  catch (err) {
29
58
  if (err instanceof McpError && err.code === JsonRpcErrorCode.NotFound) {
30
- throw notFound(`No earthquake event found for ID "${params.event_id}". Verify the ID from a feed or search result.`, { event_id: params.event_id }, { cause: err });
59
+ throw ctx.fail('not_found', `No earthquake event found for ID "${params.event_id}". Verify the ID from a feed or search result.`, { ...ctx.recoveryFor('not_found') });
60
+ }
61
+ if (err instanceof McpError && err.code === JsonRpcErrorCode.ServiceUnavailable) {
62
+ throw ctx.fail('source_unavailable', err.message, {
63
+ ...ctx.recoveryFor('source_unavailable'),
64
+ });
65
+ }
66
+ // A timeout classifies as Timeout, not ServiceUnavailable — it needs its own
67
+ // branch or it bypasses the contract and reaches the caller with no recovery hint.
68
+ if (err instanceof McpError && err.code === JsonRpcErrorCode.Timeout) {
69
+ throw ctx.fail('source_timeout', err.message, {
70
+ ...ctx.recoveryFor('source_timeout'),
71
+ });
31
72
  }
32
73
  throw err;
33
74
  }
34
- return { event };
75
+ return {
76
+ event: result.event,
77
+ ...(result.detail ? { detail: result.detail } : {}),
78
+ };
35
79
  },
36
80
  });
37
81
  //# sourceMappingURL=earthquake-event.resource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"earthquake-event.resource.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/earthquake-event.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,QAAQ,CAAC,+BAA+B,EAAE;IAC/E,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EACT,kEAAkE;QAClE,2FAA2F;QAC3F,sEAAsE;IACxE,QAAQ,EAAE,kBAAkB;IAE5B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mDAAmD,CAAC;KACnF,CAAC;IAEF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,KAAK,EAAE,qBAAqB,CAAC,QAAQ,CAAC,+BAA+B,CAAC;KACvE,CAAC;IAEF,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG;QACvB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxE,IAAI,KAAsB,CAAC;QAC3B,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,cAAc,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAChE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,gBAAgB,CAAC,QAAQ,EAAE,CAAC;gBACtE,MAAM,QAAQ,CACZ,qCAAqC,MAAM,CAAC,QAAQ,gDAAgD,EACpG,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,EAC7B,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"earthquake-event.resource.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/earthquake-event.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAoB,MAAM,iCAAiC,CAAC;AAEnF,MAAM,CAAC,MAAM,uBAAuB,GAAG,QAAQ,CAAC,+BAA+B,EAAE;IAC/E,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EACT,kEAAkE;QAClE,yFAAyF;QACzF,+FAA+F;QAC/F,sFAAsF;QACtF,qFAAqF;IACvF,QAAQ,EAAE,kBAAkB;IAE5B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC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MAAM,CAAC,QAAQ,gDAAgD,EACpG,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CACpC,CAAC;YACJ,CAAC;YACD,IAAI,GAAG,YAAY,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,gBAAgB,CAAC,kBAAkB,EAAE,CAAC;gBAChF,MAAM,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,CAAC,OAAO,EAAE;oBAChD,GAAG,GAAG,CAAC,WAAW,CAAC,oBAAoB,CAAC;iBACzC,CAAC,CAAC;YACL,CAAC;YACD,6EAA6E;YAC7E,mFAAmF;YACnF,IAAI,GAAG,YAAY,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBACrE,MAAM,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,CAAC,OAAO,EAAE;oBAC5C,GAAG,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAC;iBACrC,CAAC,CAAC;YACL,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -22,6 +22,7 @@ export declare const earthquakeCount: import("@cyanheads/mcp-ts-core").ToolDefin
22
22
  }>>;
23
23
  min_felt: z.ZodOptional<z.ZodNumber>;
24
24
  min_significance: z.ZodOptional<z.ZodNumber>;
25
+ event_type: z.ZodOptional<z.ZodString>;
25
26
  source: z.ZodDefault<z.ZodEnum<{
26
27
  usgs: "usgs";
27
28
  emsc: "emsc";
@@ -42,8 +43,25 @@ export declare const earthquakeCount: import("@cyanheads/mcp-ts-core").ToolDefin
42
43
  }, {
43
44
  readonly reason: "source_unavailable";
44
45
  readonly code: JsonRpcErrorCode.ServiceUnavailable;
45
- readonly when: "Selected source API returns non-2xx or times out.";
46
+ readonly when: "Selected source API returns a 5xx or is unreachable.";
47
+ readonly retryable: true;
46
48
  readonly recovery: "Try the other source (usgs or emsc) or retry after a short delay.";
49
+ }, {
50
+ readonly reason: "source_timeout";
51
+ readonly code: JsonRpcErrorCode.Timeout;
52
+ readonly when: "Selected source API did not answer before the request deadline.";
53
+ readonly retryable: true;
54
+ readonly recovery: string;
55
+ }, {
56
+ readonly reason: "upstream_rejected";
57
+ readonly code: JsonRpcErrorCode.InvalidParams;
58
+ readonly when: "The source API rejected the query parameters and explained why in its response body.";
59
+ readonly recovery: string;
60
+ }, {
61
+ readonly reason: "upstream_rejected_no_reason";
62
+ readonly code: JsonRpcErrorCode.InvalidParams;
63
+ readonly when: "The source API rejected the query but its response body carried no usable explanation.";
64
+ readonly recovery: string;
47
65
  }], {
48
66
  readonly queryEcho: z.ZodOptional<z.ZodObject<{
49
67
  start_time: z.ZodOptional<z.ZodString>;
@@ -58,10 +76,12 @@ export declare const earthquakeCount: import("@cyanheads/mcp-ts-core").ToolDefin
58
76
  alert_level: z.ZodOptional<z.ZodString>;
59
77
  min_felt: z.ZodOptional<z.ZodNumber>;
60
78
  min_significance: z.ZodOptional<z.ZodNumber>;
79
+ event_type: z.ZodOptional<z.ZodString>;
61
80
  source: z.ZodEnum<{
62
81
  usgs: "usgs";
63
82
  emsc: "emsc";
64
83
  }>;
65
84
  }, z.core.$strip>>;
85
+ readonly ignoredFilters: z.ZodOptional<z.ZodArray<z.ZodString>>;
66
86
  }>;
67
87
  //# sourceMappingURL=earthquake-count.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"earthquake-count.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/earthquake-count.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAY,MAAM,+BAA+B,CAAC;AAM3E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2R1B,CAAC"}
1
+ {"version":3,"file":"earthquake-count.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/earthquake-count.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAY,MAAM,+BAA+B,CAAC;AAO3E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0X1B,CAAC"}
@@ -4,7 +4,8 @@
4
4
  */
5
5
  import { tool, z } from '@cyanheads/mcp-ts-core';
6
6
  import { JsonRpcErrorCode, McpError } from '@cyanheads/mcp-ts-core/errors';
7
- import { buildQueryParams } from '../../../mcp-server/tools/query-params.js';
7
+ import { upstreamRejection } from '../../../mcp-server/tools/fdsn-error.js';
8
+ import { buildQueryParams, ignoredUsgsFilters } from '../../../mcp-server/tools/query-params.js';
8
9
  import { getEmscService } from '../../../services/emsc/emsc-service.js';
9
10
  import { getUsgsService } from '../../../services/usgs/usgs-service.js';
10
11
  export const earthquakeCount = tool('earthquake_count', {
@@ -18,7 +19,10 @@ export const earthquakeCount = tool('earthquake_count', {
18
19
  'narrow filters before fetching. ' +
19
20
  'USGS returns the max_allowed cap (20,000); EMSC count endpoint does not return this field ' +
20
21
  '(max_allowed will be null). ' +
21
- 'USGS-specific filters (alert_level, min_felt, min_significance) are ignored when source=emsc.',
22
+ 'Both catalogs include non-tectonic records, so a radius over a mining region counts quarry ' +
23
+ 'blasts alongside earthquakes — pass event_type="earthquake" on USGS to exclude them. ' +
24
+ 'USGS-specific filters (alert_level, event_type, min_felt, min_significance) are not sent when ' +
25
+ 'source=emsc — the response names them in ignoredFilters.',
22
26
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
23
27
  input: z.object({
24
28
  start_time: z
@@ -83,12 +87,22 @@ export const earthquakeCount = tool('earthquake_count', {
83
87
  .describe('Minimum USGS significance score (0–2000+). ' +
84
88
  'Combines magnitude, felt reports, and PAGER estimates. ' +
85
89
  'Significant events typically score 600+. Only available from USGS.'),
90
+ event_type: z
91
+ .string()
92
+ .optional()
93
+ .describe('Filter by upstream event classification, e.g. "earthquake" to exclude quarry blasts and ' +
94
+ 'explosions from the count, or "quarry blast" to count only those. Matched verbatim ' +
95
+ 'against the USGS catalog, which accepts any string and returns a count of zero for an ' +
96
+ 'unrecognized one. Only available from USGS.'),
86
97
  source: z
87
98
  .enum(['usgs', 'emsc'])
88
99
  .default('usgs')
89
- .describe('Data source. ' +
100
+ .describe('Data source. Both catalogs are global. ' +
90
101
  '"usgs" covers global events with PAGER, DYFI, and ShakeMap metadata. ' +
91
- '"emsc" covers the European-Mediterranean region.'),
102
+ '"emsc" is an independent global catalog operated by the European-Mediterranean ' +
103
+ 'Seismological Centre — use it to cross-check a count from a separate network. ' +
104
+ 'It has no PAGER, DYFI, or ShakeMap metadata; its station coverage is densest around ' +
105
+ 'Europe and the Mediterranean, so counts of small events differ most by region.'),
92
106
  }),
93
107
  output: z.object({
94
108
  count: z.number().describe('Number of events matching the query.'),
@@ -140,12 +154,22 @@ export const earthquakeCount = tool('earthquake_count', {
140
154
  .number()
141
155
  .optional()
142
156
  .describe('Significance filter sent upstream. Absent for EMSC — not supported there.'),
157
+ event_type: z
158
+ .string()
159
+ .optional()
160
+ .describe('Event-type filter sent upstream. Absent for EMSC — not supported there.'),
143
161
  source: z.enum(['usgs', 'emsc']).describe('Data source queried.'),
144
162
  })
145
163
  .optional()
146
164
  .describe('Echo of the effective parameters the count covers, including server-resolved defaults. ' +
147
165
  'Read start_time and end_time to know which window the count spans — a filter absent ' +
148
166
  'here was not sent upstream.'),
167
+ ignoredFilters: z
168
+ .array(z.string().describe('Name of an input filter that was not applied.'))
169
+ .optional()
170
+ .describe('USGS-only filters supplied in the input but not sent upstream because source=emsc ' +
171
+ 'does not support them. The count is NOT constrained by these — re-run with ' +
172
+ 'source=usgs to apply them. Absent when every supplied filter was applied.'),
149
173
  },
150
174
  enrichmentTrailer: {
151
175
  queryEcho: {
@@ -153,6 +177,10 @@ export const earthquakeCount = tool('earthquake_count', {
153
177
  .map(([key, value]) => `${key}=${String(value)}`)
154
178
  .join(' · ')}`,
155
179
  },
180
+ ignoredFilters: {
181
+ render: (f) => `**Ignored filters (not supported by EMSC, not sent upstream):** ${(f ?? []).join(', ')} — ` +
182
+ 'this count is NOT constrained by the listed filters. Re-run with source=usgs to apply them.',
183
+ },
156
184
  },
157
185
  errors: [
158
186
  {
@@ -164,9 +192,33 @@ export const earthquakeCount = tool('earthquake_count', {
164
192
  {
165
193
  reason: 'source_unavailable',
166
194
  code: JsonRpcErrorCode.ServiceUnavailable,
167
- when: 'Selected source API returns non-2xx or times out.',
195
+ when: 'Selected source API returns a 5xx or is unreachable.',
196
+ retryable: true,
168
197
  recovery: 'Try the other source (usgs or emsc) or retry after a short delay.',
169
198
  },
199
+ {
200
+ reason: 'source_timeout',
201
+ code: JsonRpcErrorCode.Timeout,
202
+ when: 'Selected source API did not answer before the request deadline.',
203
+ retryable: true,
204
+ recovery: 'Narrow the time range or raise min_magnitude so the upstream count scans a smaller ' +
205
+ 'window, then retry. Counts over multi-year spans are the usual cause.',
206
+ },
207
+ {
208
+ reason: 'upstream_rejected',
209
+ code: JsonRpcErrorCode.InvalidParams,
210
+ when: 'The source API rejected the query parameters and explained why in its response body.',
211
+ recovery: 'Read the upstream reason in the error message — it names the offending parameter and ' +
212
+ 'the accepted format. Correct that parameter and call again.',
213
+ },
214
+ {
215
+ reason: 'upstream_rejected_no_reason',
216
+ code: JsonRpcErrorCode.InvalidParams,
217
+ when: 'The source API rejected the query but its response body carried no usable explanation.',
218
+ recovery: 'The service named no offending parameter. Re-check the parameters you supplied — ' +
219
+ 'time range format, magnitude bounds, and the lat/lon/radius trio are the usual causes — ' +
220
+ 'or retry with the other source to see whether it accepts the same query.',
221
+ },
170
222
  ],
171
223
  async handler(input, ctx) {
172
224
  const latProvided = input.latitude != null;
@@ -196,6 +248,26 @@ export const earthquakeCount = tool('earthquake_count', {
196
248
  ...ctx.recoveryFor('source_unavailable'),
197
249
  });
198
250
  }
251
+ // A timeout classifies as Timeout, not ServiceUnavailable — it needs its own
252
+ // branch or it bypasses the contract and reaches the caller with no recovery hint.
253
+ if (err instanceof McpError && err.code === JsonRpcErrorCode.Timeout) {
254
+ throw ctx.fail('source_timeout', err.message, {
255
+ ...ctx.recoveryFor('source_timeout'),
256
+ });
257
+ }
258
+ // A 4xx means the upstream rejected the parameters, and its body usually says
259
+ // which one. The framework leaves that body out of the message, so fold it in
260
+ // here — otherwise content[]-only clients see a bare status code. A body with no
261
+ // usable reason still gets a contract reason of its own, so the raw upstream text
262
+ // (which echoes an internal hostname) never substitutes for an explanation.
263
+ const rejection = upstreamRejection(err);
264
+ if (rejection) {
265
+ const source = input.source.toUpperCase();
266
+ if (rejection.reason != null) {
267
+ throw ctx.fail('upstream_rejected', `${source} rejected the query: ${rejection.reason}`, { ...ctx.recoveryFor('upstream_rejected'), status: rejection.status }, { cause: err });
268
+ }
269
+ throw ctx.fail('upstream_rejected_no_reason', `${source} rejected the query (HTTP ${rejection.status}) — the service gave no reason.`, { ...ctx.recoveryFor('upstream_rejected_no_reason'), status: rejection.status }, { cause: err });
270
+ }
199
271
  throw err;
200
272
  }
201
273
  ctx.log.info('Count completed', {
@@ -222,9 +294,15 @@ export const earthquakeCount = tool('earthquake_count', {
222
294
  ...(isUsgs && params.minSignificance != null
223
295
  ? { min_significance: params.minSignificance }
224
296
  : {}),
297
+ ...(isUsgs && params.eventType != null ? { event_type: params.eventType } : {}),
225
298
  source: input.source,
226
299
  },
227
300
  });
301
+ // An absence from queryEcho is too quiet a signal that a supplied filter never
302
+ // constrained the count — name the dropped filters outright.
303
+ const ignoredFilters = ignoredUsgsFilters(input, input.source);
304
+ if (ignoredFilters.length > 0)
305
+ ctx.enrich({ ignoredFilters });
228
306
  return {
229
307
  count: result.count,
230
308
  max_allowed: result.maxAllowed,
@@ -1 +1 @@
1
- {"version":3,"file":"earthquake-count.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/earthquake-count.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAoB,MAAM,iCAAiC,CAAC;AAEnF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE;IACtD,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EACT,oEAAoE;QACpE,4FAA4F;QAC5F,oCAAoC;QACpC,sFAAsF;QACtF,gGAAgG;QAChG,8FAA8F;QAC9F,kCAAkC;QAClC,4FAA4F;QAC5F,8BAA8B;QAC9B,+FAA+F;IACjG,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IAE9E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,UAAU,EAAE,CAAC;aACV,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,gFAAgF;YAC9E,gFAAgF;YAChF,6DAA6D,CAChE;QACH,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,qEAAqE,CAAC;QAClF,aAAa,EAAE,CAAC;aACb,MAAM,E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,IAAI;oBAC1C,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,eAAe,EAAE;oBAC9C,CAAC,CAAC,EAAE,CAAC;gBACP,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB;SACF,CAAC,CAAC;QAEH,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,WAAW,EAAE,MAAM,CAAC,UAAU;YAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,aAAa,EAAE,MAAM,CAAC,YAAY;SACnC,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;QACjB,MAAM,KAAK,GAAa;YACtB,eAAe,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE;YAC5C,cAAc,MAAM,CAAC,KAAK,EAAE;YAC5B,oBAAoB,MAAM,CAAC,WAAW,IAAI,sBAAsB,EAAE;YAClE,sBAAsB,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,0DAA0D,CAAC,CAAC,CAAC,IAAI,EAAE;SACjH,CAAC;QACF,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"earthquake-count.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/earthquake-count.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EA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