Skip to main content
Glama
RyanCardin15

LocalTides MCP Server

get_moon_phase

Retrieve moon phase details for a specific date and location using NOAA data. Input date, latitude, longitude, and choose output format (json/text).

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

  • The execute handler for the 'get_moon_phase' tool. It invokes the moon phase service, formats the output as text or JSON based on the 'format' parameter, and handles errors.
    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');
      }
    }
  • Zod schema defining the 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)')
    });
  • Registration of the 'get_moon_phase' tool on the MCP server, specifying name, description, parameters schema, and execute handler.
    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 helper function in MoonPhaseService that computes detailed moon phase information using SunCalc library for illumination, position, phase name, age, distance, etc.
    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
      };
    }
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 tool retrieves information (implying read-only), but doesn't mention any constraints like rate limits, authentication needs, or what happens with invalid inputs. For a tool with location parameters (latitude/longitude), it doesn't explain if these are required for certain calculations or how they affect results.

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's no wasted verbiage or redundant information, making it easy for an agent 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 the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks behavioral details (e.g., error handling, output structure) and usage context relative to siblings. Without annotations or output schema, the agent must rely heavily on the input schema and trial.

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 (date, format, latitude, longitude) with descriptions, types, and constraints. The description adds no additional parameter semantics beyond what's in the schema, meeting the baseline for high 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 tool's purpose as 'Get moon phase information for a specific date', which includes a specific verb ('Get') and resource ('moon phase information'). It distinguishes from most siblings (e.g., get_current_predictions, get_water_levels) by focusing on moon phases, though it doesn't explicitly differentiate from get_moon_phases_range or get_next_moon_phase.

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 date ranges) or get_next_moon_phase (for upcoming phases), leaving the agent to infer usage based on tool names alone.

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