Skip to main content
Glama

transform_frames

Convert coordinates between reference frames (ECEF, ECI, ITRF, GCRS, GEODETIC) for aerospace applications. Specify source and target frames with optional epoch for time-dependent transformations.

Instructions

Transform coordinates between reference frames (ECEF, ECI, ITRF, GCRS, GEODETIC).

Args: coordinates: Dict with coordinate data (format depends on frame) from_frame: Source reference frame to_frame: Target reference frame epoch_utc: Optional epoch for time-dependent transformations (ISO format)

Returns: JSON string with transformed coordinates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coordinatesYes
from_frameYes
to_frameYes
epoch_utcNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for 'transform_frames'. Accepts coordinates as dict, frame names, optional epoch, calls the underlying integration function, and returns formatted JSON output or error messages.
    def transform_frames(
        coordinates: dict,
        from_frame: Literal["ECEF", "ECI", "ITRF", "GCRS", "GEODETIC"],
        to_frame: Literal["ECEF", "ECI", "ITRF", "GCRS", "GEODETIC"],
        epoch_utc: str | None = None,
    ) -> str:
        """Transform coordinates between reference frames (ECEF, ECI, ITRF, GCRS, GEODETIC).
    
        Args:
            coordinates: Dict with coordinate data (format depends on frame)
            from_frame: Source reference frame
            to_frame: Target reference frame
            epoch_utc: Optional epoch for time-dependent transformations (ISO format)
    
        Returns:
            JSON string with transformed coordinates
        """
        try:
            from ..integrations.frames import transform_frames as _transform
    
            result = _transform(coordinates, from_frame, to_frame, epoch_utc)
            return json.dumps(result, indent=2)
    
        except ImportError as e:
            return f"Frame transformation not available - missing dependency: {str(e)}"
        except Exception as e:
            logger.error(f"Frame transformation error: {str(e)}", exc_info=True)
            return f"Frame transformation error: {str(e)}"
  • Registers the transform_frames function as an MCP tool in the FastMCP server.
    mcp.tool(transform_frames)
  • Core implementation of frame transformations using astropy if available, or manual methods for ECEF/GEODETIC and approximations for others.
    def transform_frames(
        xyz: list[float],
        from_frame: str,
        to_frame: str,
        epoch_iso: str = "2000-01-01T12:00:00",
    ) -> CoordinatePoint:
        """
        Transform coordinates between reference frames.
    
        Args:
            xyz: [x, y, z] coordinates in meters
            from_frame: Source frame ("ECEF", "ECI", "ITRF", "GCRS")
            to_frame: Target frame ("ECEF", "ECI", "ITRF", "GCRS")
            epoch_iso: Reference epoch in ISO format
    
        Returns:
            CoordinatePoint with transformed coordinates
        """
        if len(xyz) != 3:
            raise ValueError("xyz must be a list of 3 coordinates")
    
        x, y, z = xyz
    
        # Validate frame names
        valid_frames = {"ECEF", "ECI", "ITRF", "GCRS", "GEODETIC"}
        if from_frame not in valid_frames or to_frame not in valid_frames:
            raise ValueError(f"Frame must be one of {valid_frames}")
    
        # Same frame - no transformation needed
        if from_frame == to_frame:
            return CoordinatePoint(x=x, y=y, z=z, frame=to_frame, epoch=epoch_iso)
    
        # Use high-precision libraries if available
        if ASTROPY_AVAILABLE:
            try:
                # Parse epoch
                time = Time(epoch_iso, format="isot")
    
                # Map frame names to astropy
                frame_map = {
                    "ECI": GCRS,
                    "GCRS": GCRS,
                    "ECEF": ITRS,
                    "ITRF": ITRS,
                }
    
                if from_frame in frame_map and to_frame in frame_map:
                    # Create coordinate object
                    coords_from = frame_map[from_frame](
                        CartesianRepresentation(x=x * u.m, y=y * u.m, z=z * u.m),
                        obstime=time,
                    )
    
                    # Transform
                    coords_to = coords_from.transform_to(frame_map[to_frame](obstime=time))
    
                    return CoordinatePoint(
                        x=float(coords_to.cartesian.x.to(u.m).value),
                        y=float(coords_to.cartesian.y.to(u.m).value),
                        z=float(coords_to.cartesian.z.to(u.m).value),
                        frame=to_frame,
                        epoch=epoch_iso,
                    )
            except Exception:
                # Fall back to manual methods
                pass
    
        # Manual transformations for basic cases
        if from_frame == "ECEF" and to_frame == "GEODETIC":
            lat, lon, alt = _manual_ecef_to_geodetic(x, y, z)
            return CoordinatePoint(x=lat, y=lon, z=alt, frame="GEODETIC", epoch=epoch_iso)
        elif from_frame == "GEODETIC" and to_frame == "ECEF":
            x_new, y_new, z_new = _manual_geodetic_to_ecef(x, y, z)
            return CoordinatePoint(x=x_new, y=y_new, z=z_new, frame="ECEF", epoch=epoch_iso)
        elif (from_frame in ["ECI", "GCRS"] and to_frame in ["ECEF", "ITRF"]) or (
            from_frame in ["ECEF", "ITRF"] and to_frame in ["ECI", "GCRS"]
        ):
            # Simple approximation: ECI ≈ ECEF (ignoring Earth rotation)
            # In real implementation, would apply rotation matrix based on GMST
            return CoordinatePoint(x=x, y=y, z=z, frame=to_frame, epoch=epoch_iso)
    
        raise NotImplementedError(
            f"Transformation from {from_frame} to {to_frame} not implemented. "
            f"Install astropy or skyfield for full functionality."
        )
  • Pydantic models defining input/output schemas for coordinate transformations.
    class CoordinatePoint(BaseModel):
        """A point in 3D space with metadata."""
    
        x: float = Field(..., description="X coordinate (m)")
        y: float = Field(..., description="Y coordinate (m)")
        z: float = Field(..., description="Z coordinate (m)")
        frame: str = Field(..., description="Coordinate frame")
        epoch: str | None = Field(None, description="Epoch (ISO format)")
    
    
    class GeodeticPoint(BaseModel):
        """Geodetic coordinates."""
    
        latitude_deg: float = Field(..., description="Latitude in degrees")
        longitude_deg: float = Field(..., description="Longitude in degrees")
        altitude_m: float = Field(..., description="Height above ellipsoid (m)")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. While it mentions the transformation is time-dependent for some frames (via epoch_utc), it doesn't describe error conditions, precision limitations, computational requirements, or what happens with invalid inputs. For a coordinate transformation 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.

