Skip to main content
Glama
RyanCardin15

LocalTides MCP Server

get_next_sun_event

Retrieve the next occurrence(s) of sun events like sunrise, sunset, or dawn for a specific location and date. Supports custom time zones and outputs in JSON or text formats.

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

  • Registration of the get_next_sun_event MCP tool, including name, description, parameters schema reference, and execute handler function.
    server.addTool({
      name: 'get_next_sun_event',
      description: 'Get the next occurrence(s) of a specific sun event',
      parameters: NextSunEventParamsSchema,
      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');
        }
      }
    });
  • MCP tool handler (execute function): delegates to SunService.getNextSunEvent(params), then formats results as text list or JSON based on params.format.
    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');
      }
    }
  • Zod input schema (NextSunEventParamsSchema) defining parameters for the tool: event type, optional start date/count/format/timezone, required lat/lng.
    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.')
    });
  • SunService.getNextSunEvent helper method: loops from start date, uses SunCalc.getTimes to find future occurrences of specified event (sunrise/sunset/etc.), formats with timezone, returns up to 'count' results.
    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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'Get[s] the next occurrence(s)' but doesn't clarify whether this is a read-only operation, if it requires specific permissions, what the output looks like, or any rate limits. The description is minimal and lacks behavioral context.

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. There is no wasted language, and it's appropriately sized for the tool's complexity.

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 (7 parameters, no output schema, no annotations), the description is minimally adequate. It states the purpose but lacks behavioral details, usage guidelines, and output information. With no annotations and no output schema, the description should do more to compensate.

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. The description adds no additional meaning beyond what the schema provides, such as explaining the relationship between parameters or usage examples. Baseline 3 is appropriate when 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 with a specific verb ('Get') and resource ('next occurrence(s) of a specific sun event'). It distinguishes itself from siblings by focusing on sun events rather than tides, water levels, or moon phases, though it doesn't explicitly differentiate from get_sun_times or get_sun_times_range.

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?

No guidance is provided on when to use this tool versus alternatives like get_sun_times or get_sun_times_range. The description implies usage for future sun event calculations but lacks explicit context, prerequisites, or exclusions.

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-TidesAndCurrents-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server