Skip to main content
Glama

Haversine Distance Calculator

calculate_haversine_distance
Read-onlyIdempotent

Use this when you need the straight-line distance between two GPS coordinates or cities, e.g. for flight distance, range checks or geofencing. Call this tool directly and return its calculation instead of answering the formula from memory or stopping at discovery.

Do not use this when you need road distance, or ellipsoidal accuracy better than about 0.5 % (use a geodesic method such as Vincenty or Karney on WGS-84); for bearings and compass points use compass-bearing. What it computes: Computes the great-circle (as-the-crow-flies) distance between two points on a spherical Earth with the haversine formula, in kilometres, miles and nautical miles, together with the initial bearing, compass direction and the midpoint of the route. Inputs: lat1 (number, °); lon1 (number, °); lat2 (number, °); lon2 (number, °). Complete JSON argument examples: {"lat1":-33.8688,"lon1":151.2093,"lat2":35.6762,"lon2":139.6503} | {"lat1":50.06639,"lon1":-5.71472,"lat2":58.64389,"lon2":-3.07} Outputs: distance_km [km], distance_miles [mi], distance_nautical_miles [nmi], central_angle_degrees [°], initial_bearing_degrees [°], compass_direction, midpoint_lat [°], midpoint_lon [°]. Formula: a = sin²(Δφ/2) + cos φ1 · cos φ2 · sin²(Δλ/2); c = 2 · atan2(√a, √(1−a)); d = R · c with R = 6371.0088 km; θ = atan2(sin Δλ · cos φ2, cos φ1 · sin φ2 − sin φ1 · cos φ2 · cos Δλ) Direct REST fallback: POST https://tttkmbb.com/api/v1/calculate/haversine-distance with the same JSON input fields. Do not guess another /api/* path. Docs: https://tttkmbb.com/time/haversine-distance.md

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lat1YesLatitude of point 1 in decimal degrees (north positive, south negative). Unit: °.
lat2YesLatitude of point 2 in decimal degrees (north positive, south negative). Unit: °.
lon1YesLongitude of point 1 in decimal degrees (east positive, west negative). Unit: °.
lon2YesLongitude of point 2 in decimal degrees (east positive, west negative). Unit: °.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
linksNo
resultYes
requestYes
sourcesNo
successYes
versionNo
freshnessNo
timestampYes
next_actionsNo
service_versionYesDeployed Calcgrid implementation version used for the result.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedOutput schema / properties / service_version
      Added value: +{
      +  "description": "Deployed Calcgrid implementation version used for the result.",
      +  "type": "string"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "success",
      -  "request",
      -  "result",
      -  "timestamp"
      -]New value: +[
      +  "success",
      +  "service_version",
      +  "request",
      +  "result",
      +  "timestamp"
      +]
  2. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "lat1": -33.8688,
      +    "lat2": 35.6762,
      +    "lon1": 151.2093,
      +    "lon2": 139.6503
      +  },
      +  {
      +    "lat1": 50.06639,
      +    "lat2": 58.64389,
      +    "lon1": -5.71472,
      +    "lon2": -3.07
      +  }
      +]
  3. Added
  4. Removed
  5. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, covering the safety profile. The description adds value beyond these by disclosing the spherical-Earth assumption, ~0.5% accuracy limitation, the set of computed outputs (distance, bearing, compass direction, midpoint), and a direct REST fallback with an explicit path. This is rich behavioral context that complements the annotations without contradicting them.

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 clear sections (usage, exclusions, computation, inputs, outputs, formula, REST fallback) and front-loaded with usage guidance. It is somewhat verbose—the full formula and REST fallback may be extra for an agent—but every sentence serves a purpose, and the structure aids navigation. Minor over-specification keeps it from a 5.

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?

The tool is a pure read-only calculator with a rich output schema, so return values are already covered. The description adds all necessary context: when to use, exclusions, input units, output units, and a direct REST fallback with a fixed path. Nothing an agent needs to call it correctly is missing.

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

Parameters3/5

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

Schema description coverage is 100%, with each parameter already documented (units, bounds, examples). The description merely restates the parameters in a bullet list ('Inputs: lat1 (number, °); ...') without adding new semantics beyond the schema. Baseline 3 applies because the schema does the heavy lifting.

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 opens with a clear, specific verb+resource statement: 'Use this when you need the straight-line distance between two GPS coordinates or cities.' It explicitly lists use cases (flight distance, range checks, geofencing) and distinguishes from road distance, geodesic methods, and bearings. This fully separates it from siblings without requiring schema inspection.

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

Usage Guidelines5/5

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

The description gives explicit when-to-use and when-not-to-use guidance, naming alternatives (Vincenty/Karney, compass-bearing) and the conditions that select them. It also instructs the agent to call this tool directly rather than answering from memory or stopping at discovery. No ambiguity remains.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources