get_tide_predictions
Retrieve tide prediction data for a specific station using customizable parameters like date range, datum, units, and output format. Supported formats include JSON, XML, and CSV.
Instructions
Get tide prediction data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| begin_date | No | Start date (YYYYMMDD or MM/DD/YYYY) | |
| date | No | Date to retrieve data for ("today", "latest", "recent", or specific date) | |
| datum | No | Datum to use (MLLW, MSL, etc.) | |
| end_date | No | End date (YYYYMMDD or MM/DD/YYYY) | |
| format | No | Output format (json, xml, csv) | |
| interval | No | Interval (hilo, hl, h, or a number for minutes) | |
| range | No | Number of hours to retrieve data for | |
| station | Yes | Station ID | |
| time_zone | No | Time zone (gmt, lst, lst_ldt) | |
| units | No | Units to use ("english" or "metric") |
Implementation Reference
- src/services/noaa-service.ts:84-89 (handler)Core handler function that executes the tool logic by fetching tide predictions from the NOAA API using the data getter endpoint with product set to 'predictions'.async getTidePredictions(params: Record<string, any>): Promise<any> { return this.fetchDataApi({ ...params, product: 'predictions' }); }
- src/interfaces/noaa.ts:33-47 (schema)Zod schema defining and validating the input parameters for the get_tide_predictions tool, including station, dates, range, datum, units, etc., with refinement for date parameters.export const GetTidePredictionsSchema = z.object({ station: StationSchema, begin_date: BeginDateSchema, end_date: EndDateSchema, date: DateSchema, range: RangeSchema, datum: DatumSchema, units: UnitsSchema, time_zone: TimeZoneSchema, interval: IntervalSchema, format: FormatSchema, }).refine( data => (data.date || (data.begin_date && data.end_date) || (data.begin_date && data.range) || (data.end_date && data.range) || data.range), { message: "You must provide either 'date', 'begin_date' and 'end_date', 'begin_date' and 'range', 'end_date' and 'range', or just 'range'" } );
- src/server/mcp-server.ts:43-51 (registration)Registration of the get_tide_predictions tool within the McpServer class, defining name, description, input schema, and handler that delegates to NoaaService.// Tide Predictions tool const getTidePredictions: MCPTool = { name: "get_tide_predictions", description: "Get tide prediction data", inputSchema: GetTidePredictionsSchema, handler: async (params) => { return this.noaaService.getTidePredictions(params); } };
- src/tools/water-tools.ts:52-79 (registration)Alternative registration of the get_tide_predictions tool using FastMCP's server.addTool method, with inline Zod schema and execute handler calling NoaaService.// Add tide predictions tool server.addTool({ name: 'get_tide_predictions', description: 'Get tide prediction data', parameters: z.object({ station: StationSchema, begin_date: BeginDateSchema, end_date: EndDateSchema, date: DateSchema, range: RangeSchema, datum: DatumSchema, units: UnitsSchema, time_zone: TimeZoneSchema, interval: IntervalSchema, format: FormatSchema, }).refine(refineDateParams, { message: dateRefinementMessage }), execute: async (params) => { try { const result = await noaaService.getTidePredictions(params); return JSON.stringify(result); } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get tide predictions: ${error.message}`); } throw new Error('Failed to get tide predictions'); } } });