Skip to main content
Glama

get_celestial_rise_set

Calculate rise and set times for celestial objects like the sun, moon, and stars based on your location and date.

Instructions

Calculate the rise and set times of a celestial object.

Args: celestial_object: Name of object (e.g. "sun", "moon", "andromeda") lon: Observer longitude in degrees lat: Observer latitude in degrees time: Date string "YYYY-MM-DD HH:MM:SS" time_zone: IANA timezone string

Returns: Dict with keys "data", "_meta". "data" contains "rise_time" and "set_time".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
celestial_objectYes
lonYes
latYes
timeYes
time_zoneYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler implementation for 'get_celestial_rise_set'. Includes @mcp.tool() decorator for registration, input processing via process_location_and_time, calls core celestial_rise_set in thread, and formats response with ISO timestamps.
    @mcp.tool()
    async def get_celestial_rise_set(
        celestial_object: str,
        lon: float,
        lat: float,
        time: str,
        time_zone: str
    ) -> Dict[str, Any]:
        """Calculate the rise and set times of a celestial object.
    
        Args:
            celestial_object: Name of object (e.g. "sun", "moon", "andromeda")
            lon: Observer longitude in degrees
            lat: Observer latitude in degrees
            time: Date string "YYYY-MM-DD HH:MM:SS"
            time_zone: IANA timezone string
    
        Returns:
            Dict with keys "data", "_meta". "data" contains "rise_time" and "set_time".
        """
        location, time_info = process_location_and_time(lon, lat, time, time_zone)
        # Run synchronous celestial calculations in a separate thread
        rise_time, set_time = await asyncio.to_thread(celestial_rise_set, celestial_object, location, time_info)
        return format_response({
            "rise_time": rise_time.isoformat() if rise_time else None,
            "set_time": set_time.isoformat() if set_time else None
        })
  • Core helper function implementing the rise/set calculation logic using Astropy. Generates time grid, computes altitudes, finds horizon crossings. Called by the tool handler.
    def celestial_rise_set(
        celestial_object: str,
        observer_location: EarthLocation,
        date: datetime,
        horizon: float = 0.0
    ) -> Tuple[Optional[Time], Optional[Time]]:
        """
        Calculate rise and set times of a celestial object.
        Args:
            celestial_object: Name of the object ("sun", "moon", or planet name).
            observer_location: Observer's EarthLocation.
            date: Date for calculation (timezone-aware datetime).
            horizon: Horizon elevation in degrees (default: 0).
        Returns:
            Tuple[Optional[Time], Optional[Time]]: (rise_time, set_time) in UTC.
        Raises:
            ValueError: If the object is not supported or horizon is invalid.
        """
        if not -90 <= horizon <= 90:
            raise ValueError("Horizon must be between -90 and 90 degrees.")
        time_zone = pytz.timezone(zone=str(date.tzinfo))
        origin_zone = pytz.timezone(zone='UTC')
        time_grid = _generate_time_grid(date)
        name = celestial_object.lower()
        altaz_frame = AltAz(obstime=time_grid, location=observer_location)
        if name == "sun":
            obj_coord = get_sun(time_grid)
        elif name == "moon":
            obj_coord = get_body("moon", time_grid)
        elif name in ["mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune"]:
            obj_coord = get_body(name, time_grid)
        else:
            base_coord = _resolve_simbad_object(celestial_object)
            obj_coord = base_coord
        altaz = obj_coord.transform_to(altaz_frame)
        altitudes = np.array(altaz.alt.deg)
        def __convert_timezone(time):
            t = time.to_datetime()
            t = origin_zone.localize(t)
            return t.astimezone(time_zone)
        
        rise_idx, set_idx = _find_rise_set_indices(altitudes, horizon)
        rise_time = __convert_timezone(time_grid[rise_idx]) if rise_idx is not None else None
        set_time = __convert_timezone(time_grid[set_idx]) if set_idx is not None else None
        return rise_time, set_time
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 what the tool does but lacks critical behavioral details: it doesn't specify error handling (e.g., invalid object names), computational limits (e.g., date ranges), or authentication requirements. For a calculation tool with 5 required parameters, this leaves significant gaps in understanding how it behaves in edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by structured sections for Args and Returns. Every sentence earns its place by providing essential information, though the Returns section could be slightly more concise by omitting obvious keys like '_meta' if not critical.

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 complexity (5 required parameters, no annotations, but with an output schema), the description is moderately complete. The output schema reduces the need to explain return values in detail, but the description lacks context on prerequisites (e.g., valid object names), error cases, or performance considerations, which are important for a calculation tool with multiple inputs.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics by explaining each parameter: 'celestial_object' with examples ('sun', 'moon', 'andromeda'), 'lon'/'lat' as observer coordinates in degrees, 'time' as a date string with format, and 'time_zone' as IANA string. This clarifies usage beyond the bare schema, though it could benefit from more detail on valid object names or coordinate ranges.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 ('Calculate') and resource ('rise and set times of a celestial object'). It distinguishes from siblings like 'get_celestial_pos' (position) and 'get_moon_info' (moon-specific details) by focusing on temporal events rather than positional or informational data.

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 sibling tools like 'get_moon_info' (which might include rise/set times for the moon) or 'get_visible_planets' (which might list visible objects), leaving the agent to infer usage context without explicit direction.

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

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/StarGazer1995/mcp-stargazing'

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