get_stations
Retrieve a list of NOAA tide and current stations by specifying station type, output format, and units for accurate data access and integration.
Instructions
Get list of stations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (json, xml) | |
| type | No | Station type (waterlevels, currents, etc.) | |
| units | No | Units to use ("english" or "metric") |
Implementation Reference
- src/services/noaa-service.ts:125-160 (handler)Core handler function that implements the logic to fetch NOAA stations list using metadata API with filtering, pagination, and sorting parameters.async getStations(params: Record<string, any>): Promise<any> { const { type, name, lat_min, lat_max, lon_min, lon_max, state, limit, offset, sort_by, sort_order, ...rest } = params; const endpoint = '/stations.' + (rest.format || 'json'); // Build query parameters with all the filters const queryParams: Record<string, any> = { ...rest }; // Add filters only if they are defined if (type) queryParams.type = type; if (name) queryParams.name = name; if (lat_min !== undefined) queryParams.lat_min = lat_min; if (lat_max !== undefined) queryParams.lat_max = lat_max; if (lon_min !== undefined) queryParams.lon_min = lon_min; if (lon_max !== undefined) queryParams.lon_max = lon_max; if (state) queryParams.state = state; if (limit !== undefined) queryParams.limit = limit; if (offset !== undefined) queryParams.offset = offset; if (sort_by) queryParams.sort_by = sort_by; if (sort_order) queryParams.sort_order = sort_order; return this.fetchMetadataApi(endpoint, queryParams); }
- src/interfaces/noaa.ts:100-114 (schema)Zod schema defining input parameters for the get_stations tool, including filters like type, location bounds, state, pagination, and sorting.export const GetStationsSchema = z.object({ type: z.string().optional().describe('Station type (waterlevels, currents, etc.)'), units: UnitsSchema, format: z.enum(['json', 'xml']).optional().describe('Output format (json, xml)'), name: z.string().optional().describe('Filter stations by name (partial match)'), lat_min: z.number().optional().describe('Minimum latitude boundary'), lat_max: z.number().optional().describe('Maximum latitude boundary'), lon_min: z.number().optional().describe('Minimum longitude boundary'), lon_max: z.number().optional().describe('Maximum longitude boundary'), state: z.string().optional().describe('Filter stations by state code (e.g., CA, NY)'), limit: z.number().optional().describe('Maximum number of stations to return'), offset: z.number().optional().describe('Number of stations to skip for pagination'), sort_by: z.enum(['name', 'id', 'state']).optional().describe('Field to sort results by'), sort_order: z.enum(['asc', 'desc']).optional().describe('Sort order (ascending or descending)'), });
- src/server/mcp-server.ts:84-91 (registration)Registers the get_stations tool in the MCP server by defining MCPTool with name, description, input schema, and handler that delegates to NoaaService.getStations.const getStations: MCPTool = { name: "get_stations", description: "Get list of stations", inputSchema: GetStationsSchema, handler: async (params) => { return this.noaaService.getStations(params); } };
- src/tools/station-tools.ts:15-34 (registration)Alternative registration of get_stations tool using FastMCP.addTool, with inline schema and execute handler calling NoaaService.getStations.server.addTool({ name: 'get_stations', description: 'Get list of stations', parameters: z.object({ type: z.string().optional().describe('Station type (waterlevels, currents, etc.)'), format: z.enum(['json', 'xml']).optional().describe('Output format (json, xml)'), units: UnitsSchema, }), execute: async (params) => { try { const result = await noaaService.getStations(params); return JSON.stringify(result); } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get stations: ${error.message}`); } throw new Error('Failed to get stations'); } } });