Conciseness4/5

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

The description is well-structured with a clear purpose statement followed by organized sections for Args and Returns. Each sentence serves a purpose, though the coordinate format dependency could be more explicitly stated in the main description rather than just in the Args section.

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 complexity (coordinate transformations between multiple reference frames) and the presence of an output schema, the description is adequate but could be more complete. It explains the transformation purpose and parameters, but doesn't address coordinate system conventions, unit expectations, or transformation limitations. The output schema handles return format, so the description doesn't need to explain that.

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?

With 0% schema description coverage, the description must compensate, and it does so effectively. It explains that 'coordinates' format depends on the frame, clarifies 'epoch_utc' is for time-dependent transformations and specifies ISO format, and identifies the purpose of 'from_frame' and 'to_frame'. This adds substantial meaning beyond the bare schema, though it could provide more detail about coordinate formats.

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: 'Transform coordinates between reference frames' with specific frames listed (ECEF, ECI, ITRF, GCRS, GEODETIC). It uses a specific verb ('transform') and resource ('coordinates'), but doesn't explicitly distinguish from sibling tools like 'ecef_to_geodetic' or 'geodetic_to_ecef' which appear to be specialized versions of this more general transformation 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. There are sibling tools like 'ecef_to_geodetic' and 'geodetic_to_ecef' that appear to handle specific frame transformations, but the description doesn't explain when this general transformation tool is preferred over those specialized tools or vice versa.

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/cheesejaguar/aerospace-mcp'

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