mcp-server-environment-agency 1.0.0 → 1.1.0

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.
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Dwain Barnes
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dwain Barnes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # Environment Agency Flood Monitoring MCP Server
2
+
3
+ [![npm version](https://badge.fury.io/js/mcp-server-environment-agency.svg)](https://badge.fury.io/js/mcp-server-environment-agency)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A Model Context Protocol (MCP) server that provides access to the UK Environment Agency's Real Time Flood Monitoring API. This server allows you to access near real-time flood warnings, water level measurements, flow data, and monitoring station information.
7
+
8
+ ## 🆕 What's new in 1.1.0
9
+
10
+ Migrated to the modern MCP SDK (`@modelcontextprotocol/sdk` 1.x), added Zod input validation (range, format, and cross-field checks), 30s request timeouts with actionable errors, id sanitization, and response capping (polygon omission, default/max limits, and 60 KB truncation) to protect the client's context window.
11
+
12
+ ## 🌊 Features
13
+
14
+ - **🚨 Flood Warnings & Alerts**: Get current flood warnings and alerts with severity levels
15
+ - **📍 Flood Areas**: Access information about flood alert and warning areas
16
+ - **🏭 Monitoring Stations**: Find water level and flow monitoring stations across the UK
17
+ - **📊 Real-time Measurements**: Access water levels, flows, and other measurements updated every 15 minutes
18
+ - **📈 Historical Data**: Retrieve historical readings and measurements
19
+ - **🗺️ Geographic Filtering**: Filter data by location using latitude, longitude, and distance
20
+ - **🔓 No API Key Required**: Uses open government data with no registration needed
21
+
22
+ ## 📦 Installation
23
+
24
+ ### For Claude Desktop Users
25
+
26
+ Add this to your Claude Desktop configuration:
27
+
28
+ **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
29
+ **Windows:** `%APPDATA%/Claude/claude_desktop_config.json`
30
+
31
+ ```json
32
+ {
33
+ "mcpServers": {
34
+ "environment-agency": {
35
+ "command": "npx",
36
+ "args": ["-y", "mcp-server-environment-agency"]
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ ### For Developers
43
+
44
+ ```bash
45
+ npm install -g mcp-server-environment-agency
46
+ ```
47
+
48
+ ## 🛠️ Available Tools
49
+
50
+ ### Flood Warning Tools
51
+ - **`get_flood_warnings`** - Get current flood warnings and alerts
52
+ - **`get_flood_warning`** - Get details of a specific flood warning
53
+ - **`get_flood_areas`** - Get flood areas (regions where warnings may apply)
54
+ - **`get_flood_area`** - Get details of a specific flood area
55
+
56
+ ### Monitoring Station Tools
57
+ - **`get_monitoring_stations`** - Get monitoring stations that measure water levels, flows, etc.
58
+ - **`get_monitoring_station`** - Get detailed information about a specific monitoring station
59
+ - **`get_measures`** - Get measurement types available across all stations
60
+ - **`get_station_measures`** - Get all measurement types from a specific station
61
+
62
+ ### Reading Tools
63
+ - **`get_readings`** - Get measurement readings from all stations
64
+ - **`get_measure_readings`** - Get readings for a specific measurement type
65
+ - **`get_station_readings`** - Get all readings from a specific monitoring station
66
+
67
+ ## 💬 Usage Examples
68
+
69
+
70
+ ```
71
+ Get detailed information for station 1029TH (Bourton Dickler)
72
+ Find monitoring stations within 25km of Cambridge
73
+ Find monitoring stations in Yorkshire
74
+ Show me today's water level readings from any 5 stations
75
+ ```
76
+
77
+
78
+ ## 📊 Data Types
79
+
80
+ ### Flood Warning Severity Levels
81
+ 1. **Severe Flood Warning** - Severe Flooding, Danger to Life
82
+ 2. **Flood Warning** - Flooding is Expected, Immediate Action Required
83
+ 3. **Flood Alert** - Flooding is Possible, Be Prepared
84
+ 4. **Warning no Longer in Force** - The warning is no longer in force
85
+
86
+ ### Measurement Parameters
87
+ - **Water Level** (`level`) - Water levels at monitoring stations
88
+ - **Flow** (`flow`) - Water flow rates
89
+ - **Temperature** (`temperature`) - Air temperature
90
+ - **Wind** (`wind`) - Wind direction and speed
91
+
92
+ ### Station Types
93
+ - **SingleLevel** - Single water level measurement
94
+ - **MultiTraceLevel** - Multiple level measurements
95
+ - **Coastal** - Coastal monitoring stations
96
+ - **Groundwater** - Groundwater level monitoring
97
+ - **Meteorological** - Weather measurements
98
+
99
+ ## 🚀 Development
100
+
101
+ ### Prerequisites
102
+ - Node.js 20+
103
+ - TypeScript
104
+
105
+ ### Setup
106
+ ```bash
107
+ git clone https://github.com/dwain-barnes/mcp-server-environment-agency.git
108
+ cd mcp-server-environment-agency
109
+ npm install
110
+ ```
111
+
112
+ ### Build
113
+ ```bash
114
+ npm run build
115
+ ```
116
+
117
+ ### Test
118
+ ```bash
119
+ # Build and run the end-to-end smoke test (spawns the server over stdio,
120
+ # lists tools, exercises a live query, and checks id sanitization)
121
+ npm test
122
+ ```
123
+
124
+ ### Local Development
125
+ ```bash
126
+ # Link for local testing
127
+ npm link
128
+
129
+ # Test with Claude Desktop using local version
130
+ ```
131
+
132
+ ## 📄 Data Attribution
133
+
134
+ This server uses Environment Agency flood and river level data from the real-time data API (Beta), provided under the [Open Government Licence](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).
135
+
136
+ ## 🔄 API Updates and Reliability
137
+
138
+ - Data is updated every 15 minutes
139
+ - The API may redirect during high load - the client follows redirects automatically
140
+ - Responses may be cached for short periods
141
+ - No service level guarantee - not suitable for safety-critical applications
142
+
143
+ ## 📋 Rate Limits and Best Practices
144
+
145
+ - For tracking all measurements, use a single call every 15 minutes
146
+ - Use geographic and parameter filters to reduce response sizes
147
+ - The API has built-in limits: default 500 items, maximum 10,000 for readings
148
+ - Use pagination with `limit` and `offset` parameters for large datasets
149
+
150
+ ## 📉 Response Limits
151
+
152
+ To keep responses friendly to LLM context windows, this server shapes and caps API results:
153
+
154
+ - **Default page size**: 50 items for stations, measures and flood areas; 100 for readings (applied when you don't pass `limit`).
155
+ - **Maximum `limit`**: 500 for any list tool. The Environment Agency API itself allows more, but this server caps for context safety — use `offset` to paginate.
156
+ - **Polygon geometry omitted**: flood-area and flood-warning polygons are replaced with a short placeholder, as they are the single largest field in the API.
157
+ - **60 KB truncation**: if a rendered response still exceeds ~60,000 characters, the items list is progressively truncated and a note explains how many items were omitted and which filters (`county`, `river_name`, `town`, or `lat`+`long`+`dist`) or pagination to use.
158
+ - Responses use a compact `{ meta, count, items }` envelope with the API `@context` field stripped.
159
+
160
+ ## 📜 License
161
+
162
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
163
+
164
+ ## 🙏 Acknowledgments
165
+
166
+ - Environment Agency for providing open flood monitoring data
167
+ - Model Context Protocol team for the excellent framework
168
+ - UK Government for open data initiatives
169
+
170
+
171
+
172
+ **Built by [Dwain Barnes](https://github.com/dwain-barnes)** 🇬🇧