← Catalog

@agntn/maps

Unified geocoding and maps provider library for humans and agents

Package

Install

Install with PiG

pig install npm:@agntn/maps

Install with Pi

pi install npm:@agntn/maps
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/pi/maps.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.0 (README.md). PiG does not review it.

@agntn/maps

npm version npm downloads license Ask DeepWiki

🗺️ Two geocoders, one TypeScript shape, nine coordinate formats. Turn places into coordinates, or ask what's at a coordinate pair.

Why?

You want a latitude and longitude, not another afternoon mapping JSON fields. Nominatim calls it lon, Google calls it lng. Maps gives your scripts and agents the same result shape from either provider.

✨ Features

  • 📍 Place names or address parts in. Search free text, or pass a structured address without building a query string yourself.
  • 🧩 One result shape out. WGS 84 coordinates, with address fields and a bounding box when available.
  • 🎯 A narrower search. Filter by country or layer: address, poi, natural. Ask for reverse results at country, state, city, street or building level.
  • 🧭 Every coordinate dialect. DMS, DDM, geohash, Maidenhead, Plus Codes, UTM and MGRS, converted locally. what3words too, if you bring a key.
  • 📏 Distance and bearing, offline. Choose a great circle or a rhumb line. Both are calculated locally, without a provider or network.
  • 🤖 A choice of interfaces. CLI, TypeScript, MCP, Pi, OMP and Vercel AI SDK tools.
  • 🔀 Two opinions on one place. Compare Google and Nominatim side by side. A failed lookup stays visible too.

📦 Install

pnpm add @agntn/maps

Node.js 26 or newer. The npm release is pending, so registry installs need publication first. Until then, use the source checkout.

🚀 First call

npx @agntn/maps geocode "Pałac Kultury i Nauki, Warszawa" --provider openstreetmap --language en --limit 1

Output from the local build:

[openstreetmap] 1 matches for "Pałac Kultury i Nauki, Warszawa":
52.2317657, 21.0057979  Palace of Culture and Science, 1, Plac Defilad, Żelazna Brama, Śródmieście Północne, Midtown, Warsaw, Masovian Voivodeship, 00-110, Poland
  category attraction; country pl; address houseNumber 1, road Plac Defilad, city Warsaw, state Masovian Voivodeship, postcode 00-110, country Poland; bounds 52.2304141..52.2331217 lat, 21.0043177..21.0080405 lon

That's a fairly long way of saying "the big building in Warsaw". The indented line is the rest of what Nominatim knows. An attraction. Fair enough. Data: © OpenStreetMap contributors, ODbL.

No API key needed for this lookup. Public Nominatim allows at most one request per second across your application. Space out calls yourself: Maps doesn't throttle them. No bulk jobs or autocomplete against that instance. Read its usage policy before using it, and don't send confidential data.

After a registry install, use pnpm exec maps for the commands below. In a built checkout, replace maps with node dist/cli.mjs.

How far is Kraków from Warsaw? This one stays offline:

maps distance 52.2297,21.0122 50.0647,19.9450
Distance: 251.98 km (251977 m)
Bearing: 197.6°

Warsaw to Kraków, from the local build. That's across a sphere, not along the motorway. Your car may have objections.

Want to hold one compass bearing from Tokyo to Los Angeles? Take the rhumb line:

maps distance 35.6762,139.6503 34.0522,-118.2437 --path rhumb
Rhumb distance: 9316.94 km (9316939 m)
Rhumb bearing: 91.1°

The great circle is 8819 km, starting at 55.5°. The rhumb line holds 91.1° for about 500 km more. Your compass gets an easier job, at a price.

Got a geohash from a puzzle? Paste it:

maps convert ezs42
geohash ezs42 -> 42.60498046875, -5.60302734375
Cell: 42.5830078125..42.626953125 lat, -5.625..-5.5810546875 lon
  decimal     42.604980, -5.603027
  dms         42°36'17.9"N 5°36'10.9"W
  ddm         N 42° 36.299' W 005° 36.182'
  geohash     ezs42
  maidenhead  IN72eo
  pluscode    8CJPJ93W+XQ
  utm         30T 286471 4720235
  mgrs        30T TN 86471 20234

ezs42 isn't a point. It's a box about 4.9 km tall on the edge of León. So you get the cell, and every other format describes its middle. No format flag needed. Maps reads the shape. A lowercase jn58td fits both a geohash and a locator, though. Then it asks.

Commands

CommandUse it forExample
geocodeA place name or addressmaps geocode "Rynek, Wrocław"
addressAddress parts you already havemaps address --road Złota --house-number 44 --city Warszawa
reverseWhat's at these coordinates?maps reverse 52.2318,21.0067
distanceDistance and bearingmaps distance 52.2297,21.0122 50.0647,19.9450
convertOne location, every formatmaps convert "N 52° 13.782 E 021° 00.732"
providersProvider keys and capabilitiesmaps providers
mcpA stdio MCP servermaps mcp

