Skip to main content
Glama

geodetic_to_ecef

Convert latitude, longitude, and altitude coordinates to Earth-centered Earth-fixed (ECEF) coordinates for flight planning and aerospace calculations.

Instructions

Convert geodetic coordinates (lat/lon/alt) to Earth-centered Earth-fixed (ECEF) coordinates.

Args: latitude_deg: Latitude in degrees (-90 to 90) longitude_deg: Longitude in degrees (-180 to 180) altitude_m: Altitude above WGS84 ellipsoid in meters

Returns: JSON string with ECEF coordinates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitude_degYes
longitude_degYes
altitude_mNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler: wraps library function, formats input/output as JSON with metadata.
    def geodetic_to_ecef(
        latitude_deg: float, longitude_deg: float, altitude_m: float = 0.0
    ) -> str:
        """Convert geodetic coordinates (lat/lon/alt) to Earth-centered Earth-fixed (ECEF) coordinates.
    
        Args:
            latitude_deg: Latitude in degrees (-90 to 90)
            longitude_deg: Longitude in degrees (-180 to 180)
            altitude_m: Altitude above WGS84 ellipsoid in meters
    
        Returns:
            JSON string with ECEF coordinates
        """
        try:
            from ..integrations.frames import geodetic_to_ecef as _geodetic_to_ecef
    
            result = _geodetic_to_ecef(latitude_deg, longitude_deg, altitude_m)
    
            return json.dumps(
                {
                    "input": {
                        "latitude_deg": latitude_deg,
                        "longitude_deg": longitude_deg,
                        "altitude_m": altitude_m,
                    },
                    "output": {
                        "x_m": result["x_m"],
                        "y_m": result["y_m"],
                        "z_m": result["z_m"],
                    },
                    "reference_frame": "WGS84 ECEF",
                    "units": {"position": "meters"},
                },
                indent=2,
            )
    
        except ImportError:
            return "Coordinate conversion not available - geodetic module required"
        except Exception as e:
            logger.error(f"Geodetic to ECEF error: {str(e)}", exc_info=True)
            return f"Geodetic to ECEF error: {str(e)}"
  • Pydantic models for input (GeodeticPoint) and output (CoordinatePoint) validation used by the library function.
    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)")
  • Registers the geodetic_to_ecef handler function with the FastMCP server.
    mcp.tool(geodetic_to_ecef)
  • Core mathematical implementation: converts geodetic (lat, lon, alt) to ECEF (x,y,z) using WGS84 ellipsoid formula.
    def _manual_geodetic_to_ecef(
        lat_deg: float, lon_deg: float, alt_m: float
    ) -> tuple[float, float, float]:
        """
        Convert geodetic to ECEF coordinates.
        Returns (x, y, z) in meters.
        """
        lat_rad = math.radians(lat_deg)
        lon_rad = math.radians(lon_deg)
    
        sin_lat = math.sin(lat_rad)
        cos_lat = math.cos(lat_rad)
        sin_lon = math.sin(lon_rad)
        cos_lon = math.cos(lon_rad)
    
        # Radius of curvature in prime vertical
        N = EARTH_A / math.sqrt(1.0 - EARTH_E2 * sin_lat**2)
    
        x = (N + alt_m) * cos_lat * cos_lon
        y = (N + alt_m) * cos_lat * sin_lon
        z = (N * (1.0 - EARTH_E2) + alt_m) * sin_lat
    
        return x, y, z
  • Library wrapper: validates inputs and calls manual converter, returns typed CoordinatePoint.
    def geodetic_to_ecef(
        latitude_deg: float, longitude_deg: float, altitude_m: float
    ) -> CoordinatePoint:
        """
        Convert geodetic coordinates to ECEF.
    
        Args:
            latitude_deg: Latitude in degrees (-90 to +90)
            longitude_deg: Longitude in degrees (-180 to +180)
            altitude_m: Height above WGS84 ellipsoid in meters
    
        Returns:
            CoordinatePoint with ECEF coordinates
        """
        if not (-90 <= latitude_deg <= 90):
            raise ValueError("Latitude must be between -90 and +90 degrees")
        if not (-180 <= longitude_deg <= 180):
            raise ValueError("Longitude must be between -180 and +180 degrees")
    
        x, y, z = _manual_geodetic_to_ecef(latitude_deg, longitude_deg, altitude_m)
    
        return CoordinatePoint(x=x, y=y, z=z, frame="ECEF")
Behavior3/5

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

No annotations are provided, so the description carries full burden. It mentions the coordinate system (WGS84 ellipsoid) and output format (JSON string), which adds useful context beyond basic functionality. However, it doesn't disclose potential limitations, error conditions, or performance characteristics that would help an agent anticipate behavior.

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 perfectly structured with a clear purpose statement followed by organized Args and Returns sections. Every sentence earns its place by providing necessary information without redundancy. The formatting with headings enhances readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's mathematical transformation nature, 3 parameters, no annotations, but with an output schema present, the description provides exactly what's needed. It explains the conversion purpose, documents all parameters thoroughly, and notes the return format. The output schema will handle return value details, so no gaps remain.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by providing complete parameter documentation in the Args section. It specifies units (degrees, meters), valid ranges (-90 to 90, -180 to 180), and clarifies altitude is above WGS84 ellipsoid. This adds essential meaning beyond the bare schema.

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 specific transformation (convert geodetic coordinates to ECEF coordinates), identifies the input format (lat/lon/alt), and distinguishes from its sibling tool 'ecef_to_geodetic' which performs the inverse operation. The verb 'convert' is precise and the resource 'coordinates' is well-defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implicitly suggests usage when needing ECEF coordinates from geodetic inputs, and the sibling tool list shows 'ecef_to_geodetic' as a clear alternative for the reverse transformation. However, it doesn't explicitly state when to choose this tool over others or mention any prerequisites or exclusions.

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