Skip to main content
Glama

ecef_to_geodetic

Convert Earth-Centered, Earth-Fixed (ECEF) coordinates to geodetic latitude, longitude, and altitude for aviation and aerospace applications.

Instructions

Convert ECEF coordinates to geodetic (lat/lon/alt) coordinates.

Args: x_m: X coordinate in meters y_m: Y coordinate in meters z_m: Z coordinate in meters

Returns: JSON string with geodetic coordinates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
x_mYes
y_mYes
z_mYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler: imports core function from integrations, executes conversion, formats input/output as JSON, handles errors.
    def ecef_to_geodetic(x_m: float, y_m: float, z_m: float) -> str:
        """Convert ECEF coordinates to geodetic (lat/lon/alt) coordinates.
    
        Args:
            x_m: X coordinate in meters
            y_m: Y coordinate in meters
            z_m: Z coordinate in meters
    
        Returns:
            JSON string with geodetic coordinates
        """
        try:
            from ..integrations.frames import ecef_to_geodetic as _ecef_to_geodetic
    
            result = _ecef_to_geodetic(x_m, y_m, z_m)
    
            return json.dumps(
                {
                    "input": {"x_m": x_m, "y_m": y_m, "z_m": z_m},
                    "output": {
                        "latitude_deg": result["latitude_deg"],
                        "longitude_deg": result["longitude_deg"],
                        "altitude_m": result["altitude_m"],
                    },
                    "reference_frame": "WGS84 Geodetic",
                    "units": {
                        "latitude": "degrees",
                        "longitude": "degrees",
                        "altitude": "meters",
                    },
                },
                indent=2,
            )
    
        except ImportError:
            return "Coordinate conversion not available - geodetic module required"
        except Exception as e:
            logger.error(f"ECEF to geodetic error: {str(e)}", exc_info=True)
            return f"ECEF to geodetic error: {str(e)}"
  • Pydantic model for output geodetic coordinates (lat, lon, alt), used by the core conversion function.
    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)")
  • FastMCP registration of the ecef_to_geodetic tool function.
    mcp.tool(ecef_to_geodetic)
  • Core helper: iterative numerical algorithm for ECEF to geodetic conversion using WGS84 ellipsoid parameters.
    def _manual_ecef_to_geodetic(
        x: float, y: float, z: float
    ) -> tuple[float, float, float]:
        """
        Convert ECEF to geodetic coordinates using iterative method.
        Returns (lat_deg, lon_deg, alt_m).
        """
        # Longitude
        lon_rad = math.atan2(y, x)
    
        # Distance from z-axis
        p = math.sqrt(x**2 + y**2)
    
        # Initial guess for latitude
        lat_rad = math.atan2(z, p * (1.0 - EARTH_E2))
    
        # Iterative solution for latitude and altitude
        for _ in range(10):  # Usually converges in 2-3 iterations
            sin_lat = math.sin(lat_rad)
            N = EARTH_A / math.sqrt(1.0 - EARTH_E2 * sin_lat**2)
            alt = p / math.cos(lat_rad) - N
            lat_rad_new = math.atan2(z, p * (1.0 - EARTH_E2 * N / (N + alt)))
    
            if abs(lat_rad_new - lat_rad) < 1e-12:
                break
            lat_rad = lat_rad_new
    
        return math.degrees(lat_rad), math.degrees(lon_rad), alt
  • Integration wrapper: calls manual converter, validates with Pydantic model for structured output.
    def ecef_to_geodetic(x: float, y: float, z: float) -> GeodeticPoint:
        """
        Convert ECEF coordinates to geodetic (WGS84).
    
        Args:
            x, y, z: ECEF coordinates in meters
    
        Returns:
            GeodeticPoint with latitude, longitude, altitude
        """
        lat, lon, alt = _manual_ecef_to_geodetic(x, y, z)
    
        return GeodeticPoint(latitude_deg=lat, longitude_deg=lon, altitude_m=alt)
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. It mentions the return format ('JSON string with geodetic coordinates'), which adds some behavioral context. However, it doesn't disclose important traits like whether this is a pure mathematical conversion (no side effects), error handling for invalid inputs, coordinate system assumptions (e.g., WGS84), or precision limitations.

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 and front-loaded: the first sentence states the core purpose, followed by clearly labeled 'Args' and 'Returns' sections. Every sentence earns its place with no wasted words, making it easy to scan and understand.

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

Completeness4/5

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

Given the mathematical nature of the tool (3 simple numeric inputs), no annotations, but with an output schema (implied by 'Returns' statement), the description is reasonably complete. It covers purpose, parameters, and return format. However, for a coordinate transformation tool, additional context about coordinate systems or validation would enhance completeness.

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 clearly defines all three parameters (x_m, y_m, z_m) with their units ('meters'), which adds essential meaning beyond the bare schema. However, it doesn't explain valid ranges (e.g., Earth-centered coordinates), coordinate frame conventions, or typical magnitude examples.

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 conversion operation ('Convert ECEF coordinates to geodetic (lat/lon/alt) coordinates'), uses precise technical terminology, and distinguishes this tool from its sibling 'geodetic_to_ecef' by specifying the direction of conversion. The purpose is unambiguous and differentiated.

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 indicates when to use this tool (for converting from ECEF to geodetic coordinates) and the sibling list shows 'geodetic_to_ecef' as the inverse operation, providing clear context. However, it doesn't explicitly state when NOT to use it or mention alternative coordinate transformation tools in the sibling list like 'transform_frames'.

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