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

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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
      +  }
      +]
  2. Added
  3. Removed
  4. First observed

TDQS

A4.6/5.0
Behavior5/5

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

The annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the safety profile is covered. The description adds meaningful behavioral context beyond that: it uses a spherical-Earth approximation, outputs the initial bearing and midpoint in addition to distance, lists exact output units, and gives a clear accuracy caveat of roughly 0.5%.

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 front-loaded with use guidance and is well-structured with clear sections for inputs, outputs, formula, REST fallback, and docs. It is longer than strictly necessary because of the formula block and documentation links, but each section serves a practical purpose and there is no filler.

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?

For a pure calculation tool with strong annotations, four well-documented parameters, and an output schema, the description covers everything an agent needs to invoke it correctly: when to use it, when not to, input examples, full output semantics, the computational model, and even a REST fallback path. No meaningful gap is apparent.

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?

The input schema already covers all four parameters in detail with units, ranges, and examples, so the baseline is 3. The description restates the parameters and units and provides complete JSON examples, but these largely duplicate what the schema already offers rather than adding new semantic information.

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 that this tool computes the straight-line (great-circle) distance between two GPS coordinates or cities, with examples of use cases like flight distance and geofencing. It also distinguishes itself from road distance, geodesic methods, and bearing-only tools, making its purpose unambiguous relative to alternatives.

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 provides explicit 'Use this when...' and 'Do not use this when...' guidance, including concrete alternatives such as Vincenty/Karney on WGS-84 for ellipsoidal accuracy and compass-bearing for bearing-only needs. It even instructs the agent to call the tool directly rather than answering from memory or stopping at discovery.

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