Skip to main content
Glama
RyanCardin15

noaa-tidesandcurrents-mcp

get_next_sun_event

Calculate the next occurrence of a specific sun event (e.g., sunrise, sunset) for a given location and date using latitude, longitude, and optional timezone. Outputs in JSON or text format for easy integration.

Instructions

Get the next occurrence(s) of a specific sun event

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of occurrences to return. Defaults to 1.
dateNoStarting date (YYYY-MM-DD format). Defaults to current date.
eventYesSun event to find
formatNoOutput format (json or text)
latitudeYesLatitude for location-specific calculations
longitudeYesLongitude for location-specific calculations
timezoneNoTimezone for the results. Defaults to UTC.

Implementation Reference

  • The handler function that executes the tool logic: calls SunService.getNextSunEvent and returns formatted text or JSON output.
    execute: async (params) => {
      try {
        const results = sunService.getNextSunEvent(params);
        if (params.format === 'text') {
          return results.map(result => 
            `Next ${result.event}: ${result.date} at ${result.time}`
          ).join('\n');
        }
        return JSON.stringify(results);
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Failed to get next sun event: ${error.message}`);
        }
        throw new Error('Failed to get next sun event');
      }
    }
  • Registration of the get_next_sun_event tool with MCP server, specifying name, description, and input schema.
    // Add next sun event tool
    server.addTool({
      name: 'get_next_sun_event',
      description: 'Get the next occurrence(s) of a specific sun event',
      parameters: NextSunEventParamsSchema,
  • Zod schema for validating the tool's input parameters, including event type, optional date, location coordinates, count, format, and timezone.
    export const NextSunEventParamsSchema = z.object({
      event: z.nativeEnum(SunEventType).describe('Sun event to find'),
      date: z.string().optional().describe('Starting date (YYYY-MM-DD format). Defaults to current date.'),
      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'),
      count: z.number().positive().optional().describe('Number of occurrences to return. Defaults to 1.'),
      format: z.enum(['json', 'text']).optional().describe('Output format (json or text)'),
      timezone: z.string().optional().describe('Timezone for the results. Defaults to UTC.')
    });
    
    export type NextSunEventParams = z.infer<typeof NextSunEventParamsSchema>; 
  • Supporting utility in SunService that implements the core algorithm for finding the next sun events using SunCalc.getTimes in a loop until required count is reached.
    getNextSunEvent(params: NextSunEventParams): { date: string, time: string, event: string }[] {
      const startDate = params.date ? new Date(params.date) : new Date();
      const count = params.count !== undefined ? params.count : 1;
      const { latitude, longitude } = params;
      const timezone = params.timezone !== undefined ? params.timezone : 'UTC';
      
      const results: { date: string, time: string, event: string }[] = [];
      let currentDate = new Date(startDate);
      
      // Find the next occurrences
      while (results.length < count) {
        const sunTimes = SunCalc.getTimes(currentDate, latitude, longitude);
        const eventTime = sunTimes[params.event as keyof typeof sunTimes];
        
        if (eventTime && !isNaN(eventTime.getTime()) && eventTime > startDate) {
          let formattedTime: string;
          
          try {
            formattedTime = eventTime.toLocaleTimeString('en-US', { timeZone: timezone });
          } catch (error) {
            // If timezone is invalid, fall back to ISO string
            console.warn(`Invalid timezone: ${timezone}. Using UTC.`);
            formattedTime = eventTime.toISOString().split('T')[1].split('.')[0];
          }
          
          results.push({
            date: eventTime.toISOString().split('T')[0],
            time: formattedTime,
            event: params.event as string
          });
          
          // Move to next day to find the next occurrence
          currentDate.setDate(currentDate.getDate() + 1);
        } else {
          // Event not found for this day, try next day
          currentDate.setDate(currentDate.getDate() + 1);
        }
        
        // Safety check to prevent infinite loops
        if (results.length === 0 && currentDate.getTime() - startDate.getTime() > 366 * 24 * 60 * 60 * 1000) {
          throw new Error('Could not find the specified sun event within a year.');
        }
      }
      
      return results;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Get') but doesn't explain what 'next occurrence(s)' entails (e.g., time-based calculations, location dependency, or output format details). For a tool with 7 parameters and no annotations, this lacks critical behavioral context like error handling or performance traits.

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, clear sentence that efficiently conveys the core functionality without unnecessary words. It's front-loaded with the main action and resource, making it easy to grasp quickly, which is ideal for conciseness.

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 complexity (7 parameters, no output schema, and no annotations), the description is minimal. It states the purpose but lacks details on output format, error conditions, or how it integrates with sibling tools. While the schema covers parameters well, the description doesn't compensate for missing behavioral context, making it adequate but incomplete.

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?

The input schema has 100% description coverage, so parameters like 'event', 'latitude', and 'count' are well-documented in the schema. The description adds no additional semantic details beyond implying a sun event and occurrence count, which aligns with the schema but doesn't enhance understanding, meeting the baseline for high schema coverage.

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 verb ('Get') and resource ('next occurrence(s) of a specific sun event'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_sun_times' or 'get_sun_times_range', which might offer similar functionality, so it falls short of a perfect score.

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. With sibling tools like 'get_sun_times' and 'get_sun_times_range' available, there's no indication of how this tool differs in context or when it's the preferred choice, leaving usage ambiguous.

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