# Distance between two latitude and longitude points from an AI agent

You need the great-circle distance over the Earth between two points given as latitude and longitude, in meters, kilometers, miles or nautical miles.

Use `geo-haversine-distance@1.0.0`. It is free and needs no key or sign-up. Compute the spherical great-circle distance between two latitude/longitude points and return it in the requested unit.

## Why call a tool for this

The haversine formula involves several trigonometric steps where a model can slip. The tool computes it and states the Earth radius it used. For example, London (51.5074, -0.1278) to Paris (48.8566, 2.3522) in km with 1 decimal returns 343.6.

## Call it over HTTP

```sh
curl -X POST https://computefirst.net/v1/tools/geo-haversine-distance/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"lat1_deg":0,"lon1_deg":0,"lat2_deg":0,"lon2_deg":0,"unit":"m"}'
```

Response:

```json
{
  "result": {
    "distance": 0,
    "unit": "m",
    "earth_radius_m": 6371008.8,
    "standard_version": "Sinnott-1984/IUGG-GRS80"
  }
}
```

## Call it over MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "geo-haversine-distance",
  "version": "1.0.0",
  "input": {
    "lat1_deg": 0,
    "lon1_deg": 0,
    "lat2_deg": 0,
    "lon2_deg": 0,
    "unit": "m"
  }
}
```

## Check the result

Coordinates are JSON numbers in decimal degrees, not strings: latitude from -90 to 90, longitude from -180 to 180. The Earth is treated as a sphere, so the result can differ from an ellipsoidal (WGS-84) distance by up to about 0.6 percent. This is not a road or travel distance.

Full contract, limits and unsupported cases: [Geo haversine distance](/tools/geo-haversine-distance).

## Related tools

- [Geo initial bearing](/tools/geo-initial-bearing)
- [Geo destination point](/tools/geo-destination-point)
