@dangahagan/weather-mcp 0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Weather MCP Server Contributors
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
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,414 @@
1
+ # Weather MCP Server
2
+
3
+ An MCP (Model Context Protocol) server that provides weather data to AI systems like Claude Code. Uses NOAA's API for US weather forecasts and current conditions, plus Open-Meteo for global historical weather data.
4
+
5
+ **No API keys required!** Both NOAA and Open-Meteo APIs are free to use with no authentication needed.
6
+
7
+ ## Features
8
+
9
+ - **Get Forecast**: Retrieve weather forecasts for any US location (7-day forecast)
10
+ - **Current Conditions**: Get real-time weather observations for US locations
11
+ - **Historical Data**: Access historical weather observations for any location worldwide
12
+ - Recent data (last 7 days): Detailed hourly observations from NOAA real-time API (US only)
13
+ - Archival data (>7 days old): Hourly/daily weather data from 1940-present via Open-Meteo (global coverage)
14
+ - **Service Status Checking**: Proactively verify API availability with health checks
15
+ - **Enhanced Error Handling**: Detailed, actionable error messages with status page links
16
+
17
+ ## Installation
18
+
19
+ ### Quick Install (Recommended)
20
+
21
+ **Via npm:**
22
+ ```bash
23
+ npm install -g weather-mcp
24
+ ```
25
+
26
+ **Via npx (no installation):**
27
+ ```bash
28
+ npx -y weather-mcp
29
+ ```
30
+
31
+ Then configure in your MCP client using:
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "weather": {
36
+ "command": "npx",
37
+ "args": ["-y", "weather-mcp"]
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ### From Source
44
+
45
+ If you prefer to build from source:
46
+
47
+ **Prerequisites:**
48
+ - Node.js 18 or higher
49
+ - npm or yarn
50
+ - **No API keys or tokens required**
51
+
52
+ **Setup:**
53
+
54
+ 1. Clone the repository:
55
+ ```bash
56
+ git clone https://github.com/dgahagan/weather-mcp.git
57
+ cd weather-mcp
58
+ ```
59
+
60
+ 2. Install dependencies:
61
+ ```bash
62
+ npm install
63
+ ```
64
+
65
+ 3. Build the project:
66
+ ```bash
67
+ npm run build
68
+ ```
69
+
70
+ ## Usage with AI Assistants
71
+
72
+ This MCP server works with any client that supports the Model Context Protocol, including:
73
+
74
+ - **Claude Desktop** - Official Claude desktop application
75
+ - **Claude Code** - Official Claude CLI tool
76
+ - **Cline** - VS Code extension for AI-assisted coding
77
+ - **Cursor** - AI-powered code editor
78
+ - **Zed** - High-performance code editor with AI features
79
+ - **VS Code (GitHub Copilot)** - With MCP support enabled
80
+ - **LM Studio** - Local AI model interface
81
+ - **Postman** - API platform with MCP integration
82
+
83
+ For detailed setup instructions for each client, see **[CLIENT_SETUP.md](./docs/CLIENT_SETUP.md)**.
84
+
85
+ ### Quick Start: Claude Code
86
+
87
+ Edit `~/.config/claude-code/mcp_settings.json` (macOS/Linux) or `%APPDATA%\claude-code\mcp_settings.json` (Windows):
88
+
89
+ ```json
90
+ {
91
+ "mcpServers": {
92
+ "weather": {
93
+ "command": "node",
94
+ "args": ["/absolute/path/to/weather-mcp/dist/index.js"]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ Restart Claude Code and the weather tools will be available.
101
+
102
+ ## Finding Coordinates
103
+
104
+ All tools require latitude and longitude coordinates. You can find coordinates for any location by:
105
+ - Asking Claude Code: "What are the coordinates for [city name]?"
106
+ - Using Google Maps: Right-click a location and select the coordinates
107
+ - Using a geocoding service like geocode.maps.co or nominatim.org
108
+
109
+ ### Common US City Coordinates
110
+
111
+ | City | Latitude | Longitude |
112
+ |------|----------|-----------|
113
+ | San Francisco, CA | 37.7749 | -122.4194 |
114
+ | New York, NY | 40.7128 | -74.0060 |
115
+ | Chicago, IL | 41.8781 | -87.6298 |
116
+ | Los Angeles, CA | 34.0522 | -118.2437 |
117
+ | Denver, CO | 39.7392 | -104.9903 |
118
+ | Miami, FL | 25.7617 | -80.1918 |
119
+ | Seattle, WA | 47.6062 | -122.3321 |
120
+ | Austin, TX | 30.2672 | -97.7431 |
121
+
122
+ ## Available Tools
123
+
124
+ ### 1. check_service_status
125
+ Check the operational status of weather APIs.
126
+
127
+ **Parameters:** None
128
+
129
+ **Description:**
130
+ Performs health checks on both NOAA and Open-Meteo APIs to verify they are operational. Use this tool when experiencing errors or to proactively verify service availability before making weather data requests. Returns current status, helpful messages, and links to official status pages.
131
+
132
+ **Example:**
133
+ ```
134
+ Check if the weather services are operational
135
+ ```
136
+
137
+ **Returns:**
138
+ - Operational status for NOAA API (forecasts & current conditions)
139
+ - Operational status for Open-Meteo API (historical data)
140
+ - Status page links and recommended actions if issues are detected
141
+ - Overall service availability summary
142
+
143
+ ### 2. get_forecast
144
+ Get weather forecast for a location.
145
+
146
+ **Parameters:**
147
+ - `latitude` (required): Latitude coordinate (-90 to 90)
148
+ - `longitude` (required): Longitude coordinate (-180 to 180)
149
+ - `days` (optional): Number of days in forecast (1-7, default: 7)
150
+
151
+ **Example:**
152
+ ```
153
+ Get the weather forecast for San Francisco (latitude: 37.7749, longitude: -122.4194)
154
+ ```
155
+
156
+ ### 3. get_current_conditions
157
+ Get current weather conditions for a location.
158
+
159
+ **Parameters:**
160
+ - `latitude` (required): Latitude coordinate (-90 to 90)
161
+ - `longitude` (required): Longitude coordinate (-180 to 180)
162
+
163
+ **Example:**
164
+ ```
165
+ What are the current weather conditions in New York? (latitude: 40.7128, longitude: -74.0060)
166
+ ```
167
+
168
+ ### 4. get_historical_weather
169
+ Get historical weather observations for a location.
170
+
171
+ **Parameters:**
172
+ - `latitude` (required): Latitude coordinate (-90 to 90)
173
+ - `longitude` (required): Longitude coordinate (-180 to 180)
174
+ - `start_date` (required): Start date in ISO format (YYYY-MM-DD)
175
+ - `end_date` (required): End date in ISO format (YYYY-MM-DD)
176
+ - `limit` (optional): Max observations to return (1-500, default: 168)
177
+
178
+ **Data Source Selection:**
179
+ The server automatically chooses the best data source based on your date range:
180
+
181
+ - **Last 7 days**: Uses NOAA real-time API
182
+ - ✓ Detailed hourly observations from weather stations
183
+ - ✓ Includes: temperature, conditions, wind speed, humidity, pressure
184
+ - ✓ High reliability and availability
185
+ - ⚠️ US locations only
186
+
187
+ - **Older than 7 days**: Uses Open-Meteo Historical Weather API
188
+ - ✓ No API token required
189
+ - ✓ Global coverage (worldwide)
190
+ - ✓ Historical data from 1940 to present
191
+ - ✓ Hourly data for ranges up to 31 days
192
+ - ✓ Daily summaries for longer periods
193
+ - ✓ Includes: temperature, precipitation, wind, humidity, pressure, cloud cover
194
+ - ✓ High resolution reanalysis data (9-25km grid)
195
+ - ⚠️ 5-day delay for most recent data
196
+
197
+ **Examples:**
198
+
199
+ Recent data (US locations, detailed observations):
200
+ ```
201
+ "What was the weather like in Chicago 3 days ago?"
202
+ Coordinates: latitude: 41.8781, longitude: -87.6298
203
+ Date range: 3 days ago to 2 days ago
204
+ ```
205
+
206
+ Historical data (global coverage):
207
+ ```
208
+ "What was the weather in Paris on January 15, 2024?"
209
+ Coordinates: latitude: 48.8566, longitude: 2.3522
210
+ Date range: 2024-01-15 to 2024-01-15
211
+ ```
212
+
213
+ Long-term historical analysis:
214
+ ```
215
+ "Show me weather data for Tokyo from January 1, 2020 to December 31, 2020"
216
+ Coordinates: latitude: 35.6762, longitude: 139.6503
217
+ Date range: 2020-01-01 to 2020-12-31
218
+ ```
219
+
220
+ **Troubleshooting:**
221
+ If you get "No historical data available":
222
+ - For recent dates (last 7 days): Ensure you're using US coordinates
223
+ - For older dates: Data should be available globally back to 1940
224
+ - Note: Most recent data has a 5-day delay
225
+ - Very recent dates (last 5 days) may not be available in archival data yet
226
+
227
+ ## Error Handling & Service Status
228
+
229
+ ### Enhanced Error Messages
230
+
231
+ This MCP server provides detailed, actionable error messages when issues occur. All error messages include:
232
+
233
+ - **Clear problem description** - What went wrong and why
234
+ - **Contextual help** - Specific guidance based on the error type
235
+ - **Status page links** - Direct links to official service status pages
236
+ - **Recommended actions** - Concrete steps to resolve or investigate the issue
237
+
238
+ **Example Error Messages:**
239
+
240
+ When a service is down:
241
+ ```
242
+ NOAA API server error: Service temporarily unavailable
243
+
244
+ The NOAA Weather API may be experiencing an outage.
245
+
246
+ Check service status:
247
+ - Planned outages: https://weather-gov.github.io/api/planned-outages
248
+ - Service notices: https://www.weather.gov/notification
249
+ - Report issues: nco.ops@noaa.gov or (301) 683-1518
250
+ ```
251
+
252
+ When rate limited:
253
+ ```
254
+ Open-Meteo API rate limit exceeded (10,000 requests/day for non-commercial use).
255
+
256
+ Please retry later or consider:
257
+ - Reducing request frequency
258
+ - Using daily instead of hourly data for longer periods
259
+ - Upgrading to a commercial plan for higher limits
260
+
261
+ More info: https://open-meteo.com/en/pricing
262
+ ```
263
+
264
+ ### Service Status Checking
265
+
266
+ Use the `check_service_status` tool to proactively verify API availability:
267
+
268
+ ```
269
+ # Query example
270
+ "Check if the weather services are working"
271
+
272
+ # Returns:
273
+ - ✅/❌ Status for NOAA API (US forecasts & current conditions)
274
+ - ✅/❌ Status for Open-Meteo API (global historical data)
275
+ - Links to official status pages
276
+ - Recommended actions if issues detected
277
+ - Overall service availability summary
278
+ ```
279
+
280
+ **When to use:**
281
+ - Before making multiple weather requests
282
+ - When experiencing errors or timeouts
283
+ - To verify service availability after an outage
284
+ - For monitoring and alerting purposes
285
+
286
+ **Status Page Links:**
287
+ - **NOAA API:**
288
+ - Planned outages: https://weather-gov.github.io/api/planned-outages
289
+ - Service notices: https://www.weather.gov/notification
290
+ - Report issues: https://weather-gov.github.io/api/reporting-issues
291
+
292
+ - **Open-Meteo API:**
293
+ - Production status: https://open-meteo.com/en/docs/model-updates
294
+ - GitHub issues: https://github.com/open-meteo/open-meteo/issues
295
+ - Documentation: https://open-meteo.com/en/docs
296
+
297
+ ## Testing
298
+
299
+ ### Quick Test
300
+
301
+ Verify NOAA API connectivity:
302
+ ```bash
303
+ npx tsx tests/test_noaa_api.ts
304
+ ```
305
+
306
+ This runs 5 tests covering all major functionality with real NOAA API calls.
307
+
308
+ ### Manual Testing with Claude Code
309
+
310
+ See [TESTING_GUIDE.md](./docs/TESTING_GUIDE.md) for comprehensive testing instructions including:
311
+ - Setup steps
312
+ - Test cases for all tools
313
+ - Error handling verification
314
+ - Performance testing
315
+ - Debugging tips
316
+
317
+ ## Development
318
+
319
+ ### Available Scripts
320
+
321
+ - `npm run build` - Compile TypeScript to JavaScript
322
+ - `npm run dev` - Run the server in development mode with tsx
323
+ - `npm start` - Run the compiled server
324
+ - `npx tsx tests/test_noaa_api.ts` - Run API connectivity tests
325
+
326
+ ### Project Structure
327
+
328
+ ```
329
+ weather-mcp/
330
+ ├── src/
331
+ │ ├── index.ts # Main MCP server
332
+ │ ├── services/
333
+ │ │ ├── noaa.ts # NOAA real-time API service
334
+ │ │ └── openmeteo.ts # Open-Meteo historical weather API service
335
+ │ ├── types/
336
+ │ │ ├── noaa.ts # NOAA TypeScript type definitions
337
+ │ │ └── openmeteo.ts # Open-Meteo TypeScript type definitions
338
+ │ └── utils/
339
+ │ └── units.ts # Unit conversion utilities
340
+ ├── dist/ # Compiled JavaScript (generated)
341
+ ├── tests/ # Test files
342
+ └── package.json
343
+ ```
344
+
345
+ ## API Information
346
+
347
+ This server uses two weather APIs:
348
+
349
+ ### NOAA Weather API (Real-time)
350
+ - **Base URL**: https://api.weather.gov
351
+ - **Authentication**: None required (User-Agent header only)
352
+ - **Rate Limits**: Enforced with 5-second retry window
353
+ - **Coverage**: United States locations only
354
+ - **Use cases**: Forecasts, current conditions, recent observations (last 7 days)
355
+ - **Data**: Detailed hourly observations from weather stations
356
+
357
+ ### Open-Meteo Historical Weather API (Archival)
358
+ - **Base URL**: https://archive-api.open-meteo.com/v1
359
+ - **Authentication**: None required (no API token needed)
360
+ - **Rate Limits**: 10,000 requests/day for non-commercial use
361
+ - **Coverage**: Global (worldwide locations)
362
+ - **Use cases**: Historical weather data from 1940 to present
363
+ - **Data**: Hourly or daily temperature, precipitation, wind, humidity, pressure, cloud cover
364
+ - **Resolution**: 9-25km grid resolution from reanalysis models
365
+ - **Delay**: 5-day delay for most recent data
366
+
367
+ For more details on NOAA APIs, see [NOAA_API_RESEARCH.md](./docs/NOAA_API_RESEARCH.md).
368
+
369
+ ## Limitations
370
+
371
+ ### Geographic Coverage
372
+
373
+ **Forecasts and Current Conditions:**
374
+ - NOAA APIs only cover **United States locations**
375
+ - International locations are not supported for forecasts and current conditions
376
+
377
+ **Historical Data:**
378
+ - Recent data (last 7 days): **US locations only** (NOAA API)
379
+ - Archival data (>7 days old): **Global coverage** (Open-Meteo API)
380
+
381
+ ### Historical Data (get_historical_weather)
382
+
383
+ **Recent Data (Last 7 Days)** - US Only, High Detail:
384
+ - ✓ Detailed hourly observations from weather stations
385
+ - ✓ No API token required
386
+ - ⚠️ US locations only
387
+ - ⚠️ May have occasional gaps depending on weather station
388
+ - ⚠️ Observations may be delayed up to 20 minutes
389
+
390
+ **Archival Data (Older than 7 Days)** - Global, Reanalysis-Based:
391
+ - ✓ Global coverage (any location worldwide)
392
+ - ✓ No API token required
393
+ - ✓ Reliable data from 1940 to present
394
+ - ✓ Hourly data for date ranges up to 31 days
395
+ - ✓ Daily summaries for longer periods
396
+ - ⚠️ Most recent data has a 5-day delay
397
+ - ⚠️ Reanalysis-based (grid model, not direct station observations)
398
+
399
+ ### Rate Limits
400
+ - **NOAA Weather API**: Automatic retry with exponential backoff on rate limit errors
401
+ - **Open-Meteo API**: 10,000 requests/day for non-commercial use
402
+
403
+ ### Recommendations
404
+ - **For recent US weather**: Use dates within the last 7 days for detailed station observations
405
+ - **For historical analysis**: Open-Meteo provides reliable global coverage back to 1940
406
+ - **For international locations**: Only historical data (>7 days old) is supported
407
+
408
+ ## License
409
+
410
+ MIT
411
+
412
+ ## Contributing
413
+
414
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Weather MCP Server
4
+ * Provides weather data from NOAA API to AI systems via Model Context Protocol
5
+ */
6
+ import 'dotenv/config';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAGH,OAAO,eAAe,CAAC"}