Skip to main content
Glama

get_water_levels

Retrieve water level data for a specific NOAA station using station ID, date range, time zone, and output format. Supports custom parameters like datum and units for accurate results.

Instructions

Get water level data for a station

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
begin_dateNoStart date (YYYYMMDD or MM/DD/YYYY)
dateNoDate to retrieve data for ("today", "latest", "recent", or specific date)
datumNoDatum to use (MLLW, MSL, etc.)
end_dateNoEnd date (YYYYMMDD or MM/DD/YYYY)
formatNoOutput format (json, xml, csv)
rangeNoNumber of hours to retrieve data for
stationYesStation ID
time_zoneNoTime zone (gmt, lst, lst_ldt)
unitsNoUnits to use ("english" or "metric")

Implementation Reference

  • The core handler function that implements the logic for fetching water levels from the NOAA API by setting product: 'water_level' and calling fetchDataApi.
    async getWaterLevels(params: Record<string, any>): Promise<any> { return this.fetchDataApi({ ...params, product: 'water_level' }); }
  • Zod schema defining the input parameters for the get_water_levels tool, including validation refinement for date parameters.
    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'" } );
  • Registration of the get_water_levels tool using FastMCP server.addTool, including inline schema and execute handler that wraps noaaService.getWaterLevels.
    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'); } } });
  • Definition and registration of the get_water_levels MCPTool in McpServer class, using GetWaterLevelsSchema and handler wrapping noaaService.getWaterLevels.
    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); } };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/RyanCardin15/NOAA'

If you have feedback or need assistance with the MCP directory API, please join our Discord server