Search GeoNames places, walk admin hierarchies, reverse geocode, get postal codes and country info.
One address for any MCP client. No sign-in needed on this server.
7 read1 other
Grouped by tool name. At most: only reads or looks up information.
Odel charges nothing per call. The publisher may charge for its own service.
Search GeoNames places, walk admin hierarchies, reverse geocode, get postal codes and country info via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://geonames.caseyjhand.com/mcp
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.
| Tool | Description |
|---|---|
geonames_search_places | Search places by name, country, feature class or code, population tier, and bounding box |
geonames_get_place | Full record for one geonameId: admin chain, timezone, elevation, alternate names, postal codes, external identifiers |
geonames_get_hierarchy | Parent chain from Earth and the continent down to the feature |
geonames_get_children | Direct children of a feature in the administrative, tourism, or dependency tree |
geonames_reverse_geocode | Country and admin subdivisions (or the ocean) for a coordinate, plus the nearest places or features and an optional timezone |
geonames_find_postal_codes | Postal codes by code, by place name, or near a coordinate |
geonames_get_countries | Country facts: ISO and FIPS codes, geonameId, capital, population, area, languages, currency, postal-code format |
geonames_list_reference | Feature classes, feature codes, and the countries with postal-code data |
geonames_search_places toolquery (up to 200 characters) compared per match: name_required (default), any_field, exact_name, or name_prefix; filters countries (up to 10, by ISO alpha-2, alpha-3, or numeric code), featureClasses, featureCodes (up to 20), cities (cities1000 / cities5000 / cities15000), and boundingBox. A call needs query or one of countries, featureClasses, featureCodes, boundingBoxlimit 1–100 (default 10), offset 0–5000, orderBy relevance or population; returns totalCount, effectiveQuery, and nextOffsetfeatureClasses, featureCodes, and cities (class P only) intersect: with both lists set, each code's class must be listed and each listed class needs a code; beside cities, only class P and its codes. Anything else fails as feature_filter_mismatchquery_or_filter_required, query_required, unknown_country_code, unknown_feature_code, feature_filter_mismatch, or invalid_bounding_boxgeonames_get_place toolgeonameId; an unknown id returns found: false with guidanceadminLevels 1–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, and identifiers (IATA, ICAO, FAA, Transport Canada, UN/LOCODE, Wikidata)nameLanguages (up to 20 tags; zh also matches zh-CN) filters alternateNames onlygeonames_get_hierarchy toolgeonameId; chain runs from Earth and its continent through the country and admin divisions down to the feature, skipping levels it does not sit undergeonameId, feature class and code, country and first-level codes, coordinates, and population; an unknown id returns found: falsegeonames_get_children toolhierarchy: administrative (default), tourism (islands, coasts, and their municipalities; almost all in Spain), or dependency (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 Ttourism or dependency request with the administrative children when the feature has no such tree. The tool compares the two lists and sets sameAsAdministrative, with a notice, when they match; the rows stay, since a real tree can match toonameContains, limit (1–500, default 100), and offset cost no extra credits; a notice says when GeoNames lists morefound: false; a leaf returns an empty children list with a noticegeonames_reverse_geocode toollat / lng resolve to country and adminLevels (down to ADM5, each with its geonameId and ISO 3166-2 subdivision code where one exists) or, offshore, the oceancoastalBufferKm (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 carries country.distanceInKm, and the nearby and timezone lookups keep the exact pointnearby lists the nearest populated places (nearbyLimit 0–50, default 5; radiusKm up to 300, default 20; optional cities tier) or, when featureClasses / featureCodes is set, the nearest features of that type; nearbyKind says which. featureClasses and featureCodes intersectconflicting_filters (cities with a feature filter), unknown_feature_code, or feature_filter_mismatch (a code whose class is not listed, or a listed class with no code)includeTimezone adds 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 toolmode: code (needs postalCode), place_name (needs placeName), or nearby (needs lat and lng; radiusKm up to 30, default 10); a missing field, or countries in nearby, fails as mode_fields_mismatchcountries filter for code and place_name, by ISO alpha-2, alpha-3, or numeric code (an alpha-3 or numeric code no country has fails as unknown_country_code); limit 1–100 (default 10); GeoNames reports no total, so a full page is marked truncatedgeonames_get_countries toolcountries by ISO alpha-2, alpha-3, or numeric code, a continent, nameContains, or no filter for all 250; limit 1–250 (default 50) with offsetgeonameId (the starting point for geonames_get_children), capital, population, area, continent, languages, currency, postal-code format, and mainland bounding box; unknown codes land in notFoundgeonames_list_reference tooltopic: feature_classes (9), feature_codes (684, filterable by featureClass), or postal_countries (122, with each country's code range and count); featureClass with another topic fails as filter_not_applicablenameContains, limit 1–700 (default 100), and offset; feature classes and codes are bundled and spend no creditsBuilt 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:
UK for GB, a P.PPLC class prefix, and a geonames.org URL in place of a geonameIdAgent-friendly output:
caller_account_rejected) from the operator's (server_account_rejected), a spent quota (quota_exhausted, with data.window of hour, day, week, or local), and a value GeoNames rejected (upstream_rejected_parameter)found: false with guidance rather than an error; empty or partial pages carry a notice naming the next offset or the filter to loosenpopulation: 0, empty admin names, geonameId: 0) are dropped rather than reported as factsKnown limitations:
limit caps at 100, so a result set is reachable up to its 5,100th row.coastalBufferKm (up to 50) to match the nearest country instead; in a strait that can be either shore.PPLX quarters or PPLH former districts; each row's featureCode says which, and cities restricts to places above a population tier.exact_name matches alternate and historical names, so a result's name can differ from the query: "Springfield" can return Plattsburg or Palmyra, MO.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.
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/mcp
git clone https://github.com/cyanheads/geonames-mcp-server.git
cd geonames-mcp-server
bun install
cp .env.example .env
# edit .env and set GEONAMES_USERNAME
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 |
|---|---|
geonames_search_places, geonames_get_place, geonames_get_hierarchy | 1 |
geonames_get_children | 1; 2 for tourism or dependency when the parent's administrative list is not cached |
geonames_find_postal_codes | 1 (code, place_name); 2 (nearby) |
geonames_reverse_geocode | 1 for containment (with or without coastalBufferKm), plus 3 for nearest populated places or 4 for nearest features, 1 for the ocean when no country contains the point or lies within the buffer, and 1 for the timezone |
geonames_get_countries | 1 a day; the country table is cached |
geonames_list_reference | 0 for feature_classes and feature_codes; 1 a day for postal_countries |
| Variable | Description | Default |
|---|---|---|
GEONAMES_USERNAME | GeoNames account used when a call passes no geonamesUsername. Free at geonames.org; enable free web services on its account page. | none |
MCP_TRANSPORT_TYPE | Transport: stdio or http. | stdio |
MCP_HTTP_PORT | HTTP server port. | 3010 |
MCP_SESSION_MODE | HTTP session mode: stateless, stateful, or auto. .env.example and the Docker image set stateless. | auto |
MCP_AUTH_MODE | Authentication: none, jwt, or oauth. | none |
MCP_LOG_LEVEL | Log level (debug, info, warning, error, etc.). | info |
LOGS_DIR | Directory for log files (Node.js only). | <app-root>/logs |
LOG_TOOL_FAILURE_PAYLOADS | Log each failed tool call's arguments and result, redacted by key name (geonamesUsername and username included). | false |
STORAGE_PROVIDER_TYPE | Storage backend: in-memory, filesystem, supabase, cloudflare-kv/r2/d1. | in-memory |
OTEL_ENABLED | Enable OpenTelemetry. | false |
See .env.example for the full list of optional overrides.
Build and run the production version:
# One-time build
bun run rebuild
# Run the built server
bun run start:http
# or
bun run start:stdio
Run checks and tests:
bun run devcheck # Lints, formats, type-checks, and more
bun run test # Runs the test suite
| Directory | Purpose |
|---|---|
src/index.ts | createApp() entry point: server instructions, tool registration, GeoNames service setup and teardown. |
src/config | GEONAMES_USERNAME parsing and validation with Zod. |
src/mcp-server/tools | The eight tool definitions (*.tool.ts) and the inputs they share (shared-inputs.ts). |
src/services/geonames | GeoNames service: fetch boundary, status mapping, retry, per-account pacing, response cache, parsers, and the bundled feature-code and country-code tables. |
src/utils | Inline-text sanitizer for GeoNames-authored text in format() output. |
tests/ | Unit and integration tests, mirroring the src/ structure. |
docs/design.md | Design notes: tool surface, credential model, upstream behavior. |
See CLAUDE.md for development guidelines and architectural rules. The short version:
try/catch in tool logicctx.log for logging, ctx.state for storagesrc/mcp-server/tools/definitions/index.tsIssues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.