@ryancardin/noaa-tides-currents-mcp-server 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.
Files changed (91) hide show
  1. package/.claude/settings.local.json +29 -0
  2. package/CLAUDE.md +71 -0
  3. package/Dockerfile +14 -0
  4. package/LICENSE +21 -0
  5. package/README.md +234 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +9 -0
  8. package/dist/interfaces/config.d.ts +6 -0
  9. package/dist/interfaces/config.js +1 -0
  10. package/dist/interfaces/moon.d.ts +65 -0
  11. package/dist/interfaces/moon.js +35 -0
  12. package/dist/interfaces/noaa.d.ts +334 -0
  13. package/dist/interfaces/noaa.js +98 -0
  14. package/dist/interfaces/parameters.d.ts +18 -0
  15. package/dist/interfaces/parameters.js +5 -0
  16. package/dist/interfaces/sun.d.ts +103 -0
  17. package/dist/interfaces/sun.js +45 -0
  18. package/dist/mcp-server.d.ts +12 -0
  19. package/dist/mcp-server.js +103 -0
  20. package/dist/moon-phase-service.d.ts +122 -0
  21. package/dist/moon-phase-service.js +187 -0
  22. package/dist/noaa-service.d.ts +60 -0
  23. package/dist/noaa-service.js +159 -0
  24. package/dist/schemas/common.d.ts +14 -0
  25. package/dist/schemas/common.js +18 -0
  26. package/dist/schemas/dpapi.d.ts +198 -0
  27. package/dist/schemas/dpapi.js +89 -0
  28. package/dist/server/config.d.ts +9 -0
  29. package/dist/server/config.js +40 -0
  30. package/dist/server/mcp-server.d.ts +12 -0
  31. package/dist/server/mcp-server.js +103 -0
  32. package/dist/services/dpapi-service.d.ts +72 -0
  33. package/dist/services/dpapi-service.js +164 -0
  34. package/dist/services/moon-phase-service.d.ts +34 -0
  35. package/dist/services/moon-phase-service.js +147 -0
  36. package/dist/services/noaa-parameters-service.d.ts +76 -0
  37. package/dist/services/noaa-parameters-service.js +128 -0
  38. package/dist/services/noaa-service.d.ts +52 -0
  39. package/dist/services/noaa-service.js +151 -0
  40. package/dist/services/sun-service.d.ts +60 -0
  41. package/dist/services/sun-service.js +234 -0
  42. package/dist/sun-service.d.ts +184 -0
  43. package/dist/sun-service.js +218 -0
  44. package/dist/tools/derived-product-tools.d.ts +6 -0
  45. package/dist/tools/derived-product-tools.js +168 -0
  46. package/dist/tools/index.d.ts +16 -0
  47. package/dist/tools/index.js +36 -0
  48. package/dist/tools/moon-tools.d.ts +6 -0
  49. package/dist/tools/moon-tools.js +69 -0
  50. package/dist/tools/parameter-tools.d.ts +6 -0
  51. package/dist/tools/parameter-tools.js +77 -0
  52. package/dist/tools/station-tools.d.ts +6 -0
  53. package/dist/tools/station-tools.js +51 -0
  54. package/dist/tools/sun-tools.d.ts +6 -0
  55. package/dist/tools/sun-tools.js +109 -0
  56. package/dist/tools/water-tools.d.ts +6 -0
  57. package/dist/tools/water-tools.js +150 -0
  58. package/dist/types/moon.d.ts +26 -0
  59. package/dist/types/moon.js +14 -0
  60. package/dist/types/sun.d.ts +49 -0
  61. package/dist/types/sun.js +19 -0
  62. package/dist/types.d.ts +337 -0
  63. package/dist/types.js +98 -0
  64. package/package.json +56 -0
  65. package/smithery.yaml +16 -0
  66. package/src/index.ts +13 -0
  67. package/src/interfaces/moon.ts +44 -0
  68. package/src/interfaces/noaa.ts +130 -0
  69. package/src/interfaces/parameters.ts +20 -0
  70. package/src/interfaces/sun.ts +57 -0
  71. package/src/schemas/common.ts +23 -0
  72. package/src/schemas/dpapi.ts +99 -0
  73. package/src/server/config.ts +43 -0
  74. package/src/server/mcp-server.ts +135 -0
  75. package/src/services/dpapi-service.ts +187 -0
  76. package/src/services/moon-phase-service.ts +167 -0
  77. package/src/services/noaa-parameters-service.ts +139 -0
  78. package/src/services/noaa-service.ts +171 -0
  79. package/src/services/sun-service.ts +275 -0
  80. package/src/tools/derived-product-tools.ts +180 -0
  81. package/src/tools/index.ts +40 -0
  82. package/src/tools/moon-tools.ts +79 -0
  83. package/src/tools/parameter-tools.ts +82 -0
  84. package/src/tools/station-tools.ts +57 -0
  85. package/src/tools/sun-tools.ts +120 -0
  86. package/src/tools/water-tools.ts +166 -0
  87. package/src/types/moon.ts +27 -0
  88. package/src/types/sun.ts +51 -0
  89. package/src/types/suncalc.d.ts +110 -0
  90. package/test-dpapi.js +0 -0
  91. package/tsconfig.json +15 -0
