@dangahagan/weather-mcp 0.2.0 → 1.0.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/README.md +372 -53
- package/dist/config/cache.d.ts +2 -0
- package/dist/config/cache.d.ts.map +1 -1
- package/dist/config/cache.js +48 -2
- package/dist/config/cache.js.map +1 -1
- package/dist/config/displayThresholds.d.ts +83 -0
- package/dist/config/displayThresholds.d.ts.map +1 -0
- package/dist/config/displayThresholds.js +83 -0
- package/dist/config/displayThresholds.js.map +1 -0
- package/dist/errors/ApiError.d.ts +62 -0
- package/dist/errors/ApiError.d.ts.map +1 -0
- package/dist/errors/ApiError.js +147 -0
- package/dist/errors/ApiError.js.map +1 -0
- package/dist/handlers/airQualityHandler.d.ts +11 -0
- package/dist/handlers/airQualityHandler.d.ts.map +1 -0
- package/dist/handlers/airQualityHandler.js +154 -0
- package/dist/handlers/airQualityHandler.js.map +1 -0
- package/dist/handlers/alertsHandler.d.ts +11 -0
- package/dist/handlers/alertsHandler.d.ts.map +1 -0
- package/dist/handlers/alertsHandler.js +82 -0
- package/dist/handlers/alertsHandler.js.map +1 -0
- package/dist/handlers/currentConditionsHandler.d.ts +11 -0
- package/dist/handlers/currentConditionsHandler.d.ts.map +1 -0
- package/dist/handlers/currentConditionsHandler.js +231 -0
- package/dist/handlers/currentConditionsHandler.js.map +1 -0
- package/dist/handlers/forecastHandler.d.ts +13 -0
- package/dist/handlers/forecastHandler.d.ts.map +1 -0
- package/dist/handlers/forecastHandler.js +337 -0
- package/dist/handlers/forecastHandler.js.map +1 -0
- package/dist/handlers/historicalWeatherHandler.d.ts +12 -0
- package/dist/handlers/historicalWeatherHandler.d.ts.map +1 -0
- package/dist/handlers/historicalWeatherHandler.js +188 -0
- package/dist/handlers/historicalWeatherHandler.js.map +1 -0
- package/dist/handlers/locationHandler.d.ts +11 -0
- package/dist/handlers/locationHandler.d.ts.map +1 -0
- package/dist/handlers/locationHandler.js +113 -0
- package/dist/handlers/locationHandler.js.map +1 -0
- package/dist/handlers/marineConditionsHandler.d.ts +11 -0
- package/dist/handlers/marineConditionsHandler.d.ts.map +1 -0
- package/dist/handlers/marineConditionsHandler.js +154 -0
- package/dist/handlers/marineConditionsHandler.js.map +1 -0
- package/dist/handlers/statusHandler.d.ts +12 -0
- package/dist/handlers/statusHandler.d.ts.map +1 -0
- package/dist/handlers/statusHandler.js +106 -0
- package/dist/handlers/statusHandler.js.map +1 -0
- package/dist/index.js +219 -377
- package/dist/index.js.map +1 -1
- package/dist/services/noaa.d.ts +24 -1
- package/dist/services/noaa.d.ts.map +1 -1
- package/dist/services/noaa.js +116 -43
- package/dist/services/noaa.js.map +1 -1
- package/dist/services/openmeteo.d.ts +110 -3
- package/dist/services/openmeteo.d.ts.map +1 -1
- package/dist/services/openmeteo.js +568 -112
- package/dist/services/openmeteo.js.map +1 -1
- package/dist/types/noaa.d.ts +158 -12
- package/dist/types/noaa.d.ts.map +1 -1
- package/dist/types/openmeteo.d.ts +448 -0
- package/dist/types/openmeteo.d.ts.map +1 -1
- package/dist/utils/airQuality.d.ts +54 -0
- package/dist/utils/airQuality.d.ts.map +1 -0
- package/dist/utils/airQuality.js +251 -0
- package/dist/utils/airQuality.js.map +1 -0
- package/dist/utils/cache.d.ts +11 -4
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/cache.js +33 -4
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/fireWeather.d.ts +62 -0
- package/dist/utils/fireWeather.d.ts.map +1 -0
- package/dist/utils/fireWeather.js +168 -0
- package/dist/utils/fireWeather.js.map +1 -0
- package/dist/utils/logger.d.ts +59 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +128 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/marine.d.ts +38 -0
- package/dist/utils/marine.d.ts.map +1 -0
- package/dist/utils/marine.js +162 -0
- package/dist/utils/marine.js.map +1 -0
- package/dist/utils/temperatureConversion.d.ts +12 -0
- package/dist/utils/temperatureConversion.d.ts.map +1 -0
- package/dist/utils/temperatureConversion.js +17 -0
- package/dist/utils/temperatureConversion.js.map +1 -0
- package/dist/utils/validation.d.ts +89 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +177 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +10 -3
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for search_location tool
|
|
3
|
+
*/
|
|
4
|
+
import { DataNotFoundError } from '../errors/ApiError.js';
|
|
5
|
+
export async function handleSearchLocation(args, openMeteoService) {
|
|
6
|
+
// Validate input parameters
|
|
7
|
+
const locationArgs = args;
|
|
8
|
+
if (!locationArgs.query || typeof locationArgs.query !== 'string') {
|
|
9
|
+
throw new Error('query parameter is required and must be a string');
|
|
10
|
+
}
|
|
11
|
+
const query = locationArgs.query.trim();
|
|
12
|
+
const limit = typeof locationArgs.limit === 'number' ?
|
|
13
|
+
Math.min(Math.max(1, locationArgs.limit), 100) : 5;
|
|
14
|
+
// Search for locations
|
|
15
|
+
const response = await openMeteoService.searchLocation(query, limit);
|
|
16
|
+
if (!response.results || response.results.length === 0) {
|
|
17
|
+
throw new DataNotFoundError('OpenMeteo', `No locations found matching "${query}". Try:\n` +
|
|
18
|
+
`- Using a different spelling\n` +
|
|
19
|
+
`- Being more specific (e.g., "Paris, France" instead of "Paris")\n` +
|
|
20
|
+
`- Using a nearby city or landmark`);
|
|
21
|
+
}
|
|
22
|
+
// Format the results for display
|
|
23
|
+
let output = `# Location Search Results\n\n`;
|
|
24
|
+
output += `**Query:** "${query}"\n`;
|
|
25
|
+
output += `**Found:** ${response.results.length} location${response.results.length > 1 ? 's' : ''}\n\n`;
|
|
26
|
+
output += `---\n\n`;
|
|
27
|
+
for (let i = 0; i < response.results.length; i++) {
|
|
28
|
+
const location = response.results[i];
|
|
29
|
+
output += `## ${i + 1}. ${location.name}\n\n`;
|
|
30
|
+
// Build location description
|
|
31
|
+
const parts = [location.name];
|
|
32
|
+
if (location.admin1)
|
|
33
|
+
parts.push(location.admin1);
|
|
34
|
+
if (location.admin2 && location.admin2 !== location.admin1)
|
|
35
|
+
parts.push(location.admin2);
|
|
36
|
+
if (location.country)
|
|
37
|
+
parts.push(location.country);
|
|
38
|
+
output += `**Full Name:** ${parts.join(', ')}\n`;
|
|
39
|
+
output += `**Coordinates:** ${location.latitude.toFixed(4)}°, ${location.longitude.toFixed(4)}°\n`;
|
|
40
|
+
if (location.country_code) {
|
|
41
|
+
output += `**Country Code:** ${location.country_code.toUpperCase()}\n`;
|
|
42
|
+
}
|
|
43
|
+
if (location.timezone) {
|
|
44
|
+
output += `**Timezone:** ${location.timezone}\n`;
|
|
45
|
+
}
|
|
46
|
+
if (location.elevation !== undefined) {
|
|
47
|
+
const elevationFt = Math.round(location.elevation * 3.28084);
|
|
48
|
+
output += `**Elevation:** ${location.elevation}m (${elevationFt}ft)\n`;
|
|
49
|
+
}
|
|
50
|
+
if (location.population !== undefined && location.population > 0) {
|
|
51
|
+
output += `**Population:** ${location.population.toLocaleString()}\n`;
|
|
52
|
+
}
|
|
53
|
+
if (location.feature_code) {
|
|
54
|
+
const featureDescription = getFeatureDescription(location.feature_code);
|
|
55
|
+
if (featureDescription) {
|
|
56
|
+
output += `**Type:** ${featureDescription}\n`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
output += `\n`;
|
|
60
|
+
// Add usage example
|
|
61
|
+
output += `*To get weather for this location, use these coordinates:*\n`;
|
|
62
|
+
output += `*Latitude: ${location.latitude}, Longitude: ${location.longitude}*\n\n`;
|
|
63
|
+
if (i < response.results.length - 1) {
|
|
64
|
+
output += `---\n\n`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
output += `---\n`;
|
|
68
|
+
output += `*Data source: Open-Meteo Geocoding API*\n`;
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: 'text',
|
|
73
|
+
text: output
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get human-readable description for feature code
|
|
80
|
+
* Based on GeoNames feature codes: https://www.geonames.org/export/codes.html
|
|
81
|
+
*/
|
|
82
|
+
function getFeatureDescription(code) {
|
|
83
|
+
const featureCodes = {
|
|
84
|
+
'PPL': 'Populated place',
|
|
85
|
+
'PPLA': 'Administrative capital',
|
|
86
|
+
'PPLA2': 'Second-order administrative capital',
|
|
87
|
+
'PPLA3': 'Third-order administrative capital',
|
|
88
|
+
'PPLA4': 'Fourth-order administrative capital',
|
|
89
|
+
'PPLC': 'National capital',
|
|
90
|
+
'PPLG': 'Seat of government',
|
|
91
|
+
'PPLS': 'Populated places',
|
|
92
|
+
'PPLX': 'Section of populated place',
|
|
93
|
+
'ADM1': 'First-order administrative division',
|
|
94
|
+
'ADM2': 'Second-order administrative division',
|
|
95
|
+
'ADM3': 'Third-order administrative division',
|
|
96
|
+
'ADM4': 'Fourth-order administrative division',
|
|
97
|
+
'PCLI': 'Independent political entity',
|
|
98
|
+
'PCLD': 'Dependent political entity',
|
|
99
|
+
'ISL': 'Island',
|
|
100
|
+
'MT': 'Mountain',
|
|
101
|
+
'MTS': 'Mountains',
|
|
102
|
+
'LAKE': 'Lake',
|
|
103
|
+
'RSTN': 'Railroad station',
|
|
104
|
+
'AIRP': 'Airport',
|
|
105
|
+
'AIRF': 'Airfield',
|
|
106
|
+
'PRK': 'Park',
|
|
107
|
+
'RES': 'Reserve',
|
|
108
|
+
'RESN': 'Nature reserve',
|
|
109
|
+
'RESW': 'Wildlife reserve'
|
|
110
|
+
};
|
|
111
|
+
return featureCodes[code] || null;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=locationHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locationHandler.js","sourceRoot":"","sources":["../../src/handlers/locationHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OA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M,EAAE,oBAAoB;QAC5B,MAAM,EAAE,kBAAkB;QAC1B,MAAM,EAAE,4BAA4B;QACpC,MAAM,EAAE,qCAAqC;QAC7C,MAAM,EAAE,sCAAsC;QAC9C,MAAM,EAAE,qCAAqC;QAC7C,MAAM,EAAE,sCAAsC;QAC9C,MAAM,EAAE,8BAA8B;QACtC,MAAM,EAAE,4BAA4B;QACpC,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,WAAW;QAClB,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,kBAAkB;QAC1B,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,gBAAgB;QACxB,MAAM,EAAE,kBAAkB;KAC3B,CAAC;IAEF,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for get_marine_conditions tool
|
|
3
|
+
*/
|
|
4
|
+
import { OpenMeteoService } from '../services/openmeteo.js';
|
|
5
|
+
export declare function handleGetMarineConditions(args: unknown, openMeteoService: OpenMeteoService): Promise<{
|
|
6
|
+
content: Array<{
|
|
7
|
+
type: string;
|
|
8
|
+
text: string;
|
|
9
|
+
}>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=marineConditionsHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marineConditionsHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/marineConditionsHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAkB5D,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,OAAO,EACb,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA4B7D"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for get_marine_conditions tool
|
|
3
|
+
*/
|
|
4
|
+
import { validateCoordinates, validateOptionalBoolean } from '../utils/validation.js';
|
|
5
|
+
import { formatWaveHeight, formatWavePeriod, formatDirection, formatCurrentVelocity, getWaveHeightCategory, getSafetyAssessment } from '../utils/marine.js';
|
|
6
|
+
export async function handleGetMarineConditions(args, openMeteoService) {
|
|
7
|
+
// Validate input parameters with runtime checks
|
|
8
|
+
const { latitude, longitude } = validateCoordinates(args);
|
|
9
|
+
const forecast = validateOptionalBoolean(args?.forecast, 'forecast', false);
|
|
10
|
+
// Get marine conditions data
|
|
11
|
+
const marineData = await openMeteoService.getMarine(latitude, longitude, forecast, 5 // Default 5-day forecast
|
|
12
|
+
);
|
|
13
|
+
// Format the marine data for display
|
|
14
|
+
const output = formatMarineConditions(marineData, latitude, longitude, forecast);
|
|
15
|
+
return {
|
|
16
|
+
content: [
|
|
17
|
+
{
|
|
18
|
+
type: 'text',
|
|
19
|
+
text: output
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Format marine conditions data as markdown
|
|
26
|
+
*/
|
|
27
|
+
function formatMarineConditions(data, latitude, longitude, includeForecast) {
|
|
28
|
+
let output = `# Marine Conditions Report\n\n`;
|
|
29
|
+
output += `**Location:** ${latitude.toFixed(4)}, ${longitude.toFixed(4)}\n`;
|
|
30
|
+
output += `**Timezone:** ${data.timezone}\n`;
|
|
31
|
+
output += `\n`;
|
|
32
|
+
// Important disclaimer at the top
|
|
33
|
+
output += `⚠️ **DISCLAIMER:** This data is modeled and may have limited accuracy in coastal areas. `;
|
|
34
|
+
output += `**NOT suitable for coastal navigation.** Always consult official marine forecasts for safety-critical decisions.\n\n`;
|
|
35
|
+
if (!data.current) {
|
|
36
|
+
output += `⚠️ **No current marine conditions data available for this location.**\n`;
|
|
37
|
+
return output;
|
|
38
|
+
}
|
|
39
|
+
const current = data.current;
|
|
40
|
+
const currentTime = new Date(current.time);
|
|
41
|
+
output += `**Observation Time:** ${currentTime.toLocaleString()}\n\n`;
|
|
42
|
+
// Overall safety assessment
|
|
43
|
+
const safety = getSafetyAssessment(current.wave_height, current.wind_wave_height, current.swell_wave_height, current.wave_period);
|
|
44
|
+
const safetyEmoji = safety.level === 'Calm' ? '🟢' :
|
|
45
|
+
safety.level === 'Moderate' ? '🟡' :
|
|
46
|
+
safety.level === 'Rough' ? '🟠' :
|
|
47
|
+
safety.level === 'Very Rough' ? '🔴' : '🟤';
|
|
48
|
+
output += `## ${safetyEmoji} Current Conditions: ${safety.level}\n\n`;
|
|
49
|
+
output += `${safety.description}\n\n`;
|
|
50
|
+
// Wave Height Summary
|
|
51
|
+
output += `## 🌊 Wave Conditions\n\n`;
|
|
52
|
+
if (current.wave_height !== undefined) {
|
|
53
|
+
const waveCategory = getWaveHeightCategory(current.wave_height);
|
|
54
|
+
output += `**Significant Wave Height:** ${formatWaveHeight(current.wave_height)}`;
|
|
55
|
+
output += ` (${waveCategory.description})\n`;
|
|
56
|
+
}
|
|
57
|
+
if (current.wave_direction !== undefined) {
|
|
58
|
+
output += `**Wave Direction:** ${formatDirection(current.wave_direction)}\n`;
|
|
59
|
+
}
|
|
60
|
+
if (current.wave_period !== undefined) {
|
|
61
|
+
output += `**Wave Period:** ${formatWavePeriod(current.wave_period)}\n`;
|
|
62
|
+
}
|
|
63
|
+
output += `\n`;
|
|
64
|
+
// Wind Waves (locally generated)
|
|
65
|
+
if (current.wind_wave_height !== undefined && current.wind_wave_height > 0) {
|
|
66
|
+
output += `### Wind Waves\n\n`;
|
|
67
|
+
output += `**Height:** ${formatWaveHeight(current.wind_wave_height)}\n`;
|
|
68
|
+
if (current.wind_wave_direction !== undefined) {
|
|
69
|
+
output += `**Direction:** ${formatDirection(current.wind_wave_direction)}\n`;
|
|
70
|
+
}
|
|
71
|
+
if (current.wind_wave_period !== undefined) {
|
|
72
|
+
output += `**Period:** ${formatWavePeriod(current.wind_wave_period)}\n`;
|
|
73
|
+
}
|
|
74
|
+
if (current.wind_wave_peak_period !== undefined) {
|
|
75
|
+
output += `**Peak Period:** ${formatWavePeriod(current.wind_wave_peak_period)}\n`;
|
|
76
|
+
}
|
|
77
|
+
output += `\n`;
|
|
78
|
+
}
|
|
79
|
+
// Swell Waves (propagated from distant storms)
|
|
80
|
+
if (current.swell_wave_height !== undefined && current.swell_wave_height > 0) {
|
|
81
|
+
output += `### Swell\n\n`;
|
|
82
|
+
output += `**Height:** ${formatWaveHeight(current.swell_wave_height)}\n`;
|
|
83
|
+
if (current.swell_wave_direction !== undefined) {
|
|
84
|
+
output += `**Direction:** ${formatDirection(current.swell_wave_direction)}\n`;
|
|
85
|
+
}
|
|
86
|
+
if (current.swell_wave_period !== undefined) {
|
|
87
|
+
output += `**Period:** ${formatWavePeriod(current.swell_wave_period)}\n`;
|
|
88
|
+
}
|
|
89
|
+
if (current.swell_wave_peak_period !== undefined) {
|
|
90
|
+
output += `**Peak Period:** ${formatWavePeriod(current.swell_wave_peak_period)}\n`;
|
|
91
|
+
}
|
|
92
|
+
output += `\n`;
|
|
93
|
+
}
|
|
94
|
+
// Ocean Currents
|
|
95
|
+
if (current.ocean_current_velocity !== undefined || current.ocean_current_direction !== undefined) {
|
|
96
|
+
output += `## 🌀 Ocean Currents\n\n`;
|
|
97
|
+
if (current.ocean_current_velocity !== undefined) {
|
|
98
|
+
output += `**Velocity:** ${formatCurrentVelocity(current.ocean_current_velocity)}\n`;
|
|
99
|
+
}
|
|
100
|
+
if (current.ocean_current_direction !== undefined) {
|
|
101
|
+
output += `**Direction:** ${formatDirection(current.ocean_current_direction)}\n`;
|
|
102
|
+
}
|
|
103
|
+
output += `\n`;
|
|
104
|
+
}
|
|
105
|
+
// Add forecast summary if requested
|
|
106
|
+
if (includeForecast && data.daily && data.daily.time && data.daily.time.length > 0) {
|
|
107
|
+
output += `---\n\n`;
|
|
108
|
+
output += `## 📅 Marine Forecast\n\n`;
|
|
109
|
+
const daysToShow = Math.min(5, data.daily.time.length);
|
|
110
|
+
output += `**Next ${daysToShow} days:**\n\n`;
|
|
111
|
+
for (let i = 0; i < daysToShow; i++) {
|
|
112
|
+
const date = new Date(data.daily.time[i]);
|
|
113
|
+
const dayName = date.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
|
|
114
|
+
output += `**${dayName}:**\n`;
|
|
115
|
+
if (data.daily.wave_height_max?.[i] !== undefined) {
|
|
116
|
+
const maxWaveHeight = data.daily.wave_height_max[i];
|
|
117
|
+
const category = getWaveHeightCategory(maxWaveHeight);
|
|
118
|
+
output += ` • Max Wave Height: ${formatWaveHeight(maxWaveHeight)} (${category.description})\n`;
|
|
119
|
+
}
|
|
120
|
+
if (data.daily.wave_direction_dominant?.[i] !== undefined) {
|
|
121
|
+
output += ` • Wave Direction: ${formatDirection(data.daily.wave_direction_dominant[i])}\n`;
|
|
122
|
+
}
|
|
123
|
+
if (data.daily.wave_period_max?.[i] !== undefined) {
|
|
124
|
+
output += ` • Max Wave Period: ${formatWavePeriod(data.daily.wave_period_max[i])}\n`;
|
|
125
|
+
}
|
|
126
|
+
// Show swell info if significant
|
|
127
|
+
if (data.daily.swell_wave_height_max?.[i] !== undefined && data.daily.swell_wave_height_max[i] > 0.5) {
|
|
128
|
+
output += ` • Swell Height: ${formatWaveHeight(data.daily.swell_wave_height_max[i])}\n`;
|
|
129
|
+
if (data.daily.swell_wave_direction_dominant?.[i] !== undefined) {
|
|
130
|
+
output += ` • Swell Direction: ${formatDirection(data.daily.swell_wave_direction_dominant[i])}\n`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
output += `\n`;
|
|
134
|
+
}
|
|
135
|
+
// Add hourly forecast note if available
|
|
136
|
+
if (data.hourly && data.hourly.time && data.hourly.time.length > 0) {
|
|
137
|
+
output += `*Hourly forecast data available for ${data.hourly.time.length} hours*\n\n`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Footer with interpretation guidance
|
|
141
|
+
output += `---\n\n`;
|
|
142
|
+
output += `### Interpreting Marine Conditions\n\n`;
|
|
143
|
+
output += `**Significant Wave Height:** The average height of the highest 1/3 of waves\n`;
|
|
144
|
+
output += `**Wind Waves:** Waves generated by local winds (shorter period)\n`;
|
|
145
|
+
output += `**Swell:** Long-period waves from distant weather systems (longer period)\n`;
|
|
146
|
+
output += `**Wave Period:** Time between successive wave crests (longer = more powerful)\n\n`;
|
|
147
|
+
output += `🟢 **Calm** (0-2m): Safe for most vessels\n`;
|
|
148
|
+
output += `🟡 **Moderate** (2-4m): Challenging for small craft\n`;
|
|
149
|
+
output += `🟠 **Rough** (4-6m): Hazardous for small vessels\n`;
|
|
150
|
+
output += `🔴 **Very Rough** (6-9m): Dangerous for most vessels\n`;
|
|
151
|
+
output += `🟤 **High** (>9m): Extremely dangerous\n`;
|
|
152
|
+
return output;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=marineConditionsHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marineConditionsHandler.js","sourceRoot":"","sources":["../../src/handlers/marineConditionsHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAS5B,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,IAAa,EACb,gBAAkC;IAElC,gDAAgD;IAChD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,QAAQ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C,CAAC,KAAK,SAAS,EAAE,CAAC;oBAChE,MAAM,IAAI,wBAAwB,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBACrG,CAAC;YACH,CAAC;YAED,MAAM,IAAI,IAAI,CAAC;QACjB,CAAC;QAED,wCAAwC;QACxC,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,uCAAuC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC;QACxF,CAAC;IACH,CAAC;IAED,sCAAsC;IACtC,MAAM,IAAI,SAAS,CAAC;IACpB,MAAM,IAAI,wCAAwC,CAAC;IACnD,MAAM,IAAI,+EAA+E,CAAC;IAC1F,MAAM,IAAI,mEAAmE,CAAC;IAC9E,MAAM,IAAI,6EAA6E,CAAC;IACxF,MAAM,IAAI,mFAAmF,CAAC;IAC9F,MAAM,IAAI,6CAA6C,CAAC;IACxD,MAAM,IAAI,uDAAuD,CAAC;IAClE,MAAM,IAAI,oDAAoD,CAAC;IAC/D,MAAM,IAAI,wDAAwD,CAAC;IACnE,MAAM,IAAI,0CAA0C,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for check_service_status tool
|
|
3
|
+
*/
|
|
4
|
+
import { NOAAService } from '../services/noaa.js';
|
|
5
|
+
import { OpenMeteoService } from '../services/openmeteo.js';
|
|
6
|
+
export declare function handleCheckServiceStatus(noaaService: NOAAService, openMeteoService: OpenMeteoService): Promise<{
|
|
7
|
+
content: Array<{
|
|
8
|
+
type: string;
|
|
9
|
+
text: string;
|
|
10
|
+
}>;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=statusHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/statusHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA+G7D"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for check_service_status tool
|
|
3
|
+
*/
|
|
4
|
+
import { CacheConfig } from '../config/cache.js';
|
|
5
|
+
export async function handleCheckServiceStatus(noaaService, openMeteoService) {
|
|
6
|
+
// Check status of both services
|
|
7
|
+
const noaaStatus = await noaaService.checkServiceStatus();
|
|
8
|
+
const openMeteoStatus = await openMeteoService.checkServiceStatus();
|
|
9
|
+
// Format the status report
|
|
10
|
+
let output = `# Weather API Service Status\n\n`;
|
|
11
|
+
output += `**Check Time:** ${new Date().toLocaleString()}\n\n`;
|
|
12
|
+
// NOAA Status
|
|
13
|
+
output += `## NOAA Weather API (Forecasts & Current Conditions)\n\n`;
|
|
14
|
+
output += `**Status:** ${noaaStatus.operational ? '✅ Operational' : '❌ Issues Detected'}\n`;
|
|
15
|
+
output += `**Message:** ${noaaStatus.message}\n`;
|
|
16
|
+
output += `**Status Page:** ${noaaStatus.statusPage}\n`;
|
|
17
|
+
output += `**Coverage:** United States locations only\n\n`;
|
|
18
|
+
if (!noaaStatus.operational) {
|
|
19
|
+
output += `**Recommended Actions:**\n`;
|
|
20
|
+
output += `- Check planned outages: https://weather-gov.github.io/api/planned-outages\n`;
|
|
21
|
+
output += `- View service notices: https://www.weather.gov/notification\n`;
|
|
22
|
+
output += `- Report issues: nco.ops@noaa.gov or (301) 683-1518\n\n`;
|
|
23
|
+
}
|
|
24
|
+
// Open-Meteo Status
|
|
25
|
+
output += `## Open-Meteo API (Historical Weather Data)\n\n`;
|
|
26
|
+
output += `**Status:** ${openMeteoStatus.operational ? '✅ Operational' : '❌ Issues Detected'}\n`;
|
|
27
|
+
output += `**Message:** ${openMeteoStatus.message}\n`;
|
|
28
|
+
output += `**Status Page:** ${openMeteoStatus.statusPage}\n`;
|
|
29
|
+
output += `**Coverage:** Global (worldwide locations)\n\n`;
|
|
30
|
+
if (!openMeteoStatus.operational) {
|
|
31
|
+
output += `**Recommended Actions:**\n`;
|
|
32
|
+
output += `- Check production status: https://open-meteo.com/en/docs/model-updates\n`;
|
|
33
|
+
output += `- View GitHub issues: https://github.com/open-meteo/open-meteo/issues\n`;
|
|
34
|
+
output += `- Review documentation: https://open-meteo.com/en/docs\n\n`;
|
|
35
|
+
}
|
|
36
|
+
// Cache Statistics
|
|
37
|
+
if (CacheConfig.enabled) {
|
|
38
|
+
output += `## Cache Statistics\n\n`;
|
|
39
|
+
const noaaStats = noaaService.getCacheStats();
|
|
40
|
+
const openMeteoStats = openMeteoService.getCacheStats();
|
|
41
|
+
const totalHits = noaaStats.hits + openMeteoStats.hits;
|
|
42
|
+
const totalMisses = noaaStats.misses + openMeteoStats.misses;
|
|
43
|
+
const totalRequests = totalHits + totalMisses;
|
|
44
|
+
const overallHitRate = totalRequests > 0 ? ((totalHits / totalRequests) * 100).toFixed(1) : '0.0';
|
|
45
|
+
output += `**Cache Status:** ✅ Enabled\n`;
|
|
46
|
+
output += `**Overall Hit Rate:** ${overallHitRate}%\n`;
|
|
47
|
+
output += `**Total Cache Hits:** ${totalHits}\n`;
|
|
48
|
+
output += `**Total Cache Misses:** ${totalMisses}\n`;
|
|
49
|
+
output += `**Total Requests:** ${totalRequests}\n\n`;
|
|
50
|
+
const noaaHitRate = (noaaStats.hits + noaaStats.misses) > 0
|
|
51
|
+
? ((noaaStats.hits / (noaaStats.hits + noaaStats.misses)) * 100).toFixed(1)
|
|
52
|
+
: '0.0';
|
|
53
|
+
const openMeteoHitRate = (openMeteoStats.hits + openMeteoStats.misses) > 0
|
|
54
|
+
? ((openMeteoStats.hits / (openMeteoStats.hits + openMeteoStats.misses)) * 100).toFixed(1)
|
|
55
|
+
: '0.0';
|
|
56
|
+
output += `### NOAA Service Cache\n`;
|
|
57
|
+
output += `- Entries: ${noaaStats.size} / ${noaaStats.maxSize}\n`;
|
|
58
|
+
output += `- Hit Rate: ${noaaHitRate}%\n`;
|
|
59
|
+
output += `- Hits: ${noaaStats.hits}\n`;
|
|
60
|
+
output += `- Misses: ${noaaStats.misses}\n`;
|
|
61
|
+
output += `- Evictions: ${noaaStats.evictions}\n\n`;
|
|
62
|
+
output += `### Open-Meteo Service Cache\n`;
|
|
63
|
+
output += `- Entries: ${openMeteoStats.size} / ${openMeteoStats.maxSize}\n`;
|
|
64
|
+
output += `- Hit Rate: ${openMeteoHitRate}%\n`;
|
|
65
|
+
output += `- Hits: ${openMeteoStats.hits}\n`;
|
|
66
|
+
output += `- Misses: ${openMeteoStats.misses}\n`;
|
|
67
|
+
output += `- Evictions: ${openMeteoStats.evictions}\n\n`;
|
|
68
|
+
output += `*Cache reduces API calls and improves performance for repeated queries.*\n\n`;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
output += `## Cache Statistics\n\n`;
|
|
72
|
+
output += `**Cache Status:** ❌ Disabled\n`;
|
|
73
|
+
output += `*Set CACHE_ENABLED=true in environment to enable caching.*\n\n`;
|
|
74
|
+
}
|
|
75
|
+
// Overall status summary
|
|
76
|
+
const bothOperational = noaaStatus.operational && openMeteoStatus.operational;
|
|
77
|
+
const neitherOperational = !noaaStatus.operational && !openMeteoStatus.operational;
|
|
78
|
+
if (bothOperational) {
|
|
79
|
+
output += `## Overall Status: ✅ All Services Operational\n\n`;
|
|
80
|
+
output += `Both NOAA and Open-Meteo APIs are functioning normally. Weather data requests should succeed.\n`;
|
|
81
|
+
}
|
|
82
|
+
else if (neitherOperational) {
|
|
83
|
+
output += `## Overall Status: ❌ Multiple Service Issues\n\n`;
|
|
84
|
+
output += `Both weather APIs are experiencing issues. Please check the status pages above for updates.\n`;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
output += `## Overall Status: ⚠️ Partial Service Availability\n\n`;
|
|
88
|
+
if (noaaStatus.operational) {
|
|
89
|
+
output += `NOAA API is operational: Forecasts and current conditions for US locations are available.\n`;
|
|
90
|
+
output += `Open-Meteo API has issues: Historical weather data may be unavailable.\n`;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
output += `Open-Meteo API is operational: Historical weather data is available globally.\n`;
|
|
94
|
+
output += `NOAA API has issues: Forecasts and current conditions for US locations may be unavailable.\n`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
content: [
|
|
99
|
+
{
|
|
100
|
+
type: 'text',
|
|
101
|
+
text: output
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=statusHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusHandler.js","sourceRoot":"","sources":["../../src/handlers/statusHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,WAAwB,EACxB,gBAAkC;IAElC,gCAAgC;IAChC,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,kBAAkB,EAAE,CAAC;IAC1D,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAAC,kBAAkB,EAAE,CAAC;IAEpE,2BAA2B;IAC3B,IAAI,MAAM,GAAG,kCAAkC,CAAC;IAChD,MAAM,IAAI,mBAAmB,IAAI,IA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