osm-mcp

osm-mcp

An MCP server that provides live geospatial data such as geocoding, POI search, isochrones, and area density from open data sources to LLM clients like Claude, Cursor, or Claude Code.

Category
访问服务器

README

Open MCP Data Server

An MCP server that gives Claude (or Cursor, or Claude Code) live geospatial data — geocoding, POI search, isochrones, and area density — over open data.

CI PyPI License: MIT

One-line pitch: turn real open data sources into tools any LLM client can call directly. The model orchestrates the calls; this server does the fetching, caching, rate-limiting, and typed validation.


The hook (demo)

Ask Claude Desktop a real geography question and it calls your tools directly:

You (in Claude Desktop):
  "I'm opening a coffee shop. Find all existing cafés within a 15-minute walk
   of Bukit Bintang MRT, and tell me the postcode centroid so I can cross-check
   rent data."

Claude:
  → isochrone(lat=3.1498, lon=101.7149, mode="walk", minutes=15)
  → pois(lat=3.1499, lon=101.7144, radius_m=1200, categories=["cafe"])
  → reverse_geocode(lat=3.1499, lon=101.7144)
  ← cafe list (12 matches), postcode "55100", centroid coords

Claude:
  "There are 12 cafés within a 15-min walk. The postcode centroid is 55100
   (Bukit Bintang). Here's the list, sorted by distance…"

The user never sees an API key or an HTTP call — the model orchestrates the tools. That orchestration, made possible by the server's tool design, is the point of this project.

📸 GIF of a live Claude Desktop session goes here on first publish.


How it works

  ┌─────────────────────┐         MCP (JSON-RPC over stdio)
  │   LLM Client        │  ─────────────────────────────────────┐
  │  (Claude Desktop /  │                                        │
  │   Cursor / Code)    │  ◄──── tool schemas advertised         │
  └─────────────────────┘                                        ▼
                                ┌─────────────────────────────┐
                                │   Open MCP Data Server      │
                                │  (FastMCP Python process)   │
                                │                             │
                                │  @mcp.tool: geocode         │
                                │  @mcp.tool: reverse_geocode │
                                │  @mcp.tool: pois            │
                                │  @mcp.tool: isochrone       │
                                │  @mcp.tool: bbox_summary    │
                                │                             │
                                │  TTLCache + rate limiting   │
                                └──────────────┬──────────────┘
                                               │  https GET/POST
                    ┌──────────────────────────┼──────────────────────┐
                    ▼                          ▼                      ▼
          ┌─────────────────┐    ┌────────────────────┐    ┌─────────────────┐
          │ OSM Nominatim   │    │ Overpass API       │    │ OSRM            │
          │ (geocoding)     │    │ (POIs by amenity)  │    │ (isochrones)    │
          └─────────────────┘    └────────────────────┘    └─────────────────┘

Each tool is a thin async function that fetches upstream data through a shared cache + per-host rate limiter, validates it with Pydantic, and returns a typed result. Inputs are enum-constrained — callers never supply raw Overpass QL.


Tools

Tool Description Units
geocode(query) Forward geocode a place name → coordinate. lat/lon decimal degrees
reverse_geocode(lat, lon) Coordinate → human-readable address. decimal degrees → string
pois(lat, lon, radius_m, categories) Points of interest within a radius, by category. metres; counts
isochrone(lat, lon, mode, minutes) Reachable-area polygon within a time budget. minutes; polygon [lon,lat]; area m²
bbox_summary(min_lat, min_lon, max_lat, max_lon, categories?) Counts of key amenities inside a bounding box (density helper). counts

mode ∈ {walk, drive, transit}. categories are enum-constrained (cafe, restaurant, retail, transit, school, attraction, accommodation, bank, healthcare) — all Overpass queries are built server-side.


Quick start

git clone https://github.com/abangbroy/osm-mcp.git
cd osm-mcp
python -m venv .venv && .venv\Scripts\activate     # Windows
# source .venv/bin/activate                        # macOS/Linux
pip install -e ".[dev]"

