Geolocation MCP Tools for AI Agents

"How far is it from New York to London?" Your agent attempts to apply the Haversine formula mentally and gets 5,470 km. The actual distance is 5,570 km. Geographic distance calculations require precise trigonometric math. These tools use the Haversine formula correctly.

All Geolocation Tools (16)

Your agent gets access to 16 geolocation tools via the /mcp/geo/ endpoint. Here's the complete list:

ToolDescription
geo/haversineHaversine Distance
geo/bearingCalculate Bearing
geo/midpointCalculate Midpoint
geo/destinationDestination Point
geo/dms-to-decimalDms To Decimal
geo/decimal-to-dmsDecimal To Dms
geo/is-valid-coordinatesIs Valid Coordinates
geo/bounding-boxBounding Box
geo/point-in-polygonPoint In Polygon
geo/geohash-encodeGeohash Encode
geo/geohash-decodeGeohash Decode
geo/polygon-areaPolygon Area
geo/polyline-lengthPolyline Length
geo/centroidPolygon Centroid
geo/timezone-offsetTimezone Offset
geo/sun-positionSun Position

Agent Scenarios

Here's how real agents use these tools:

1. Delivery routing agent

A logistics agent calculates the distance between a warehouse and delivery address for shipping estimates.

Tool Call: geo/distance
{ "lat1": 40.7128, "lon1": -74.006, "lat2": 34.0522, "lon2": -118.2437 }

2. Store locator agent

A retail agent finds the nearest store by calculating distances from a customer's location to all store coordinates.

Tool Call: geo/distance
{ "lat1": 51.5074, "lon1": -0.1278, "lat2": 48.8566, "lon2": 2.3522 }

MCP Setup

Add geolocation tools to your agent in under 2 minutes. Choose your client:

Claude Desktop / Claude Code

Add this to your MCP config:

{
  "mcpServers": {
    "tinyfn-geo": {
      "url": "https://api.tinyfn.io/mcp/geo/",
      "headers": {
        "X-API-Key": "your-api-key"
      }
    }
  }
}

Cursor

Go to Settings > MCP and add a new server:

  • Type: SSE
  • URL: https://api.tinyfn.io/mcp/geo/sse
  • Headers: X-API-Key: your-api-key

Tip: Use the category-specific endpoint (/mcp/geo/) for the best experience. The all-in-one endpoint (/mcp/all/) works too but has 500+ tools which some clients handle less efficiently.

When to Use These Tools

Use geolocation MCP tools when your agent needs to:

  • Guarantee correctness — when wrong answers have real consequences
  • Process user data — when you're operating on actual user input, not hypothetical examples
  • Maintain consistency — when the same input must always produce the same output

You don't need these tools for casual conversation or rough estimates. Use them when precision matters.

Ready to add geolocation tools to your agent?

Get Free API Key 100 requests/month free. No credit card required.

Frequently Asked Questions

What formula does TinyFn use for distance?

TinyFn uses the Haversine formula, which calculates great-circle distances between two points on a sphere. This provides accuracy to within 0.5% for Earth distances.

What units are distances returned in?

Distances are returned in both kilometers and miles. You can specify your preferred unit in the request.

Can TinyFn calculate midpoints?

Yes. TinyFn can calculate the geographic midpoint between two coordinates, useful for finding central meeting points or map centering.

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key