Skip to main content
Glama

Reverse geocode with GeoNames

geonames_reverse_geocode
Read-onlyIdempotent

Resolve a latitude/longitude to the country and admin subdivisions that contain it (down to ADM5, each with its geonameId and ISO 3166-2 code where one exists), or the ocean or sea when the point is offshore, plus the nearest populated places with distances; these include neighborhood sections (PPLX) and historical places (PPLH), marked by featureCode. Set featureClasses or featureCodes to list the nearest features of that type instead (peaks, lakes, airports), cities to keep only places above a population tier, and includeTimezone for the IANA timezone with local time, sunrise, and sunset (offshore points get only GeoNames' UTC-offset estimate). A harbor, pier, or shoreline point can fall just outside every country outline and resolve to the sea; coastalBufferKm (up to 50) matches the nearest country within that distance instead. Costs 1 GeoNames credit for containment, with or without the buffer, plus 3 for nearest populated places or 4 for nearest features (nearbyLimit 0 skips them), 1 for the ocean when no country contains the point or lies within the buffer, and 1 for the timezone.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latYesLatitude in decimal degrees, -90 to 90.
lngYesLongitude in decimal degrees, -180 to 180.
citiesNoKeep only nearby populated places with a population of at least 1,000 (cities1000), 5,000 (cities5000), or 15,000 (cities15000), plus seats of admin divisions: GeoNames' cities tiers. Not combinable with featureClasses or featureCodes.
radiusKmNoRadius in kilometres for the nearby lookup, above 0 and at most 300 (GeoNames' free-tier limit). Default 20.
nearbyLimitNoHow many nearest places or features to list, 0 to 50. Default 5. 0 skips the nearby lookup and its 3 or 4 credits.
featureCodesNoList the nearest features with these GeoNames codes instead of populated places (MT mountain, PK peak, LK lake, AIRP airport), up to 20, as a list or a comma-separated string. Case-insensitive; a class prefix (T.MT) is dropped. Each code implies its class; with featureClasses too, the two lists intersect, so featureClasses must list exactly these codes' classes. geonames_list_reference topic feature_codes lists every code. Not combinable with cities.
featureClassesNoList the nearest features of these GeoNames classes instead of populated places: A admin divisions, H water, L areas, P populated places, R roads, S spots and buildings, T terrain, U undersea, V vegetation. A list or a comma-separated string; case-insensitive. With featureCodes too, the two lists intersect: list exactly the classes of those codes, or pass featureCodes alone. Not combinable with cities.
coastalBufferKmNoWhen no country contains the point, match the nearest country within this many kilometres, 0 to 50. Default 0: exact containment only. Set it for a harbor, pier, or shoreline point, which can fall just outside a country's outline as GeoNames maps it and otherwise resolves to the sea; a match carries country.distanceInKm. The nearby and timezone lookups keep the exact point. No extra credit.
includeTimezoneNoAlso return the timezone: IANA id, UTC offsets, local time, sunrise, and sunset (1 more credit). Default false.
geonamesUsernameNoYour own GeoNames username, so the call spends that account's free credits instead of the server's. Omit it to use the server's account. The account needs free web services enabled on its geonames.org account page.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
capNoThe nearbyLimit that was applied.
latNoThe latitude that was looked up.
lngNoThe longitude that was looked up.
errorNoPresent when the call failed. Absent on success.
oceanNoThe ocean or sea at the point; present only when no country contains it or lies within coastalBufferKm.
shownNoNearby places or features returned.
nearbyNoNearest places or features, nearest first; empty when nearbyKind is none.
noticeNoGuidance when the point is offshore or unmapped, its country was matched within coastalBufferKm, nothing is nearby, nearby is full, or no IANA timezone covers it.
countryNoThe country containing the point, or with coastalBufferKm the nearest country within that distance (then distanceInKm is set); absent offshore and in unmapped areas.
timezoneNoThe timezone at the point; present only with includeTimezone.
truncatedNoTrue when nearby is full at nearbyLimit, so more may lie within the radius.
nearbyKindNoWhat nearby lists: populated_places, features (featureClasses or featureCodes was set), or none (nearbyLimit 0).
adminLevelsNoAdmin divisions containing the point, first level first; for a country matched within coastalBufferKm, the divisions of its part nearest the point. Empty offshore, and where GeoNames records no subdivision of the country.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations cover the safety profile (readOnly, idempotent, openWorld), and the description goes well beyond them: it discloses credit costs per operation, the exact offshore/sea resolution behavior, that coastalBufferKm up to 50 matches the nearest country, that nearby/timezone lookups keep the exact point, and that PPLX/PPLH places are marked by featureCode. This is unusually rich behavioral context.

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 purpose is front-loaded in the first clause and every clause carries substantive information about a 10-parameter tool. It is one dense paragraph rather than a structured list, which slightly hurts scanability, but there is little waste for the complexity involved.

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?

An output schema exists, yet the description still names the key return fields (geonameId, ISO 3166-2, distanceInKm, timezone components), covers offshore edge cases, credit accounting, and alternate modes. Combined with 100% schema coverage and annotations, an agent has everything needed to invoke it correctly.

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

Parameters4/5

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

Schema description coverage is 100%, so the baseline is 3, but the description adds real value beyond the schema: it links nearbyLimit=0 to skipping the 3-4 credits, explains why coastalBufferKm exists (harbor/pier/shoreline edge cases) and that it costs no extra credit, and clarifies the non-combinability rules with cities. This lifts it above the schema-only baseline.

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?

States a precise verb+resource ('resolve a latitude/longitude to the country and admin subdivisions') and enumerates the exact outputs (ADM levels, geonameId, ISO 3166-2, ocean/sea fallback, nearest places with distances). An agent can immediately tell this apart from search_places or get_place, which are name-based lookups.

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

Usage Guidelines4/5

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

Clearly explains when to switch behavior: set featureClasses/featureCodes to list nearest features instead, cities to filter by population tier, coastalBufferKm for harbor/shoreline points that fall outside country outlines. It also cross-references the sibling geonames_list_reference for feature codes. It lacks explicit when-not-to-use-this-tool-vs-siblings guidance (e.g. vs geonames_search_places), so it stops short of a 5.

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.