Skip to main content
Glama
RyanCardin15

LocalTides MCP Server

get_next_moon_phase

Calculate the next occurrence of a specific moon phase (New Moon, First Quarter, Full Moon, Last Quarter) starting from a given date. Specify the number of occurrences and output format (json or text) for precise astronomical planning.

Instructions

Get the next occurrence(s) of a specific moon phase

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of occurrences to return. Defaults to 1.
dateNoStarting date (YYYY-MM-DD format). Defaults to current date.
formatNoOutput format (json or text)
phaseYesMoon phase to find

Implementation Reference

  • Core handler function that computes the next moon phase dates by iterating daily and detecting phase transitions using SunCalc.getMoonIllumination.
    getNextMoonPhase(params: NextMoonPhaseParams): { date: string, phase: string }[] {
      const startDate = params.date ? new Date(params.date) : new Date();
      const count = params.count || 1;
      const targetPhase = params.phase;
      
      // Map phase names to their approximate values
      const phaseValues: Record<string, number> = {
        [MoonPhaseName.NEW_MOON]: 0,
        [MoonPhaseName.FIRST_QUARTER]: 0.25,
        [MoonPhaseName.FULL_MOON]: 0.5,
        [MoonPhaseName.LAST_QUARTER]: 0.75
      };
      
      const targetPhaseValue = phaseValues[targetPhase];
      const results: { date: string, phase: string }[] = [];
      let currentDate = new Date(startDate);
      
      // Find the next occurrences
      while (results.length < count) {
        // Check every day (could be optimized with better algorithms)
        const illuminationData = SunCalc.getMoonIllumination(currentDate);
        const prevDate = new Date(currentDate);
        prevDate.setDate(prevDate.getDate() - 1);
        const prevIlluminationData = SunCalc.getMoonIllumination(prevDate);
        
        // Check if we've passed the target phase between yesterday and today
        const prevDiff = Math.abs(prevIlluminationData.phase - targetPhaseValue);
        const currentDiff = Math.abs(illuminationData.phase - targetPhaseValue);
        
        // If we're getting closer to the target phase and then further away, we've passed it
        // Or if we're very close to the target phase (within 0.01)
        if ((prevDiff > currentDiff && currentDiff < 0.01) || currentDiff < 0.005) {
          results.push({
            date: currentDate.toISOString().split('T')[0],
            phase: targetPhase
          });
        }
        
        // Move to 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 moon phase within a year.');
        }
      }
      
      return results;
    }
  • Registers the 'get_next_moon_phase' tool with the MCP server, providing schema, description, and execute handler that delegates to MoonPhaseService.
    server.addTool({
      name: 'get_next_moon_phase',
      description: 'Get the next occurrence(s) of a specific moon phase',
      parameters: NextMoonPhaseParamsSchema,
      execute: async (params) => {
        try {
          const results = moonPhaseService.getNextMoonPhase(params);
          if (params.format === 'text') {
            return results.map(result => 
              `Next ${result.phase}: ${result.date}`
            ).join('\n');
          }
          return JSON.stringify(results);
        } catch (error) {
          if (error instanceof Error) {
            throw new Error(`Failed to get next moon phase: ${error.message}`);
          }
          throw new Error('Failed to get next moon phase');
        }
      }
    });
  • Zod schema defining input parameters for the get_next_moon_phase tool, including phase type, optional start date, count, and output format.
    export const NextMoonPhaseParamsSchema = z.object({
      phase: z.enum([
        MoonPhaseName.NEW_MOON,
        MoonPhaseName.FIRST_QUARTER,
        MoonPhaseName.FULL_MOON,
        MoonPhaseName.LAST_QUARTER
      ]).describe('Moon phase to find'),
      date: z.string().optional().describe('Starting date (YYYY-MM-DD format). Defaults to current date.'),
      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)')
    });
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 mentions the tool returns 'next occurrence(s)' but doesn't specify whether results are sorted, if there are rate limits, error conditions, or what the output format looks like (beyond the 'format' parameter). For a tool with no annotation coverage, this leaves significant behavioral gaps.

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 communicates the core functionality without any wasted words. It's appropriately sized and front-loaded with the essential information.

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?

For a tool with 4 parameters, 100% schema coverage, but no annotations and no output schema, the description is minimally adequate. It states what the tool does but doesn't provide enough context about behavior, output format, or differentiation from similar tools. The completeness is borderline for a tool of this complexity.

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 schema description coverage is 100%, so all parameters are documented in the schema. The description doesn't add any meaningful parameter semantics beyond what's already in the schema (like explaining what 'phase' means or how 'count' affects results). The baseline of 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 action ('Get the next occurrence(s)') and resource ('specific moon phase'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from its sibling 'get_moon_phase' or 'get_moon_phases_range', which appears to be a similar moon phase tool.

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 like 'get_moon_phase' or 'get_moon_phases_range'. There's no mention of prerequisites, limitations, or comparative context with sibling tools.

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