Skip to main content
Glama
RyanCardin15

noaa-tidesandcurrents-mcp

get_sun_times_range

Retrieve sunrise, sunset, and other sun event times for a specific date range and location using latitude, longitude, and optional timezone, with output in JSON or text format.

Instructions

Get sun rise/set and other sun event times for a date range and location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_dateYesEnd date (YYYY-MM-DD format)
formatNoOutput format (json or text)
latitudeYesLatitude for location-specific calculations
longitudeYesLongitude for location-specific calculations
start_dateYesStart date (YYYY-MM-DD format)
timezoneNoTimezone for the results. Defaults to UTC.

Implementation Reference

  • Core handler function that computes sun times for a range of dates by iterating over each day and calling getSunTimes.
    getSunTimesRange(params: SunTimesRangeParams): SunTimesInfo[] {
      const startDate = new Date(params.start_date);
      const endDate = new Date(params.end_date);
      
      if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
        throw new Error('Invalid date format. Please use YYYY-MM-DD format.');
      }
      
      if (startDate > endDate) {
        throw new Error('Start date must be before end date.');
      }
      
      const result: SunTimesInfo[] = [];
      const currentDate = new Date(startDate);
      
      while (currentDate <= endDate) {
        result.push(this.getSunTimes({
          date: currentDate.toISOString().split('T')[0],
          latitude: params.latitude,
          longitude: params.longitude,
          timezone: params.timezone
        }));
        
        // Move to next day
        currentDate.setDate(currentDate.getDate() + 1);
      }
      
      return result;
    }
  • MCP tool registration: defines name, description, input schema, and execute function that calls the sun service handler and formats output.
    server.addTool({
      name: 'get_sun_times_range',
      description: 'Get sun rise/set and other sun event times for a date range and location',
      parameters: SunTimesRangeParamsSchema,
      execute: async (params) => {
        try {
          const results = sunService.getSunTimesRange(params);
          if (params.format === 'text') {
            let text = `Sun times from ${params.start_date} to ${params.end_date} at latitude ${params.latitude}, longitude ${params.longitude}:\n\n`;
            
            results.forEach(result => {
              text += `Date: ${result.date}\n`;
              text += `Sunrise: ${result.sunrise || 'N/A'}\n`;
              text += `Sunset: ${result.sunset || 'N/A'}\n`;
              text += `Day length: ${Math.floor(result.dayLength / 60)}h ${Math.round(result.dayLength % 60)}m\n\n`;
            });
            
            return text;
          }
          return JSON.stringify(results);
        } catch (error) {
          if (error instanceof Error) {
            throw new Error(`Failed to get sun times range: ${error.message}`);
          }
          throw new Error('Failed to get sun times range');
        }
      }
    });
  • Zod schema defining input parameters for the get_sun_times_range tool.
    export const SunTimesRangeParamsSchema = z.object({
      start_date: z.string().describe('Start date (YYYY-MM-DD format)'),
      end_date: z.string().describe('End date (YYYY-MM-DD format)'),
      latitude: z.number().min(-90).max(90).describe('Latitude for location-specific calculations'),
      longitude: z.number().min(-180).max(180).describe('Longitude for location-specific calculations'),
      format: z.enum(['json', 'text']).optional().describe('Output format (json or text)'),
      timezone: z.string().optional().describe('Timezone for the results. Defaults to UTC.')
    });
  • TypeScript interface defining the structure of sun times information returned by the tool.
    export interface SunTimesInfo {
      date: string;
      sunrise: string | null;
      sunset: string | null;
      solarNoon: string | null;
      dawn: string | null;
      dusk: string | null;
      nightStart: string | null;
      nightEnd: string | null;
      goldenHourStart: string | null;
      goldenHourEnd: string | null;
      nauticalDawn: string | null;
      nauticalDusk: string | null;
      astronomicalDawn: string | null;
      astronomicalDusk: string | null;
      dayLength: number; // in minutes
    }
  • Top-level registration call that invokes the sun tools registration function, instantiating SunService.
    registerSunTools(server, sunService);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves data ('Get'), implying a read-only operation, but doesn't clarify authentication needs, rate limits, error conditions, or what 'other sun event times' includes. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every element ('Get,' 'sun rise/set and other sun event times,' 'date range and location') earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (6 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and parameters indirectly, but lacks details on output format, error handling, or behavioral traits. Without annotations or output schema, more context would be helpful for an AI agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly (e.g., date formats, latitude/longitude ranges, timezone default). The description adds minimal value beyond the schema by mentioning 'date range and location,' which aligns with the required parameters. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get sun rise/set and other sun event times for a date range and location.' It specifies the action ('Get'), resource ('sun rise/set and other sun event times'), and scope ('date range and location'). However, it doesn't explicitly differentiate from sibling tools like 'get_sun_times' or 'get_next_sun_event', which likely have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_sun_times' (likely for a single date) or 'get_next_sun_event' (likely for the next event), nor does it specify prerequisites or exclusions. Usage is implied by the parameters but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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