@dangahagan/weather-mcp 0.1.2 → 0.4.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.
Files changed (68) hide show
  1. package/README.md +295 -52
  2. package/dist/config/cache.d.ts +30 -0
  3. package/dist/config/cache.d.ts.map +1 -0
  4. package/dist/config/cache.js +105 -0
  5. package/dist/config/cache.js.map +1 -0
  6. package/dist/config/displayThresholds.d.ts +83 -0
  7. package/dist/config/displayThresholds.d.ts.map +1 -0
  8. package/dist/config/displayThresholds.js +83 -0
  9. package/dist/config/displayThresholds.js.map +1 -0
  10. package/dist/errors/ApiError.d.ts +62 -0
  11. package/dist/errors/ApiError.d.ts.map +1 -0
  12. package/dist/errors/ApiError.js +147 -0
  13. package/dist/errors/ApiError.js.map +1 -0
  14. package/dist/handlers/alertsHandler.d.ts +11 -0
  15. package/dist/handlers/alertsHandler.d.ts.map +1 -0
  16. package/dist/handlers/alertsHandler.js +79 -0
  17. package/dist/handlers/alertsHandler.js.map +1 -0
  18. package/dist/handlers/currentConditionsHandler.d.ts +11 -0
  19. package/dist/handlers/currentConditionsHandler.d.ts.map +1 -0
  20. package/dist/handlers/currentConditionsHandler.js +168 -0
  21. package/dist/handlers/currentConditionsHandler.js.map +1 -0
  22. package/dist/handlers/forecastHandler.d.ts +13 -0
  23. package/dist/handlers/forecastHandler.d.ts.map +1 -0
  24. package/dist/handlers/forecastHandler.js +226 -0
  25. package/dist/handlers/forecastHandler.js.map +1 -0
  26. package/dist/handlers/historicalWeatherHandler.d.ts +12 -0
  27. package/dist/handlers/historicalWeatherHandler.d.ts.map +1 -0
  28. package/dist/handlers/historicalWeatherHandler.js +188 -0
  29. package/dist/handlers/historicalWeatherHandler.js.map +1 -0
  30. package/dist/handlers/locationHandler.d.ts +11 -0
  31. package/dist/handlers/locationHandler.d.ts.map +1 -0
  32. package/dist/handlers/locationHandler.js +113 -0
  33. package/dist/handlers/locationHandler.js.map +1 -0
  34. package/dist/handlers/statusHandler.d.ts +12 -0
  35. package/dist/handlers/statusHandler.d.ts.map +1 -0
  36. package/dist/handlers/statusHandler.js +106 -0
  37. package/dist/handlers/statusHandler.js.map +1 -0
  38. package/dist/index.js +149 -343
  39. package/dist/index.js.map +1 -1
  40. package/dist/services/noaa.d.ts +23 -1
  41. package/dist/services/noaa.d.ts.map +1 -1
  42. package/dist/services/noaa.js +154 -41
  43. package/dist/services/noaa.js.map +1 -1
  44. package/dist/services/openmeteo.d.ts +63 -3
  45. package/dist/services/openmeteo.d.ts.map +1 -1
  46. package/dist/services/openmeteo.js +284 -50
  47. package/dist/services/openmeteo.js.map +1 -1
  48. package/dist/types/noaa.d.ts +64 -12
  49. package/dist/types/noaa.d.ts.map +1 -1
  50. package/dist/types/openmeteo.d.ts +156 -0
  51. package/dist/types/openmeteo.d.ts.map +1 -1
  52. package/dist/utils/cache.d.ts +69 -0
  53. package/dist/utils/cache.d.ts.map +1 -0
  54. package/dist/utils/cache.js +164 -0
  55. package/dist/utils/cache.js.map +1 -0
  56. package/dist/utils/logger.d.ts +59 -0
  57. package/dist/utils/logger.d.ts.map +1 -0
  58. package/dist/utils/logger.js +128 -0
  59. package/dist/utils/logger.js.map +1 -0
  60. package/dist/utils/temperatureConversion.d.ts +12 -0
  61. package/dist/utils/temperatureConversion.d.ts.map +1 -0
  62. package/dist/utils/temperatureConversion.js +17 -0
  63. package/dist/utils/temperatureConversion.js.map +1 -0
  64. package/dist/utils/validation.d.ts +89 -0
  65. package/dist/utils/validation.d.ts.map +1 -0
  66. package/dist/utils/validation.js +177 -0
  67. package/dist/utils/validation.js.map +1 -0
  68. package/package.json +10 -3
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Display thresholds and constants for weather data formatting
3
+ *
4
+ * These values determine when certain weather metrics are shown or highlighted
5
+ */
6
+ export declare const DisplayThresholds: {
7
+ /**
8
+ * Temperature thresholds (in Fahrenheit)
9
+ */
10
+ readonly temperature: {
11
+ /** Show heat index when temperature is above this value */
12
+ readonly showHeatIndex: 80;
13
+ /** Show wind chill when temperature is below this value */
14
+ readonly showWindChill: 50;
15
+ };
16
+ /**
17
+ * Wind thresholds
18
+ */
19
+ readonly wind: {
20
+ /** Show gusts if they are this ratio higher than sustained wind speed (1.2 = 20% higher) */
21
+ readonly gustSignificanceRatio: 1.2;
22
+ };
23
+ /**
24
+ * Visibility thresholds (in miles)
25
+ */
26
+ readonly visibility: {
27
+ /** Dense fog */
28
+ readonly denseFog: 0.25;
29
+ /** Fog */
30
+ readonly fog: 1;
31
+ /** Haze or mist */
32
+ readonly hazeMist: 3;
33
+ /** Clear visibility */
34
+ readonly clear: 10;
35
+ };
36
+ /**
37
+ * Precipitation thresholds
38
+ */
39
+ readonly precipitation: {
40
+ /** Light precipitation (inches per hour) */
41
+ readonly light: 0.1;
42
+ /** Moderate precipitation (inches per hour) */
43
+ readonly moderate: 0.3;
44
+ /** Heavy precipitation (inches per hour) */
45
+ readonly heavy: 0.5;
46
+ };
47
+ };
48
+ /**
49
+ * API-related constants
50
+ */
51
+ export declare const ApiConstants: {
52
+ /**
53
+ * Historical data threshold (in days)
54
+ * Data older than this uses archival API instead of recent observations
55
+ */
56
+ readonly historicalDataThresholdDays: 7;
57
+ /**
58
+ * Maximum date range for hourly historical data (in days)
59
+ */
60
+ readonly maxHourlyHistoricalDays: 31;
61
+ };
62
+ /**
63
+ * Formatting constants
64
+ */
65
+ export declare const FormatConstants: {
66
+ /**
67
+ * Default forecast periods to show
68
+ */
69
+ readonly defaultForecastDays: 7;
70
+ /**
71
+ * Maximum forecast days (Open-Meteo supports up to 16 days)
72
+ */
73
+ readonly maxForecastDays: 16;
74
+ /**
75
+ * Default observation limit for historical data
76
+ */
77
+ readonly defaultHistoricalLimit: 168;
78
+ /**
79
+ * Maximum observations to return
80
+ */
81
+ readonly maxHistoricalLimit: 500;
82
+ };
83
+ //# sourceMappingURL=displayThresholds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"displayThresholds.d.ts","sourceRoot":"","sources":["../../src/config/displayThresholds.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;;QAED,2DAA2D;;QAE3D,2DAA2D;;;IAI7D;;OAEG;;QAED,4FAA4F;;;IAI9F;;OAEG;;QAED,gBAAgB;;QAEhB,UAAU;;QAEV,mBAAmB;;QAEnB,uBAAuB;;;IAIzB;;OAEG;;QAED,4CAA4C;;QAE5C,+CAA+C;;QAE/C,4CAA4C;;;CAGtC,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB;;;OAGG;;IAGH;;OAEG;;CAEK,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEK,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Display thresholds and constants for weather data formatting
3
+ *
4
+ * These values determine when certain weather metrics are shown or highlighted
5
+ */
6
+ export const DisplayThresholds = {
7
+ /**
8
+ * Temperature thresholds (in Fahrenheit)
9
+ */
10
+ temperature: {
11
+ /** Show heat index when temperature is above this value */
12
+ showHeatIndex: 80,
13
+ /** Show wind chill when temperature is below this value */
14
+ showWindChill: 50,
15
+ },
16
+ /**
17
+ * Wind thresholds
18
+ */
19
+ wind: {
20
+ /** Show gusts if they are this ratio higher than sustained wind speed (1.2 = 20% higher) */
21
+ gustSignificanceRatio: 1.2,
22
+ },
23
+ /**
24
+ * Visibility thresholds (in miles)
25
+ */
26
+ visibility: {
27
+ /** Dense fog */
28
+ denseFog: 0.25,
29
+ /** Fog */
30
+ fog: 1.0,
31
+ /** Haze or mist */
32
+ hazeMist: 3.0,
33
+ /** Clear visibility */
34
+ clear: 10.0,
35
+ },
36
+ /**
37
+ * Precipitation thresholds
38
+ */
39
+ precipitation: {
40
+ /** Light precipitation (inches per hour) */
41
+ light: 0.1,
42
+ /** Moderate precipitation (inches per hour) */
43
+ moderate: 0.3,
44
+ /** Heavy precipitation (inches per hour) */
45
+ heavy: 0.5,
46
+ },
47
+ };
48
+ /**
49
+ * API-related constants
50
+ */
51
+ export const ApiConstants = {
52
+ /**
53
+ * Historical data threshold (in days)
54
+ * Data older than this uses archival API instead of recent observations
55
+ */
56
+ historicalDataThresholdDays: 7,
57
+ /**
58
+ * Maximum date range for hourly historical data (in days)
59
+ */
60
+ maxHourlyHistoricalDays: 31,
61
+ };
62
+ /**
63
+ * Formatting constants
64
+ */
65
+ export const FormatConstants = {
66
+ /**
67
+ * Default forecast periods to show
68
+ */
69
+ defaultForecastDays: 7,
70
+ /**
71
+ * Maximum forecast days (Open-Meteo supports up to 16 days)
72
+ */
73
+ maxForecastDays: 16,
74
+ /**
75
+ * Default observation limit for historical data
76
+ */
77
+ defaultHistoricalLimit: 168, // One week of hourly data
78
+ /**
79
+ * Maximum observations to return
80
+ */
81
+ maxHistoricalLimit: 500,
82
+ };
83
+ //# sourceMappingURL=displayThresholds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"displayThresholds.js","sourceRoot":"","sources":["../../src/config/displayThresholds.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B;;OAEG;IACH,WAAW,EAAE;QACX,2DAA2D;QAC3D,aAAa,EAAE,EAAE;QACjB,2DAA2D;QAC3D,aAAa,EAAE,EAAE;KAClB;IAED;;OAEG;IACH,IAAI,EAAE;QACJ,4FAA4F;QAC5F,qBAAqB,EAAE,GAAG;KAC3B;IAED;;OAEG;IACH,UAAU,EAAE;QACV,gBAAgB;QAChB,QAAQ,EAAE,IAAI;QACd,UAAU;QACV,GAAG,EAAE,GAAG;QACR,mBAAmB;QACnB,QAAQ,EAAE,GAAG;QACb,uBAAuB;QACvB,KAAK,EAAE,IAAI;KACZ;IAED;;OAEG;IACH,aAAa,EAAE;QACb,4CAA4C;QAC5C,KAAK,EAAE,GAAG;QACV,+CAA+C;QAC/C,QAAQ,EAAE,GAAG;QACb,4CAA4C;QAC5C,KAAK,EAAE,GAAG;KACX;CACO,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;;;OAGG;IACH,2BAA2B,EAAE,CAAC;IAE9B;;OAEG;IACH,uBAAuB,EAAE,EAAE;CACnB,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B;;OAEG;IACH,mBAAmB,EAAE,CAAC;IAEtB;;OAEG;IACH,eAAe,EAAE,EAAE;IAEnB;;OAEG;IACH,sBAAsB,EAAE,GAAG,EAAE,0BAA0B;IAEvD;;OAEG;IACH,kBAAkB,EAAE,GAAG;CACf,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Custom error classes for better error handling and logging
3
+ */
4
+ /**
5
+ * Base error class for API-related errors
6
+ */
7
+ export declare class ApiError extends Error {
8
+ readonly statusCode: number;
9
+ readonly service: 'NOAA' | 'OpenMeteo';
10
+ readonly userMessage: string;
11
+ readonly helpLinks: string[];
12
+ readonly isRetryable: boolean;
13
+ constructor(message: string, statusCode: number, service: 'NOAA' | 'OpenMeteo', userMessage: string, helpLinks?: string[], isRetryable?: boolean);
14
+ /**
15
+ * Format error for display to user
16
+ */
17
+ toUserMessage(): string;
18
+ }
19
+ /**
20
+ * Rate limit error - too many requests
21
+ */
22
+ export declare class RateLimitError extends ApiError {
23
+ readonly retryAfter?: number;
24
+ constructor(service: 'NOAA' | 'OpenMeteo', retryAfter?: number);
25
+ }
26
+ /**
27
+ * Service unavailable error - API is down or timing out
28
+ */
29
+ export declare class ServiceUnavailableError extends ApiError {
30
+ constructor(service: 'NOAA' | 'OpenMeteo', originalError?: Error);
31
+ }
32
+ /**
33
+ * Invalid location error - coordinates not supported or out of range
34
+ */
35
+ export declare class InvalidLocationError extends ApiError {
36
+ readonly latitude?: number;
37
+ readonly longitude?: number;
38
+ constructor(service: 'NOAA' | 'OpenMeteo', message: string, latitude?: number, longitude?: number);
39
+ }
40
+ /**
41
+ * Data not found error - requested data doesn't exist
42
+ */
43
+ export declare class DataNotFoundError extends ApiError {
44
+ constructor(service: 'NOAA' | 'OpenMeteo', message: string);
45
+ }
46
+ /**
47
+ * Validation error - invalid input parameters
48
+ */
49
+ export declare class ValidationError extends Error {
50
+ readonly field?: string;
51
+ readonly value?: any;
52
+ constructor(message: string, field?: string, value?: any);
53
+ }
54
+ /**
55
+ * Check if an error is retryable
56
+ */
57
+ export declare function isRetryableError(error: Error): boolean;
58
+ /**
59
+ * Format error for user display
60
+ */
61
+ export declare function formatErrorForUser(error: Error): string;
62
+ //# sourceMappingURL=ApiError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiError.d.ts","sourceRoot":"","sources":["../../src/errors/ApiError.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC;IAC9C,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpC,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAGnC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GAAG,WAAW,EAC7B,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,MAAM,EAAO,EACxB,WAAW,GAAE,OAAe;IAgB9B;;OAEG;IACH,aAAa,IAAI,MAAM;CAYxB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,UAAU,CAAC,EAAE,MAAM;CAoB/D;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,QAAQ;gBACvC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,aAAa,CAAC,EAAE,KAAK;CAoBjE;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;IAChD,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClC,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;gBAGjC,OAAO,EAAE,MAAM,GAAG,WAAW,EAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM;CAerB;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM;CAY3D;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAgB,KAAK,CAAC,EAAE,GAAG,CAAC;gBAEhB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;CAUzD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAetD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAgBvD"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Custom error classes for better error handling and logging
3
+ */
4
+ /**
5
+ * Base error class for API-related errors
6
+ */
7
+ export class ApiError extends Error {
8
+ statusCode;
9
+ service;
10
+ userMessage;
11
+ helpLinks;
12
+ isRetryable;
13
+ constructor(message, statusCode, service, userMessage, helpLinks = [], isRetryable = false) {
14
+ super(message);
15
+ this.name = 'ApiError';
16
+ this.statusCode = statusCode;
17
+ this.service = service;
18
+ this.userMessage = userMessage;
19
+ this.helpLinks = helpLinks;
20
+ this.isRetryable = isRetryable;
21
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
22
+ if (Error.captureStackTrace) {
23
+ Error.captureStackTrace(this, this.constructor);
24
+ }
25
+ }
26
+ /**
27
+ * Format error for display to user
28
+ */
29
+ toUserMessage() {
30
+ let message = `${this.service} API Error: ${this.userMessage}`;
31
+ if (this.helpLinks.length > 0) {
32
+ message += '\n\nFor more information:\n';
33
+ this.helpLinks.forEach(link => {
34
+ message += `- ${link}\n`;
35
+ });
36
+ }
37
+ return message;
38
+ }
39
+ }
40
+ /**
41
+ * Rate limit error - too many requests
42
+ */
43
+ export class RateLimitError extends ApiError {
44
+ retryAfter;
45
+ constructor(service, retryAfter) {
46
+ const userMessage = retryAfter
47
+ ? `Rate limit exceeded. Please retry after ${retryAfter} seconds.`
48
+ : 'Rate limit exceeded. Please retry in a few seconds.';
49
+ super(`Rate limit exceeded for ${service}`, 429, service, userMessage, [
50
+ 'https://weather.gov/documentation/services-web-api',
51
+ 'https://open-meteo.com/en/features#api-documentation',
52
+ ], true // Retryable after waiting
53
+ );
54
+ this.name = 'RateLimitError';
55
+ this.retryAfter = retryAfter;
56
+ }
57
+ }
58
+ /**
59
+ * Service unavailable error - API is down or timing out
60
+ */
61
+ export class ServiceUnavailableError extends ApiError {
62
+ constructor(service, originalError) {
63
+ super(`${service} API is currently unavailable`, 503, service, `The ${service} weather service is temporarily unavailable. Please try again in a few minutes.`, [
64
+ service === 'NOAA'
65
+ ? 'https://www.weather.gov/'
66
+ : 'https://open-meteo.com/',
67
+ ], true // Retryable
68
+ );
69
+ this.name = 'ServiceUnavailableError';
70
+ if (originalError && originalError.stack) {
71
+ this.stack = `${this.stack}\nCaused by: ${originalError.stack}`;
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * Invalid location error - coordinates not supported or out of range
77
+ */
78
+ export class InvalidLocationError extends ApiError {
79
+ latitude;
80
+ longitude;
81
+ constructor(service, message, latitude, longitude) {
82
+ super(message, 400, service, message, [], false // Not retryable
83
+ );
84
+ this.name = 'InvalidLocationError';
85
+ this.latitude = latitude;
86
+ this.longitude = longitude;
87
+ }
88
+ }
89
+ /**
90
+ * Data not found error - requested data doesn't exist
91
+ */
92
+ export class DataNotFoundError extends ApiError {
93
+ constructor(service, message) {
94
+ super(message, 404, service, message, [], false // Not retryable
95
+ );
96
+ this.name = 'DataNotFoundError';
97
+ }
98
+ }
99
+ /**
100
+ * Validation error - invalid input parameters
101
+ */
102
+ export class ValidationError extends Error {
103
+ field;
104
+ value;
105
+ constructor(message, field, value) {
106
+ super(message);
107
+ this.name = 'ValidationError';
108
+ this.field = field;
109
+ this.value = value;
110
+ if (Error.captureStackTrace) {
111
+ Error.captureStackTrace(this, this.constructor);
112
+ }
113
+ }
114
+ }
115
+ /**
116
+ * Check if an error is retryable
117
+ */
118
+ export function isRetryableError(error) {
119
+ if (error instanceof ApiError) {
120
+ return error.isRetryable;
121
+ }
122
+ // Network errors are generally retryable
123
+ if (error.message.includes('ECONNREFUSED') ||
124
+ error.message.includes('ETIMEDOUT') ||
125
+ error.message.includes('ENOTFOUND')) {
126
+ return true;
127
+ }
128
+ return false;
129
+ }
130
+ /**
131
+ * Format error for user display
132
+ */
133
+ export function formatErrorForUser(error) {
134
+ if (error instanceof ApiError) {
135
+ return error.toUserMessage();
136
+ }
137
+ if (error instanceof ValidationError) {
138
+ return `Validation Error: ${error.message}`;
139
+ }
140
+ // Sanitize generic errors to avoid leaking sensitive information
141
+ const sanitizedMessage = error.message
142
+ .replace(/ECONNREFUSED/, 'Connection refused')
143
+ .replace(/ETIMEDOUT/, 'Connection timed out')
144
+ .replace(/ENOTFOUND/, 'Service not found');
145
+ return `Error: ${sanitizedMessage}`;
146
+ }
147
+ //# sourceMappingURL=ApiError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiError.js","sourceRoot":"","sources":["../../src/errors/ApiError.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjB,UAAU,CAAS;IACnB,OAAO,CAAuB;IAC9B,WAAW,CAAS;IACpB,SAAS,CAAW;IACpB,WAAW,CAAU;IAErC,YACE,OAAe,EACf,UAA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O;SACnC,OAAO,CAAC,cAAc,EAAE,oBAAoB,CAAC;SAC7C,OAAO,CAAC,WAAW,EAAE,sBAAsB,CAAC;SAC5C,OAAO,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;IAE7C,OAAO,UAAU,gBAAgB,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Handler for get_alerts tool
3
+ */
4
+ import { NOAAService } from '../services/noaa.js';
5
+ export declare function handleGetAlerts(args: unknown, noaaService: NOAAService): Promise<{
6
+ content: Array<{
7
+ type: string;
8
+ text: string;
9
+ }>;
10
+ }>;
11
+ //# sourceMappingURL=alertsHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alertsHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/alertsHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AASlD,wBAAsB,eAAe,CACnC,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA+F7D"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Handler for get_alerts tool
3
+ */
4
+ import { validateCoordinates, validateOptionalBoolean } from '../utils/validation.js';
5
+ export async function handleGetAlerts(args, noaaService) {
6
+ // Validate input parameters with runtime checks
7
+ const { latitude, longitude } = validateCoordinates(args);
8
+ const active_only = validateOptionalBoolean(args?.active_only, 'active_only', true);
9
+ // Get alerts data
10
+ const alertsData = await noaaService.getAlerts(latitude, longitude, active_only);
11
+ const alerts = alertsData.features;
12
+ // Format the alerts for display
13
+ let output = `# Weather Alerts\n\n`;
14
+ output += `**Location:** ${latitude.toFixed(4)}, ${longitude.toFixed(4)}\n`;
15
+ output += `**Status:** ${active_only ? 'Active alerts only' : 'All alerts'}\n`;
16
+ if (alertsData.updated) {
17
+ output += `**Updated:** ${new Date(alertsData.updated).toLocaleString()}\n`;
18
+ }
19
+ output += `\n`;
20
+ if (alerts.length === 0) {
21
+ output += `✅ **No active weather alerts for this location.**\n\n`;
22
+ output += `The area is currently clear of weather warnings, watches, and advisories.\n`;
23
+ }
24
+ else {
25
+ output += `⚠️ **${alerts.length} active alert${alerts.length > 1 ? 's' : ''} found**\n\n`;
26
+ const severityOrder = {
27
+ 'Extreme': 0,
28
+ 'Severe': 1,
29
+ 'Moderate': 2,
30
+ 'Minor': 3,
31
+ 'Unknown': 4
32
+ };
33
+ const sortedAlerts = alerts.sort((a, b) => {
34
+ const severityA = severityOrder[a.properties.severity] ?? 4;
35
+ const severityB = severityOrder[b.properties.severity] ?? 4;
36
+ return severityA - severityB;
37
+ });
38
+ for (const alert of sortedAlerts) {
39
+ const props = alert.properties;
40
+ // Severity emoji
41
+ const severityEmoji = props.severity === 'Extreme' ? '🔴' :
42
+ props.severity === 'Severe' ? '🟠' :
43
+ props.severity === 'Moderate' ? '🟡' :
44
+ props.severity === 'Minor' ? '🔵' : '⚪';
45
+ output += `${severityEmoji} **${props.event}**\n`;
46
+ output += `---\n`;
47
+ if (props.headline) {
48
+ output += `**${props.headline}**\n\n`;
49
+ }
50
+ output += `**Severity:** ${props.severity} | **Urgency:** ${props.urgency} | **Certainty:** ${props.certainty}\n`;
51
+ output += `**Area:** ${props.areaDesc}\n`;
52
+ output += `**Effective:** ${new Date(props.effective).toLocaleString()}\n`;
53
+ output += `**Expires:** ${new Date(props.expires).toLocaleString()}\n`;
54
+ if (props.onset && props.onset !== props.effective) {
55
+ output += `**Onset:** ${new Date(props.onset).toLocaleString()}\n`;
56
+ }
57
+ if (props.ends) {
58
+ output += `**Ends:** ${new Date(props.ends).toLocaleString()}\n`;
59
+ }
60
+ output += `\n**Description:**\n${props.description}\n`;
61
+ if (props.instruction) {
62
+ output += `\n**Instructions:**\n${props.instruction}\n`;
63
+ }
64
+ output += `\n**Recommended Response:** ${props.response}\n`;
65
+ output += `**Sender:** ${props.senderName}\n\n`;
66
+ }
67
+ }
68
+ output += `---\n`;
69
+ output += `*Data source: NOAA National Weather Service*\n`;
70
+ return {
71
+ content: [
72
+ {
73
+ type: 'text',
74
+ text: output
75
+ }
76
+ ]
77
+ };
78
+ }
79
+ //# sourceMappingURL=alertsHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alertsHandler.js","sourceRoot":"","sources":["../../src/handlers/alertsHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAQtF,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAa,EACb,WAAwB;IAExB,gDAAgD;IAChD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,uBAAuB,CACxC,IAAmB,EAAE,WAAW,EACjC,aAAa,EACb,IAAI,CACL,CAAC;IAEF,kBAAkB;IAClB,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IACjF,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC;IAEnC,gCAAgC;IAChC,IAAI,MAAM,GAAG,sBAAsB,CAAC;IACpC,MAAM,IAAI,iBAAiB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5E,MAAM,IAAI,eAAe,WAAW,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC;IAC/E,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,MAAM,IAAI,gBAAgB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,cAAc,EAA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AAU,MAAM,CAAC;QAClD,CAAC;IACH,CAAC;IAED,MAAM,IAAI,OAAO,CAAC;IAClB,MAAM,IAAI,gDAAgD,CAAC;IAE3D,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,MAAM;aACb;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Handler for get_current_conditions tool
3
+ */
4
+ import { NOAAService } from '../services/noaa.js';
5
+ export declare function handleGetCurrentConditions(args: unknown, noaaService: NOAAService): Promise<{
6
+ content: Array<{
7
+ type: string;
8
+ text: string;
9
+ }>;
10
+ }>;
11
+ //# sourceMappingURL=currentConditionsHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currentConditionsHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/currentConditionsHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKlD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAkL7D"}