Skip to main content
Glama

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
NameRequiredDescriptionDefault
formatNoOutput format (json, xml)
typeNoStation type (waterlevels, currents, etc.)
unitsNoUnits to use ("english" or "metric")

Implementation Reference

  • 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); }
  • 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)'), });
  • 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); } };
  • 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'); } } });

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