@cyanheads/geonames-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@@cyanheads/geonames-mcp-serverwhat country and city are at coordinates 48.8566, 2.3522?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Public Hosted Server: https://geonames.caseyjhand.com/mcp
Overview
The GeoNames gazetteer: 13M+ places worldwide, each keyed by a stable integer geonameId and linked into an administrative tree from continent to neighborhood. Search places, read full records, walk the admin hierarchy, reverse geocode coordinates, look up postal codes, and read country facts. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Tool | Description |
| Search places by name, country, feature class or code, population tier, and bounding box |
| Full record for one |
| Parent chain from Earth and the continent down to the feature |
| Direct children of a feature in the administrative, tourism, or dependency tree |
| Country and admin subdivisions (or the ocean) for a coordinate, plus the nearest places or features and an optional timezone |
| Postal codes by code, by place name, or near a coordinate |
| Country facts: ISO and FIPS codes, |
| Feature classes, feature codes, and the countries with postal-code data |
Related MCP server: GeoWire
Capability reference
geonames_search_places tool
query(up to 200 characters) compared permatch:name_required(default),any_field,exact_name, orname_prefix; filterscountries(up to 10, by ISO alpha-2, alpha-3, or numeric code),featureClasses,featureCodes(up to 20),cities(cities1000/cities5000/cities15000), andboundingBox. A call needsqueryor one ofcountries,featureClasses,featureCodes,boundingBoxlimit1–100 (default 10),offset0–5000,orderByrelevanceorpopulation; returnstotalCount,effectiveQuery, andnextOffsetfeatureClasses,featureCodes, andcities(class P only) intersect: with both lists set, each code's class must be listed and each listed class needs a code; besidecities, only class P and its codes. Anything else fails asfeature_filter_mismatchFails before any request with
query_or_filter_required,query_required,unknown_country_code,unknown_feature_code,feature_filter_mismatch, orinvalid_bounding_box
geonames_get_place tool
One
geonameId; an unknown id returnsfound: falsewithguidanceReturns
adminLevels1–5 (code, name,geonameId), timezone (UTC offsets on 1 January and 1 July), bounding box, recorded and DEM elevation, population, Wikipedia URL,alternateNames,postalCodes,links, andidentifiers(IATA, ICAO, FAA, Transport Canada, UN/LOCODE, Wikidata)nameLanguages(up to 20 tags;zhalso matcheszh-CN) filtersalternateNamesonly
geonames_get_hierarchy tool
One
geonameId;chainruns from Earth and its continent through the country and admin divisions down to the feature, skipping levels it does not sit underEach level carries
geonameId, feature class and code, country and first-level codes, coordinates, and population; an unknown id returnsfound: false
geonames_get_children tool
hierarchy:administrative(default),tourism(islands, coasts, and their municipalities; almost all in Spain), ordependency(a country's dependent territories). Children are mostly admin divisions (class A) and populated places (class P); continents and coasts are class L, islands class TGeoNames answers a
tourismordependencyrequest with the administrative children when the feature has no such tree. The tool compares the two lists and setssameAsAdministrative, with a notice, when they match; the rows stay, since a real tree can match tooFetches up to 1,000 children per parent once and caches them, so
nameContains,limit(1–500, default 100), andoffsetcost no extra credits; a notice says when GeoNames lists moreAn unknown id returns
found: false; a leaf returns an emptychildrenlist with a notice
geonames_reverse_geocode tool
lat/lngresolve tocountryandadminLevels(down to ADM5, each with itsgeonameIdand ISO 3166-2 subdivision code where one exists) or, offshore, theoceancoastalBufferKm(0–50, default 0) matches the nearest country within that distance when none contains the point, for harbor, pier, and shoreline fixes; a buffered match carriescountry.distanceInKm, and the nearby and timezone lookups keep the exact pointnearbylists the nearest populated places (nearbyLimit0–50, default 5;radiusKmup to 300, default 20; optionalcitiestier) or, whenfeatureClasses/featureCodesis set, the nearest features of that type;nearbyKindsays which.featureClassesandfeatureCodesintersectFails before any request with
conflicting_filters(citieswith a feature filter),unknown_feature_code, orfeature_filter_mismatch(a code whose class is not listed, or a listed class with no code)includeTimezoneadds the IANA id, UTC offsets, local time, sunrise, and sunset (offsets only offshore, where 1 July is reported at the standard offset)
geonames_find_postal_codes tool
mode:code(needspostalCode),place_name(needsplaceName), ornearby(needslatandlng;radiusKmup to 30, default 10); a missing field, orcountriesinnearby, fails asmode_fields_mismatchcountriesfilter forcodeandplace_name, by ISO alpha-2, alpha-3, or numeric code (an alpha-3 or numeric code no country has fails asunknown_country_code);limit1–100 (default 10); GeoNames reports no total, so a full page is marked truncatedCovers 122 countries; Ireland returns only Eircode routing keys and Malta only letter prefixes
geonames_get_countries tool
Up to 50
countriesby ISO alpha-2, alpha-3, or numeric code, acontinent,nameContains, or no filter for all 250;limit1–250 (default 50) withoffsetRows carry ISO and FIPS codes,
geonameId(the starting point forgeonames_get_children), capital, population, area, continent, languages, currency, postal-code format, and mainland bounding box; unknown codes land innotFound
geonames_list_reference tool
topic:feature_classes(9),feature_codes(684, filterable byfeatureClass), orpostal_countries(122, with each country's code range and count);featureClasswith another topic fails asfilter_not_applicablenameContains,limit1–700 (default 100), andoffset; feature classes and codes are bundled and spend no credits
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
GeoNames-specific:
Data from GeoNames, licensed CC BY 4.0: results you pass on must credit GeoNames. This server is independent of GeoNames.
Per-account pacing at 1,000 requests an hour, with a cooldown after a quota error that holds only that account
Responses are cached across callers: searches for 1 hour, timezones never, every other lookup for 24 hours. A cache hit spends no credit
Forgiving inputs: comma-separated lists, any-case enums and codes, alpha-3 and numeric country codes,
UKforGB, aP.PPLCclass prefix, and a geonames.org URL in place of ageonameId
Agent-friendly output:
Typed failure reasons separate the caller's account (
caller_account_rejected) from the operator's (server_account_rejected), a spent quota (quota_exhausted, withdata.windowofhour,day,week, orlocal), and a value GeoNames rejected (upstream_rejected_parameter)Unknown ids return
found: falsewithguidancerather than an error; empty or partial pages carry anoticenaming the nextoffsetor the filter to loosenGeoNames placeholders for "none" (
population: 0, empty admin names,geonameId: 0) are dropped rather than reported as facts
Known limitations:
Shared quota on a shared deployment. All callers without their own username share the server account's 1,000 credits an hour. A burst of reverse geocodes (up to 7 credits each) can exhaust it, and GeoNames does not say when the window resets.
Search reaches only offset 5000 on the free tier, and
limitcaps at 100, so a result set is reachable up to its 5,100th row.Children cap at 1,000 per parent.
Postal data covers 122 countries. Ireland and Malta return only code prefixes. US nearby lookups place the first row at the query point rather than the ZIP centroid.
Nearby radius tops out at 300 km for places and features and 30 km for postal codes, GeoNames' free-tier ceilings.
Bounding boxes cannot cross the 180° meridian. Split such an area into two searches.
Coastal points can resolve to the ocean without a buffer. By default only a country that contains the point matches, so a harbor or shoreline point just outside the outline returns the sea while its nearby places are on land. Set
coastalBufferKm(up to 50) to match the nearest country instead; in a strait that can be either shore.Microstates and enclaves can resolve to the surrounding country. A point inside Vatican City returns Italy.
Nearest populated places include sections and historical places. In a dense city the nearest rows are often
PPLXquarters orPPLHformer districts; each row'sfeatureCodesays which, andcitiesrestricts to places above a population tier.Offshore timezones are offsets only. No IANA id, local time, sunrise, or sunset is available at sea, and the 1 July offset is the standard offset (open water has no DST).
exact_namematches alternate and historical names, so a result'snamecan differ from the query: "Springfield" can return Plattsburg or Palmyra, MO.Data is community-edited and provided "as is". Many features have no recorded population or elevation.
Getting started
Public Hosted Instance
A public instance is available at https://geonames.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"geonames-mcp-server": {
"type": "streamable-http",
"url": "https://geonames.caseyjhand.com/mcp"
}
}
}A call that passes no geonamesUsername spends the hosted instance's GeoNames account, whose 1,000 credits an hour are shared by every such caller. Pass your own geonamesUsername to spend your account's quota instead.
Self-Hosted / Local
Add the following to your MCP client configuration file, with your GeoNames username in place of the placeholder.
{
"mcpServers": {
"geonames-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/geonames-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"GEONAMES_USERNAME": "your_geonames_username"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"geonames-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/geonames-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"GEONAMES_USERNAME": "your_geonames_username"
}
}
}
}Or with Docker:
{
"mcpServers": {
"geonames-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"-e", "GEONAMES_USERNAME=your_geonames_username",
"ghcr.io/cyanheads/geonames-mcp-server:latest"
]
}
}
}For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 GEONAMES_USERNAME=your_geonames_username bun run start:http
# Server listens at http://localhost:3010/mcpPrerequisites
Bun v1.4.0 or higher (or Node.js v24+).
A free GeoNames account with free web services enabled on its account page. GeoNames rejects calls from an account until they are enabled.
Installation
Clone the repository:
git clone https://github.com/cyanheads/geonames-mcp-server.gitNavigate into the directory:
cd geonames-mcp-serverInstall dependencies:
bun installConfigure environment:
cp .env.example .env
# edit .env and set GEONAMES_USERNAMEConfiguration
Every GeoNames call spends credits from a GeoNames account. GEONAMES_USERNAME is the server's account: a free GeoNames account with free web services enabled on its account page. Every tool also takes geonamesUsername (alias username), so a caller on a shared deployment can spend their own account instead of the server's. When neither is set, calls fail with username_required; only the bundled feature_classes and feature_codes topics of geonames_list_reference work without an account.
A free account gets 1,000 credits an hour and 10,000 a day. Cached lookups spend nothing.
Tool | Credits per call |
| 1 |
| 1; 2 for |
| 1 ( |
| 1 for containment (with or without |
| 1 a day; the country table is cached |
| 0 for |
Variable | Description | Default |
| GeoNames account used when a call passes no | none |
| Transport: |
|
| HTTP server port. |
|
| HTTP session mode: |
|
| Authentication: |
|
| Log level ( |
|
| Directory for log files (Node.js only). |
|
| Log each failed tool call's arguments and result, redacted by key name ( |
|
| Storage backend: |
|
| Enable OpenTelemetry. |
|
See .env.example for the full list of optional overrides.
Running the server
Local development
Build and run the production version:
# One-time build bun run rebuild # Run the built server bun run start:http # or bun run start:stdioRun checks and tests:
bun run devcheck # Lints, formats, type-checks, and more bun run test # Runs the test suite
Project structure
Directory | Purpose |
|
|
|
|
| The eight tool definitions ( |
| GeoNames service: fetch boundary, status mapping, retry, per-account pacing, response cache, parsers, and the bundled feature-code and country-code tables. |
| Inline-text sanitizer for GeoNames-authored text in |
| Unit and integration tests, mirroring the |
| Design notes: tool surface, credential model, upstream behavior. |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor logging,ctx.statefor storageRegister new tools in
src/mcp-server/tools/definitions/index.tsWrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Free GeoNames MCP: countries, cities, POIs, distance & nearby. Remote HTTP + agent token signup.
Geocode, reverse-geocode, autocomplete, route and search places.
Geocode, reverse geocode, and run Overpass spatial queries on OpenStreetMap data.
Geocode, reverse geocode, and run Overpass spatial queries on OpenStreetMap data.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides forward/reverse geocoding, bounding box extraction, nearby places discovery, batch geocoding, route waypoints, and administrative boundary lookup using OpenStreetMap data.10Apache 2.0
- AlicenseAqualityCmaintenanceUnified place search and geocoding over OpenStreetMap, Google, and your own CSV data. Provider fallback, multi-provider merge + dedup, cost budgets, and a policy engine. Works with zero API keys. Tools: search_places, get_place, geocode_address, reverse_geocode, list_geo_providers.10Apache 2.0
- AlicenseNot gradedqualityAmaintenanceGeocode places, fetch global weather forecasts, ERA5 historical climate, marine conditions, air quality, and terrain elevation via MCP. Provides 11 tools over STDIO or Streamable HTTP.683 npm8Apache 2.0
- AlicenseAqualityCmaintenanceEnables LLMs to geocode and reverse geocode places, find nearby points of interest, search categories within an area, get turn-by-turn routing, suggest meeting points, and analyze neighborhoods, commutes, schools, EV charging, and parking through OpenStreetMap data services. It also serves place and map tile resources over stdio, SSE, or Streamable HTTP transports.12MIT