mapy-geocode-mcp
by lbehounek
README.md
# mapy-geocode-mcp
A tiny **local** [MCP](https://modelcontextprotocol.io/) server with one tool: give it a place name or an address, get
back GPS coordinates, the municipality / district / region, and the straight-line distance from your own "home" point.
```
"Černokostelecká, Říčany" ──► 49.99 N, 14.65 E · Říčany · Okres Praha-východ · 19.8 km SE of home · within radius
```
It uses the [Mapy.com REST API](https://developer.mapy.com/rest-api-mapy-cz/) geocoder (best coverage in Czechia) with
your own API key. Unofficial: not affiliated with Mapy.com or Seznam.cz.
Typical use: an assistant reads an incoming request that mentions a location and has to answer "is this in our area?"
before anyone spends time on it.
## Local only, on purpose
This server is meant to run **on your own computer**, started by your MCP client (Claude Desktop, Claude Code, …) over
stdio. It is not a remote server and should not be turned into one:
- there is no HTTP listener and no authentication, because nothing outside your machine is supposed to reach it;
- your API key lives in your local client configuration and is sent only to `api.mapy.com`;
- nothing is stored: no cache, no log of queries, no telemetry.
The only thing that leaves your machine is the query text (the place you ask about), which goes to Mapy.com.
## Requirements
- Node.js 20 or newer
- A Mapy.com API key: register a project at <https://developer.mapy.com/> (the free tier is far more than a person
can use by hand)
No other dependencies: the package installs nothing but itself.
## Install
Add the server to your MCP client configuration. For Claude Desktop that is `claude_desktop_config.json`
(Settings → Developer → Edit Config):
```json
{
"mcpServers": {
"mapy-geocode": {
"command": "npx",
"args": ["-y", "https://github.com/lbehounek/mapy-geocode-mcp/archive/refs/tags/v0.1.0.tar.gz"],
"env": {
"MAPY_API_KEY": "your-key",
"MAPY_HOME": "50.0875,14.4213",
"MAPY_HOME_LABEL": "office",
"MAPY_RADIUS_KM": "40"
}
}
}
}
```
`npx` downloads that exact tagged release from GitHub and runs it; pinning the tag means an update never arrives
unannounced. Restart the client after editing the file.
On Windows, if the client cannot start `npx` directly, wrap it:
```json
"command": "cmd",
"args": ["/c", "npx", "-y", "https://github.com/lbehounek/mapy-geocode-mcp/archive/refs/tags/v0.1.0.tar.gz"]
```
Claude Code: `claude mcp add mapy-geocode -e MAPY_API_KEY=your-key -e MAPY_HOME=50.0875,14.4213 -- npx -y https://github.com/lbehounek/mapy-geocode-mcp/archive/refs/tags/v0.1.0.tar.gz`
## Configuration
| Variable | Required | Meaning |
|---|---|---|
| `MAPY_API_KEY` | yes | Your Mapy.com API key. |
| `MAPY_HOME` | no | Home point as `latitude,longitude` in decimal degrees (`50.0875,14.4213` or `50.0875N, 14.4213E`). Without it the tool still finds places but reports no distance. |
| `MAPY_HOME_LABEL` | no | A name for the home point, echoed in results (`office`). |
| `MAPY_RADIUS_KM` | no | Your service radius in km. Each candidate then gets `within_radius`, and the result a `radius_summary`. Needs `MAPY_HOME`. |
| `MAPY_LANG` | no | Language of place names, default `cs`. One of `cs de el en es fr it nl pl pt ru sk tr uk`. |
A wrong setting does not stop the server from starting; the tool tells you what to fix the first time it is called.
## The tool: `locate_place`
| Argument | Type | Meaning |
|---|---|---|
| `query` | string, 1–150 chars | The place: address, street + municipality, municipality, or point of interest. |
| `limit` | integer 1–15, default 5 | Maximum number of candidates. |
Example result:
```json
{
"query": "Říčany",
"count": 2,
"home": { "lat": 50.0875, "lon": 14.4213, "label": "office" },
"distance_method": "straight line (great circle), not driving distance",
"radius_km": 40,
"radius_summary": "mixed",
"candidates": [
{
"name": "Říčany", "label": "Město", "type": "regional.municipality", "location": "Česko",
"municipality": "Říčany", "municipality_parts": [],
"regions": ["Okres Praha-východ", "Středočeský kraj"], "country_code": "CZ", "zip": null,
"lat": 49.9917, "lon": 14.6543, "distance_km": 19.8, "direction": "SE", "within_radius": true
},
{
"name": "Říčany", "label": "Obec", "type": "regional.municipality", "location": "Česko",
"municipality": "Říčany", "municipality_parts": [],
"regions": ["Okres Brno-venkov", "Jihomoravský kraj"], "country_code": "CZ", "zip": null,
"lat": 49.2151, "lon": 16.3936, "distance_km": 172, "direction": "SE", "within_radius": false
}
],
"note": "Candidates disagree about the radius. Decide which one is meant from the district/region or other context, or report the place as ambiguous.",
"attribution": "Geocoding data: Mapy.com (© Seznam.cz, a.s. and others)"
}
```
### Why several candidates
Place names repeat. In Czechia 591 municipality names are shared by 1,503 municipalities; there is a Říčany 20 km from
Prague and another one 170 km away. A tool that returned one "best" hit would turn an ambiguous name into a confident
wrong distance, so this one returns all candidates and says `mixed` when they disagree about the radius.
### Limits worth knowing
- **Distances are straight-line**, not driving distances.
- **Road numbers and kilometre markers** ("road II/101 near …", "D1 exit 21") are not something geocoders resolve
reliably. Ask with the nearest municipality instead.
- Result quality is whatever the Mapy.com geocoder returns; outside Czechia its data comes from OpenStreetMap.
## Mapy.com terms
You use the API under your own key and the [Mapy.com API terms](https://developer.mapy.com/terms-and-conditions/);
read them before relying on this for a business. Two points shaped this server: results must not be stored or cached
(it keeps nothing), and the data source must be credited (every result carries an `attribution` line; show it when you
show the data).
## Security notes
- The key is sent in the `X-Mapy-Api-Key` header, never in a URL, and only to `api.mapy.com`; redirects are refused.
- The query is treated as untrusted text (it often comes from an e-mail): it is length-limited, stripped of control
characters and percent-encoded, so it cannot alter the request.
- Error messages never include the key or raw network details.
- Restrict the key to the geocoding service in the Mapy.com developer console.
- MCP client configuration files usually hold the key in plain text. Treat that file accordingly.
## Protocol support
stdio transport. Protocol versions `2026-07-28` (stateless, `server/discover`) and the handshake versions
`2024-11-05` … `2025-11-25` (`initialize`).
## Development
```bash
node --test # or: pnpm test
```
Tests never touch the network; the API client is exercised through an injected `fetch`.
## License
MIT