@@ -0,0 +1,6 @@
1
+ import { FastMCP } from 'fastmcp';
2
+ import { SunService } from '../services/sun-service.js';
3
+ /**
4
+ * Register sun-related tools with the MCP server
5
+ */
6
+ export declare function registerSunTools(server: FastMCP, sunService: SunService): void;
@@ -0,0 +1,109 @@
1
+ import { SunTimesParamsSchema, SunTimesRangeParamsSchema, SunPositionParamsSchema, NextSunEventParamsSchema } from '../interfaces/sun.js';
2
+ /**
3
+ * Register sun-related tools with the MCP server
4
+ */
5
+ export function registerSunTools(server, sunService) {
6
+ // Add sun times tool
7
+ server.addTool({
8
+ name: 'get_sun_times',
9
+ description: 'Get sun rise/set and other sun event times for a specific date and location',
10
+ parameters: SunTimesParamsSchema,
11
+ execute: async (params) => {
12
+ try {
13
+ const result = sunService.getSunTimes(params);
14
+ if (params.format === 'text') {
15
+ let text = `Sun times for ${result.date} at latitude ${params.latitude}, longitude ${params.longitude}:\n`;
16
+ text += `Sunrise: ${result.sunrise || 'N/A'}\n`;
17
+ text += `Sunset: ${result.sunset || 'N/A'}\n`;
18
+ text += `Day length: ${Math.floor(result.dayLength / 60)}h ${Math.round(result.dayLength % 60)}m\n`;
19
+ text += `Solar noon: ${result.solarNoon || 'N/A'}\n`;
20
+ text += `Dawn: ${result.dawn || 'N/A'}\n`;
21
+ text += `Dusk: ${result.dusk || 'N/A'}\n`;
22
+ return text;
23
+ }
24
+ return JSON.stringify(result);
25
+ }
26
+ catch (error) {
27
+ if (error instanceof Error) {
28
+ throw new Error(`Failed to get sun times: ${error.message}`);
29
+ }
30
+ throw new Error('Failed to get sun times');
31
+ }
32
+ }
33
+ });
34
+ // Add sun times range tool
35
+ server.addTool({
36
+ name: 'get_sun_times_range',
37
+ description: 'Get sun rise/set and other sun event times for a date range and location',
38
+ parameters: SunTimesRangeParamsSchema,
39
+ execute: async (params) => {
40
+ try {
41
+ const results = sunService.getSunTimesRange(params);
42
+ if (params.format === 'text') {
43
+ let text = `Sun times from ${params.start_date} to ${params.end_date} at latitude ${params.latitude}, longitude ${params.longitude}:\n\n`;
44
+ results.forEach(result => {
45
+ text += `Date: ${result.date}\n`;
46
+ text += `Sunrise: ${result.sunrise || 'N/A'}\n`;
47
+ text += `Sunset: ${result.sunset || 'N/A'}\n`;
48
+ text += `Day length: ${Math.floor(result.dayLength / 60)}h ${Math.round(result.dayLength % 60)}m\n\n`;
49
+ });
50
+ return text;
51
+ }
52
+ return JSON.stringify(results);
53
+ }
54
+ catch (error) {
55
+ if (error instanceof Error) {
56
+ throw new Error(`Failed to get sun times range: ${error.message}`);
57
+ }
58
+ throw new Error('Failed to get sun times range');
59
+ }
60
+ }
61
+ });
62
+ // Add sun position tool
63
+ server.addTool({
64
+ name: 'get_sun_position',
65
+ description: 'Get sun position information for a specific date, time, and location',
66
+ parameters: SunPositionParamsSchema,
67
+ execute: async (params) => {
68
+ try {
69
+ const result = sunService.getSunPosition(params);
70
+ if (params.format === 'text') {
71
+ let text = `Sun position for ${result.date} ${result.time} at latitude ${params.latitude}, longitude ${params.longitude}:\n`;
72
+ text += `Azimuth: ${result.azimuth.toFixed(2)}°\n`;
73
+ text += `Altitude: ${result.altitude.toFixed(2)}°\n`;
74
+ text += `Declination: ${result.declination.toFixed(2)}°\n`;
75
+ text += `Right Ascension: ${result.rightAscension.toFixed(2)}h\n`;
76
+ return text;
77
+ }
78
+ return JSON.stringify(result);
79
+ }
80
+ catch (error) {
81
+ if (error instanceof Error) {
82
+ throw new Error(`Failed to get sun position: ${error.message}`);
83
+ }
84
+ throw new Error('Failed to get sun position');
85
+ }
86
+ }
87
+ });
88
+ // Add next sun event tool
89
+ server.addTool({
90
+ name: 'get_next_sun_event',
91
+ description: 'Get the next occurrence(s) of a specific sun event',
92
+ parameters: NextSunEventParamsSchema,
93
+ execute: async (params) => {
94
+ try {
95
+ const results = sunService.getNextSunEvent(params);
96
+ if (params.format === 'text') {
97
+ return results.map(result => `Next ${result.event}: ${result.date} at ${result.time}`).join('\n');
98
+ }
99
+ return JSON.stringify(results);
100
+ }
101
+ catch (error) {
102
+ if (error instanceof Error) {
103
+ throw new Error(`Failed to get next sun event: ${error.message}`);
104
+ }
105
+ throw new Error('Failed to get next sun event');
106
+ }
107
+ }
108
+ });
109
+ }
@@ -0,0 +1,6 @@
1
+ import { FastMCP } from 'fastmcp';
2
+ import { NoaaService } from '../services/noaa-service.js';
3
+ /**
4
+ * Register water-related tools with the MCP server
5
+ */
6
+ export declare function registerWaterTools(server: FastMCP, noaaService: NoaaService): void;
@@ -0,0 +1,150 @@
1
+ import { z } from 'zod';
2
+ import { StationSchema, DateSchema, BeginDateSchema, EndDateSchema, RangeSchema, DatumSchema, UnitsSchema, TimeZoneSchema, FormatSchema, BinSchema, IntervalSchema, refineDateParams, dateRefinementMessage } from '../schemas/common.js';
3
+ /**
4
+ * Register water-related tools with the MCP server
5
+ */
6
+ export function registerWaterTools(server, noaaService) {
7
+ // Add water levels tool
8
+ server.addTool({
9
+ name: 'get_water_levels',
10
+ description: 'Get water level data for a station',
11
+ parameters: z.object({
12
+ station: StationSchema,
13
+ date: DateSchema,
14
+ begin_date: BeginDateSchema,
15
+ end_date: EndDateSchema,
16
+ range: RangeSchema,
17
+ datum: DatumSchema,
18
+ units: UnitsSchema,
19
+ time_zone: TimeZoneSchema,
20
+ format: FormatSchema,
21
+ }).refine(refineDateParams, { message: dateRefinementMessage }),
22
+ execute: async (params) => {
23
+ try {
24
+ const result = await noaaService.getWaterLevels(params);
25
+ return JSON.stringify(result);
26
+ }
27
+ catch (error) {
28
+ if (error instanceof Error) {
29
+ throw new Error(`Failed to get water levels: ${error.message}`);
30
+ }
31
+ throw new Error('Failed to get water levels');
32
+ }
33
+ }
34
+ });
35
+ // Add tide predictions tool
36
+ server.addTool({
37
+ name: 'get_tide_predictions',
38
+ description: 'Get tide prediction data',
39
+ parameters: z.object({
40
+ station: StationSchema,
41
+ begin_date: BeginDateSchema,
42
+ end_date: EndDateSchema,
43
+ date: DateSchema,
44
+ range: RangeSchema,
45
+ datum: DatumSchema,
46
+ units: UnitsSchema,
47
+ time_zone: TimeZoneSchema,
48
+ interval: IntervalSchema,
49
+ format: FormatSchema,
50
+ }).refine(refineDateParams, { message: dateRefinementMessage }),
51
+ execute: async (params) => {
52
+ try {
53
+ const result = await noaaService.getTidePredictions(params);
54
+ return JSON.stringify(result);
55
+ }
56
+ catch (error) {
57
+ if (error instanceof Error) {
58
+ throw new Error(`Failed to get tide predictions: ${error.message}`);
59
+ }
60
+ throw new Error('Failed to get tide predictions');
61
+ }
62
+ }
63
+ });
64
+ // Add currents tool
65
+ server.addTool({
66
+ name: 'get_currents',
67
+ description: 'Get currents data for a station',
68
+ parameters: z.object({
69
+ station: StationSchema,
70
+ date: DateSchema,
71
+ begin_date: BeginDateSchema,
72
+ end_date: EndDateSchema,
73
+ range: RangeSchema,
74
+ bin: BinSchema,
75
+ units: UnitsSchema,
76
+ time_zone: TimeZoneSchema,
77
+ format: FormatSchema,
78
+ }).refine(refineDateParams, { message: dateRefinementMessage }),
79
+ execute: async (params) => {
80
+ try {
81
+ const result = await noaaService.getCurrents(params);
82
+ return JSON.stringify(result);
83
+ }
84
+ catch (error) {
85
+ if (error instanceof Error) {
86
+ throw new Error(`Failed to get currents: ${error.message}`);
87
+ }
88
+ throw new Error('Failed to get currents');
89
+ }
90
+ }
91
+ });
92
+ // Add current predictions tool
93
+ server.addTool({
94
+ name: 'get_current_predictions',
95
+ description: 'Get current predictions',
96
+ parameters: z.object({
97
+ station: StationSchema,
98
+ date: DateSchema,
99
+ begin_date: BeginDateSchema,
100
+ end_date: EndDateSchema,
101
+ range: RangeSchema,
102
+ bin: BinSchema,
103
+ interval: z.string().optional().describe('Interval (MAX_SLACK or a number for minutes)'),
104
+ vel_type: z.enum(['speed_dir', 'default']).optional().describe('Velocity type (speed_dir or default)'),
105
+ units: UnitsSchema,
106
+ time_zone: TimeZoneSchema,
107
+ format: FormatSchema,
108
+ }).refine(refineDateParams, { message: dateRefinementMessage }),
109
+ execute: async (params) => {
110
+ try {
111
+ const result = await noaaService.getCurrentPredictions(params);
112
+ return JSON.stringify(result);
113
+ }
114
+ catch (error) {
115
+ if (error instanceof Error) {
116
+ throw new Error(`Failed to get current predictions: ${error.message}`);
117
+ }
118
+ throw new Error('Failed to get current predictions');
119
+ }
120
+ }
121
+ });
122
+ // Add meteorological data tool
123
+ server.addTool({
124
+ name: 'get_meteorological_data',
125
+ description: 'Get meteorological data',
126
+ parameters: z.object({
127
+ station: StationSchema,
128
+ product: z.string().min(1).describe('Product (air_temperature, wind, etc.)'),
129
+ date: DateSchema,
130
+ begin_date: BeginDateSchema,
131
+ end_date: EndDateSchema,
132
+ range: RangeSchema,
133
+ units: UnitsSchema,
134
+ time_zone: TimeZoneSchema,
135
+ format: FormatSchema,
136
+ }).refine(refineDateParams, { message: dateRefinementMessage }),
137
+ execute: async (params) => {
138
+ try {
139
+ const result = await noaaService.getMeteorologicalData(params);
140
+ return JSON.stringify(result);
141
+ }
142
+ catch (error) {
143
+ if (error instanceof Error) {
144
+ throw new Error(`Failed to get meteorological data: ${error.message}`);
145
+ }
146
+ throw new Error('Failed to get meteorological data');
147
+ }
148
+ }
149
+ });
150
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Moon phase names and their approximate ranges
3
+ */
4
+ export declare enum MoonPhaseName {
5
+ NEW_MOON = "New Moon",
6
+ WAXING_CRESCENT = "Waxing Crescent",
7
+ FIRST_QUARTER = "First Quarter",
8
+ WAXING_GIBBOUS = "Waxing Gibbous",
9
+ FULL_MOON = "Full Moon",
10
+ WANING_GIBBOUS = "Waning Gibbous",
11
+ LAST_QUARTER = "Last Quarter",
12
+ WANING_CRESCENT = "Waning Crescent"
13
+ }
14
+ /**
15
+ * Moon phase information
16
+ */
17
+ export interface MoonPhaseInfo {
18
+ date: string;
19
+ phase: number;
20
+ phaseName: MoonPhaseName;
21
+ illumination: number;
22
+ age: number;
23
+ distance: number;
24
+ diameter: number;
25
+ isWaxing: boolean;
26
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Moon phase names and their approximate ranges
3
+ */
4
+ export var MoonPhaseName;
5
+ (function (MoonPhaseName) {
6
+ MoonPhaseName["NEW_MOON"] = "New Moon";
7
+ MoonPhaseName["WAXING_CRESCENT"] = "Waxing Crescent";
8
+ MoonPhaseName["FIRST_QUARTER"] = "First Quarter";
9
+ MoonPhaseName["WAXING_GIBBOUS"] = "Waxing Gibbous";
10
+ MoonPhaseName["FULL_MOON"] = "Full Moon";
11
+ MoonPhaseName["WANING_GIBBOUS"] = "Waning Gibbous";
12
+ MoonPhaseName["LAST_QUARTER"] = "Last Quarter";
13
+ MoonPhaseName["WANING_CRESCENT"] = "Waning Crescent";
14
+ })(MoonPhaseName || (MoonPhaseName = {}));
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Sun event types
3
+ */
4
+ export declare enum SunEventType {
5
+ SUNRISE = "sunrise",
6
+ SUNSET = "sunset",
7
+ DAWN = "dawn",
8
+ DUSK = "dusk",
9
+ SOLAR_NOON = "solarNoon",
10
+ NIGHT_START = "night",
11
+ NIGHT_END = "nightEnd",
12
+ GOLDEN_HOUR_START = "goldenHourStart",
13
+ GOLDEN_HOUR_END = "goldenHourEnd",
14
+ NAUTICAL_DAWN = "nauticalDawn",
15
+ NAUTICAL_DUSK = "nauticalDusk",
16
+ ASTRONOMICAL_DAWN = "astronomicalDawn",
17
+ ASTRONOMICAL_DUSK = "astronomicalDusk"
18
+ }
19
+ /**
20
+ * Sun times information
21
+ */
22
+ export interface SunTimesInfo {
23
+ date: string;
24
+ sunrise: string | null;
25
+ sunset: string | null;
26
+ solarNoon: string | null;
27
+ dawn: string | null;
28
+ dusk: string | null;
29
+ nightStart: string | null;
30
+ nightEnd: string | null;
31
+ goldenHourStart: string | null;
32
+ goldenHourEnd: string | null;
33
+ nauticalDawn: string | null;
34
+ nauticalDusk: string | null;
35
+ astronomicalDawn: string | null;
36
+ astronomicalDusk: string | null;
37
+ dayLength: number;
38
+ }
39
+ /**
40
+ * Sun position information
41
+ */
42
+ export interface SunPositionInfo {
43
+ date: string;
44
+ time: string;
45
+ azimuth: number;
46
+ altitude: number;
47
+ declination: number;
48
+ rightAscension: number;
49
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Sun event types
3
+ */
4
+ export var SunEventType;
5
+ (function (SunEventType) {
6
+ SunEventType["SUNRISE"] = "sunrise";
7
+ SunEventType["SUNSET"] = "sunset";
8
+ SunEventType["DAWN"] = "dawn";
9
+ SunEventType["DUSK"] = "dusk";
10
+ SunEventType["SOLAR_NOON"] = "solarNoon";
11
+ SunEventType["NIGHT_START"] = "night";
12
+ SunEventType["NIGHT_END"] = "nightEnd";
13
+ SunEventType["GOLDEN_HOUR_START"] = "goldenHourStart";
14
+ SunEventType["GOLDEN_HOUR_END"] = "goldenHourEnd";
15
+ SunEventType["NAUTICAL_DAWN"] = "nauticalDawn";
16
+ SunEventType["NAUTICAL_DUSK"] = "nauticalDusk";
17
+ SunEventType["ASTRONOMICAL_DAWN"] = "astronomicalDawn";
18
+ SunEventType["ASTRONOMICAL_DUSK"] = "astronomicalDusk";
19
+ })(SunEventType || (SunEventType = {}));