Skip to main content
Glama
RyanCardin15

noaa-tidesandcurrents-mcp

get_moon_phase

Retrieve moon phase details for a specific date and location using NOAA Tides and Currents data. Input date, latitude, longitude, and format (json/text) to get accurate lunar phase information.

Instructions

Get moon phase information for a specific date

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoDate to get moon phase for (YYYY-MM-DD format). Defaults to current date.
formatNoOutput format (json or text)
latitudeNoLatitude for location-specific calculations
longitudeNoLongitude for location-specific calculations

Implementation Reference

  • Registration of the 'get_moon_phase' tool, including its handler function that delegates to MoonPhaseService and handles text/json formatting
    server.addTool({
      name: 'get_moon_phase',
      description: 'Get moon phase information for a specific date',
      parameters: MoonPhaseParamsSchema,
      execute: async (params) => {
        try {
          const result = moonPhaseService.getMoonPhase(params);
          if (params.format === 'text') {
            return `Moon phase for ${result.date}: ${result.phaseName} (${(result.illumination * 100).toFixed(1)}% illuminated)`;
          }
          return JSON.stringify(result);
        } catch (error) {
          if (error instanceof Error) {
            throw new Error(`Failed to get moon phase: ${error.message}`);
          }
          throw new Error('Failed to get moon phase');
        }
      }
    });
  • Core handler logic for calculating moon phase information using SunCalc
    getMoonPhase(params: MoonPhaseParams): MoonPhaseInfo {
      const date = params.date ? new Date(params.date) : new Date();
      
      // Get moon illumination data
      const illuminationData = SunCalc.getMoonIllumination(date);
      
      // Get moon position data (requires location)
      const latitude = params.latitude ?? 0;
      const longitude = params.longitude ?? 0;
      const positionData = SunCalc.getMoonPosition(date, latitude, longitude);
      
      // Calculate moon phase name
      const phaseName = this.getMoonPhaseName(illuminationData.phase);
      
      // Calculate if the moon is waxing (increasing illumination)
      const isWaxing = illuminationData.phase < 0.5;
      
      // Calculate approximate moon age (0-29.53 days)
      const lunarMonth = 29.53; // days
      const age = illuminationData.phase * lunarMonth;
      
      // Calculate apparent diameter (in degrees)
      const diameter = 0.5181 * (384400 / positionData.distance);
      
      return {
        date: date.toISOString().split('T')[0],
        phase: illuminationData.phase,
        phaseName,
        illumination: illuminationData.fraction,
        age,
        distance: positionData.distance,
        diameter,
        isWaxing
      };
    }
  • Zod schema defining input parameters for the get_moon_phase tool
    export const MoonPhaseParamsSchema = z.object({
      date: z.string().optional().describe('Date to get moon phase for (YYYY-MM-DD format). Defaults to current date.'),
      latitude: z.number().min(-90).max(90).optional().describe('Latitude for location-specific calculations'),
      longitude: z.number().min(-180).max(180).optional().describe('Longitude for location-specific calculations'),
      format: z.enum(['json', 'text']).optional().describe('Output format (json or text)')
    });
  • Helper function to determine moon phase name from phase value (used by getMoonPhase)
    private getMoonPhaseName(phase: number): MoonPhaseName {
      // Normalize phase to 0-1 range
      const normalizedPhase = phase < 0 ? phase + 1 : phase > 1 ? phase - 1 : phase;
      
      // Determine moon phase based on the value
      if (normalizedPhase < 0.0625 || normalizedPhase >= 0.9375) {
        return MoonPhaseName.NEW_MOON;
      } else if (normalizedPhase < 0.1875) {
        return MoonPhaseName.WAXING_CRESCENT;
      } else if (normalizedPhase < 0.3125) {
        return MoonPhaseName.FIRST_QUARTER;
      } else if (normalizedPhase < 0.4375) {
        return MoonPhaseName.WAXING_GIBBOUS;
      } else if (normalizedPhase < 0.5625) {
        return MoonPhaseName.FULL_MOON;
      } else if (normalizedPhase < 0.6875) {
        return MoonPhaseName.WANING_GIBBOUS;
      } else if (normalizedPhase < 0.8125) {
        return MoonPhaseName.LAST_QUARTER;
      } else {
        return MoonPhaseName.WANING_CRESCENT;
      }
    }
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. It states what the tool does but doesn't disclose behavioral traits like whether it's read-only (implied by 'Get'), error handling, rate limits, authentication needs, or what happens with invalid inputs. For a tool with no annotation coverage, this is a significant gap in transparency.

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 directly states the tool's purpose. It's front-loaded with the core functionality and has zero wasted words, making it easy to parse quickly.

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 no annotations, no output schema, and 4 parameters with full schema coverage, the description is minimally adequate. It covers the basic purpose but lacks behavioral context, usage guidance, and output details. For a tool with moderate complexity (location-based calculations), it should do more to compensate for missing structured data.

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 fully documents all 4 parameters. The description doesn't add any parameter-specific details beyond what's in the schema (e.g., it doesn't explain how latitude/longitude affect calculations or when to use json vs. text format). With high schema coverage, the baseline is 3 even without extra param info in the description.

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 ('moon phase information') with a specific scope ('for a specific date'). It distinguishes from siblings like 'get_moon_phases_range' (which covers date ranges) and 'get_next_moon_phase' (which focuses on future events). However, it doesn't explicitly mention how it differs from all siblings, so it's not a perfect 5.

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 siblings like 'get_moon_phases_range' for multiple dates or 'get_next_moon_phase' for upcoming phases. There's no context about prerequisites, limitations, or typical use cases.

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