Options are spelled out: --provider, --language, --limit. Lists and objects go in as JSON. Looking for a landmark rather than streets named after it? Try --layers '["poi"]'. Want the data, not the text? Add --json. Each command has --help.

A negative latitude needs a separator: maps reverse -- -33.86,151.21. A short Plus Code like 9G8F+6W needs a point nearby, --reference '{"latitude":52.2,"longitude":21}'.

🧠 Library

import { create, distanceBetween, parseCoordinates } from "@agntn/maps";

const provider = create("openstreetmap");
const [place] = await provider.geocode("Pałac Kultury i Nauki, Warszawa", { limit: 1 });
console.log(place?.latitude, place?.longitude, place?.address?.city);

const from = parseCoordinates("52.2297,21.0122");
const to = parseCoordinates("50.0647,19.9450");
console.log(distanceBetween(from, to));

Have address parts? Use provider.geocodeAddress(). Coordinates? Use provider.reverse(latitude, longitude). Direct calls stick to one provider. For automatic fallback, use geocodeWithFallback. For comparison, use geocodeAll. Both have structured-address and reverse variants. Don't feel like waiting? All six take an AbortSignal last. create() takes one too, as signal.

Coordinates in some other notation? convertCoordinates("34U EC 0083 8658") reads it and writes the rest.

Following one compass bearing? rhumbDistanceBetween(from, to) gives meters and rhumbBearingBetween(from, to) gives degrees from true north.

Address fields are optional. Check capabilities for custom providers. Coordinate helpers validate ranges before reverse requests.

Public exports · Options and results · Provider contract

🗺️ Providers

KeyCredentialsForward result cap
openstreetmapNone for public Nominatim40
googlemapsGOOGLE_MAPS_API_KEY20

CLI and agent tools select Google when its key is configured, otherwise OpenStreetMap. They fall back on auth, billing, rate-limit errors or unsupported operations. Other failures propagate. An explicit provider is never replaced. Pass --provider all in the CLI to compare providers in parallel, with errors kept beside successful results.

For Google, enable the Geocoding API and supply its key through the environment. Follow Google's usage and attribution rules. Maps redacts secret query parameters from error messages, including Google's key parameter.

what3words is the one conversion that leaves your machine. Set WHAT3WORDS_API_KEY and Maps sends it in a header, never in the URL. Without it, convert just skips three words.

For regular or bulk Nominatim work, use your own instance through create("openstreetmap", { baseUrl }). Maps sends an identifying User-Agent. Provider limits still apply when a call falls back or uses all.

🤖 Agents

After publication, pick your host:

pi install npm:@agntn/maps
omp install @agntn/maps

Or add Maps to an MCP client:

{
  "mcpServers": {
    "maps": { "command": "npx", "args": ["-y", "@agntn/maps", "mcp"] }
  }
}

Read-only tools: maps_providers, maps_geocode, maps_address_geocode, maps_reverse, maps_distance and maps_convert. Every host gets the same set and the same text, indented facts included. The provider's own record stays out. Need osm_id or place_id? Pass raw: true. No need to carry the whole suitcase for a postcode. Hit Esc halfway through a geocode and the request dies with the call. The 15 second timeout is there for a slow Nominatim, not for you.

With a built checkout, use pi install . or omp install .. For MCP, use node with the absolute path to dist/cli.mjs, followed by mcp.

Using Vercel AI SDK? Install ai too. @agntn/maps/ai exports geocodeTool, geocodeAddressTool, reverseTool, distanceTool, convertTool and providersTool. You get the data back, with that same text in text. The raw flag works there too. Bring your own MCP transport with the @agntn/maps/mcp export, createMcpServer.

Tool definitions · MCP server · AI SDK tools · Pi · OMP

🚫 What this does not do

No routes, traffic estimates or map tiles. Distance is measured across a sphere, not along roads. Finding an address doesn't validate it for postal delivery either. UTM and MGRS stop at 80°S and 84°N, the poles need UPS.

🧩 Adding a provider

Got another geocoder? The Nominatim implementation shows the whole adapter, including its register() call. Yours needs the same Provider contract and an import in the provider index.

🛠️ Development

From this repository's checkout:

pnpm install
pnpm build       # Build the library, CLI, MCP and AI SDK entrypoints
pnpm fmt         # Apply lint fixes and formatting
pnpm lint        # Check lint and formatting
pnpm typecheck   # Check the library and extensions
pnpm test        # Run mocked unit tests

Try the CLI with node dist/cli.mjs in place of maps. For integration checks without live geocoding:

MAPS_EVAL_OFFLINE=1 pnpm test:cli
MAPS_EVAL_OFFLINE=1 pnpm test:mcp
pnpm test:packed

💛 Thanks

Built with support from Claude for Open Source and Codex for Open Source. Thanks for giving small packages room to grow.

📄 License

MIT covers the code. Provider data keeps its own licensing and attribution requirements.