get_water_levels
Retrieve accurate water level data for specific stations using NOAA Tides and Currents API. Specify station ID, date range, units, and output format for tailored results. Ideal for monitoring tidal patterns and coastal conditions.
Instructions
Get water level data for a station
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) | |
| 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:74-79 (handler)Core handler function that fetches water level data from the NOAA API by adding the 'water_level' product parameter and calling fetchDataApi.async getWaterLevels(params: Record<string, any>): Promise<any> { return this.fetchDataApi({ ...params, product: 'water_level' }); }
- src/interfaces/noaa.ts:17-30 (schema)Zod schema defining the input parameters and validation for the get_water_levels tool.export const GetWaterLevelsSchema = z.object({ station: StationSchema, date: DateSchema, begin_date: BeginDateSchema, end_date: EndDateSchema, range: RangeSchema, datum: DatumSchema, units: UnitsSchema, time_zone: TimeZoneSchema, 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:34-41 (registration)Registration of the get_water_levels tool in the MCP server class, including name, description, schema, and handler that delegates to NoaaService.const getWaterLevels: MCPTool = { name: "get_water_levels", description: "Get water level data for a station", inputSchema: GetWaterLevelsSchema, handler: async (params) => { return this.noaaService.getWaterLevels(params); } };
- src/tools/water-tools.ts:25-50 (registration)Alternative registration of the get_water_levels tool using FastMCP server.addTool, with inline schema and execute handler calling NoaaService.server.addTool({ name: 'get_water_levels', description: 'Get water level data for a station', parameters: z.object({ station: StationSchema, date: DateSchema, begin_date: BeginDateSchema, end_date: EndDateSchema, range: RangeSchema, datum: DatumSchema, units: UnitsSchema, time_zone: TimeZoneSchema, format: FormatSchema, }).refine(refineDateParams, { message: dateRefinementMessage }), execute: async (params) => { try { const result = await noaaService.getWaterLevels(params); return JSON.stringify(result); } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get water levels: ${error.message}`); } throw new Error('Failed to get water levels'); } } });