get_top_ten_water_levels
Retrieve the top ten highest or lowest water levels for a NOAA tide station, specifying output format, units, and datum reference for analysis.
Instructions
Get top ten highest or lowest water levels for a station
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| analysis_type | No | Analysis type (highest or lowest) | |
| datum | No | Datum reference for DPAPI | |
| format | No | Output format (json, xml, csv) | |
| station | Yes | Station ID | |
| units | No | Units to use ("english" or "metric") |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "Get top ten water levels for a station",
"properties": {
"analysis_type": {
"description": "Analysis type (highest or lowest)",
"enum": [
"highest",
"lowest"
],
"type": "string"
},
"datum": {
"description": "Datum reference for DPAPI",
"enum": [
"STND",
"MLLW",
"MHHW",
"GT",
"MSL",
"MLW",
"MHW"
],
"type": "string"
},
"format": {
"description": "Output format (json, xml, csv)",
"enum": [
"json",
"xml",
"csv"
],
"type": "string"
},
"station": {
"description": "Station ID",
"minLength": 1,
"type": "string"
},
"units": {
"description": "Units to use (\"english\" or \"metric\")",
"enum": [
"english",
"metric"
],
"type": "string"
}
},
"required": [
"station"
],
"type": "object"
}
Implementation Reference
- The execute handler function for the 'get_top_ten_water_levels' tool. It calls the DpapiService.getTopTenWaterLevels method with the input params, stringifies the result, and handles errors by throwing descriptive messages.execute: async (params) => { try { const result = await dpapiService.getTopTenWaterLevels(params); return JSON.stringify(result); } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get top ten water levels: ${error.message}`); } throw new Error('Failed to get top ten water levels'); }
- src/schemas/dpapi.ts:93-99 (schema)Zod schema defining the input parameters for the 'get_top_ten_water_levels' tool, including required station, format, datum, units, and optional analysis_type.export const TopTenWaterLevelsSchema = z.object({ station: StationSchema, format: FormatSchema, datum: DpapiDatumSchema, units: UnitsSchema, analysis_type: z.enum(['highest', 'lowest']).optional().describe('Analysis type (highest or lowest)') }).describe('Get top ten water levels for a station');
- src/tools/derived-product-tools.ts:164-179 (registration)Registration of the 'get_top_ten_water_levels' tool via server.addTool within the registerDerivedProductTools function.server.addTool({ name: 'get_top_ten_water_levels', description: 'Get top ten highest or lowest water levels for a station', parameters: TopTenWaterLevelsSchema, execute: async (params) => { try { const result = await dpapiService.getTopTenWaterLevels(params); return JSON.stringify(result); } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get top ten water levels: ${error.message}`); } throw new Error('Failed to get top ten water levels'); } } });
- Helper method in DpapiService that prepares parameters and fetches data from the NOAA DPAPI /topten endpoint to get top ten water levels.async getTopTenWaterLevels(params: Record<string, any>): Promise<any> { const { station, format = 'json', ...rest } = params; return this.fetchDpapi('/topten', { station, format, ...rest }); }