Run standalone over stdio:

osm-mcp            # or: python -m osm_mcp

Or install the published package directly:

uvx osm-mcp        # or: pip install osm-mcp

Set USER_AGENT (see .env.example) to a descriptive value — Nominatim usage policy requires it.

Claude Desktop config

Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "osm-mcp": {
      "command": "C:\\path\\to\\osm-mcp\\.venv\\Scripts\\osm-mcp.exe",
      "args": []
    }
  }
}

With the published package:

{
  "mcpServers": {
    "osm-mcp": {
      "command": "uvx",
      "args": ["osm-mcp"]
    }
  }
}

Cursor config

Point Cursor at the same command via Settings → MCP → Add Server, using osm-mcp (local venv) or uvx osm-mcp (published).

Tests

pytest --cov=osm_mcp --cov-report=term-missing

Upstream dependencies & rate-limit policy

All upstream APIs are free-tier and shared/public, so they are rate-limited. This server respects their usage terms:

  • TTL cache (CACHE_TTL_SECONDS, default 24h) + per-host rate limiting (RATE_LIMIT_MIN_INTERVAL_SECONDS, default 1s — Nominatim's policy ceiling).
  • A compliant User-Agent header (configurable; required by Nominatim).
  • Bounded retry with exponential backoff for transient errors (429/502/503/ 504, timeouts), honoring Retry-After.
  • transit mode falls back to the OSRM foot profile — OSRM has no transit router. For real transit isochrones, self-host a transit router and point OSRM_BASE_URL at it. This is a documented limitation, stated openly.
  • For production throughput, self-host Nominatim / Overpass / OSRM and set the *_BASE_URL env vars.

Attribution: data © OpenStreetMap contributors (ODbL). Code is MIT; data attribution must accompany any reuse.


Configuration

All settings are environment-driven (see .env.example):

Variable Default Purpose
NOMINATIM_BASE_URL https://nominatim.openstreetmap.org Geocoding upstream
OVERPASS_BASE_URL https://overpass-api.de POI upstream
OSRM_BASE_URL https://router.project-osrm.org Routing upstream
USER_AGENT osm-mcp/0.1.0 (...) Required by Nominatim policy
CACHE_MAXSIZE / CACHE_TTL_SECONDS 2048 / 86400 TTL cache sizing
RATE_LIMIT_MIN_INTERVAL_SECONDS 1.0 Per-host request spacing
HTTP_TIMEOUT_SECONDS 15.0 Upstream call timeout

Publishing

v1 ships stdio transport. Releases are automated:

  1. PyPI — pushing a v* tag runs publish.yml, which re-runs the tests and lint, verifies the tag matches the version in pyproject.toml, builds, and uploads via Trusted Publishing (OIDC — no API token is stored in the repo).

    git tag v0.1.0 && git push origin v0.1.0
    

    Requires a one-time pending publisher on PyPI — see the header comment in publish.yml for the exact field values.

  2. Official MCP registry — submit server.json at registry.modelcontextprotocol.io once the PyPI release is live. The server is registered as io.github.abangbroy/osm-mcp; the io.github.<user>/ namespace is what proves GitHub ownership.

SSE-only transports are deprecated since MCP spec 2025-03-26. A Streamable HTTP transport is the planned v2 stretch (no SSE).


Learned in public

This project is a portfolio piece. A few things I learned openly while building it, rather than claiming prior mastery:

  • FastMCP packaging — wiring @mcp.tool decorators to Pydantic-typed signatures and exposing the bounds in the generated JSON schema (so the model sees the limits, not just gets rejected by them).
  • OSRM as an isochrone source — OSRM has no native isochrone endpoint; the radial-sampling + /table approach is a public-methodology workaround.
  • Overpass (poly:) coordinate order — it expects latitude-then-longitude, the opposite of GeoJSON; getting this wrong returns HTTP 400 live.

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选