OpenStreetMap

io.github.ni-c由 GitHub 帳號 ni-c 發布v0.3.2更新於 Oct 24, 2026

Geocoding, walking/driving/cycling distances, route optimization, isochrones and POI search on OSM

概覽

AI 產生的概覽

唯讀的 OpenStreetMap 伺服器,提供地理編碼、步行/開車/騎車路線、等時圈與周邊興趣點搜尋,適合旅遊規劃。

可以做什麼
  • 把地名或地址轉成座標,以及反向查出最近的地址
  • 計算步行、開車、騎車路線的距離與時間,產生多點行程時間矩陣並排定多點造訪順序
  • 查出在指定時間或距離內可抵達的範圍,並為多人建議車程均衡的會面地點
  • 依類別或 OSM 標籤搜尋周邊興趣點,並讀取單一元素的完整紀錄
  • 離線計算直線距離,並產生 openstreetmap.org 標記或路線連結
適用情境
適合讓助理在對話中直接回答地點、距離、路線與興趣點問題來協助行程規劃,尤其是需要準確的步行與騎車時間、而非只以開車估算時。
執行需求
透過 npx 以 stdio 在本機執行(需 Node.js 24 以上),或使用 Docker 映像;需要連線到公開的 OpenStreetMap 服務。不需要 API 金鑰;選用的 ORS_API_KEY 會把路線、矩陣與等時圈改用 OpenRouteService。建議設定 OSM_USER_AGENT,讓 Nominatim 能辨識用戶端。
安裝前請注意
所有工具皆為唯讀且不需憑證,但選用的 ORS_API_KEY 屬於機密,應只透過環境變數提供。請求會送往共用的社群服務,有速率限制與非商業使用的要求;大量或商業用途應把各 base URL 變數指向自架執行個體。OSM 內容會以不受信任資料的形式回傳。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 OpenStreetMap,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

osm-mcp

[CI] [OpenSSF Scorecard] [Socket Badge] [Glama score]
[npm version] [container image] [HTTP via mcp-hub]
[docs] [sponsor]

A Model Context Protocol (MCP) server for OpenStreetMap, built for travel planning.

Lets MCP clients like Claude Code, Claude Desktop or Codex answer questions about places: geocoding, walking, driving and cycling distances and durations, multi-stop route optimization, isochrones and POI search — 11 tools, all read-only.

Eleven tools is the ceiling, not the floor: OSM_ALLOW_TOOLS=essential registers a curated six instead, and a model picks the right tool far more reliably from six than from eleven — see choosing which tools load.

All backends are free public OpenStreetMap services, so no API key is required. An OpenRouteService key can be supplied optionally to switch the routing engine.

[An MCP client talks to osm-mcp over stdio; the server exposes eleven read-only tools with rate limiting and caching, and calls Nominatim, Photon, OSRM, Valhalla and Overpass over HTTPS — plus OpenRouteService optionally with an API key] [Terminal recording: the server reports eleven tools, geocodes the Porta Nigra in Trier, and returns a walking route with distance and duration]

What makes it different

  • Correct walking/cycling routes. The public OSRM demo servers ignore the profile segment inside the OSRM URL path and always return car routes unless the FOSSGIS routed-foot / routed-bike / routed-car path prefixes are used. Most existing OSM MCP servers get this wrong and silently return driving times for walking queries. This server uses the prefixes and its live smoke test asserts that foot routes are much slower than car routes.
  • Policy-compliant by construction. Per-service rate limiting (Nominatim and OSRM: 1 request/second), an identifying User-Agent on every request (required by the Nominatim usage policy), response caching, capped Overpass concurrency (2 slots) and automatic failover to the next Overpass endpoint on anything but a malformed query, within one 50-second budget per call.
  • Photon support. Optional typo-tolerant geocoding via komoot's Photon, which is designed for interactive use — a better fit for LLM-driven lookups than hammering Nominatim.

Requirements

  • Node.js ≥ 24
  • Internet access to the public OpenStreetMap services (see table below)

Configuration

Every variable is optional — the server works out of the box.

VariableDefaultDescription
OSM_USER_AGENTosm-mcp/<version> (+https://github.com/ni-c/osm-mcp)User-Agent sent to every service. Nominatim requires a real, identifying one.
NOMINATIM_BASE_URLhttps://nominatim.openstreetmap.orgGeocoding / reverse geocoding
PHOTON_BASE_URLhttps://photon.komoot.ioTypo-tolerant geocoding
OSRM_BASE_URLhttps://routing.openstreetmap.deRouting, matrices, trip optimization. Must serve the routed-{car,bike,foot} path prefixes (the FOSSGIS layout).
OVERPASS_BASE_URLhttps://z.overpass-api.de/api/interpreter,https://lz4.overpass-api.de/api/interpreterComma-separated Overpass endpoints, tried in order until one answers (a malformed query stops the walk)
VALHALLA_BASE_URLhttps://valhalla1.openstreetmap.deIsochrones
ORS_API_KEY–Optional OpenRouteService key (secret). When set, routes, matrices and isochrones use ORS instead of OSRM/Valhalla. Free tier: 2000 directions/day, 40/minute.
ORS_BASE_URLhttps://api.openrouteservice.orgOpenRouteService endpoint
OSM_CACHE_TTL3600Seconds identical upstream responses are served from the in-memory cache (0 disables caching)
OSM_ALLOW_TOOLSnoComma-separated tool names, list_* prefixes, or essential for a curated preset
OSM_DENY_TOOLSnoSame syntax; removed from whatever OSM_ALLOW_TOOLS left

Choosing which tools load

OSM_ALLOW_TOOLS and OSM_DENY_TOOLS take comma-separated tool names; a trailing * matches a whole family. essential is a curated preset of six: geocode, reverse_geocode, find_nearby_pois, poi_details, route, map_link.

sh
OSM_ALLOW_TOOLS=essentialOSM_ALLOW_TOOLS=geocode,route,find_nearby_poisOSM_DENY_TOOLS=isochrone,optimize_route

An entry that matches no tool aborts startup and names it, so a typo cannot silently hide a tool — an absent tool is not something anyone traces back to an environment variable. A filtered tool is never registered, so it is absent from tools/list and unknown to tools/call alike.

If you run several of these servers at once, mcp-hub is the other answer — its /hub endpoint replaces every server's tools with six meta-tools.

Installation

Claude Code

sh
claude mcp add osm -- npx -y osm-mcp

Claude Desktop

claude_desktop_config.json:

json
{  "mcpServers": {    "osm": {      "command": "npx",      "args": ["-y", "osm-mcp"]    }  }}

Codex

~/.codex/config.toml:

toml
[mcp_servers.osm]command = "npx"args = ["-y", "osm-mcp"]

Docker

Multi-arch, with SBOM and build provenance:

sh
docker run -i --rm ghcr.io/ni-c/osm-mcp

-i is required — the protocol runs over stdin and stdout. There is no port to publish. More client recipes are in the client guide.

Through mcp-hub

A client that cannot spawn a local process — ChatGPT connectors, Claude on the web, Cursor, LibreChat — reaches osm-mcp through mcp-hub: one container serves many stdio MCP servers over Streamable HTTP, with an OAuth 2.1 login behind a single password and long-lived tokens for the clients that cannot do OAuth. Its /hub endpoint puts every server behind six meta-tools, so one connector reaches all of them without N×tool schemas in the model's context, and it speaks both protocol revisions — a question this server asks travels through it to the person at the far end.

Its /config/mcp.json uses Claude Code's format, so the entry is the one you already have:

json
{  "mcpServers": {    "osm": {      "command": "npx",      "args": ["-y", "osm-mcp"],      "env": { "OSM_ALLOW_TOOLS": "essential" },      "denyTools": ["isochrone"]    }  }}

allowTools and denyTools there are the hub's own per-server filter, which is not the same thing as *_ALLOW_TOOLS in env — the difference, and the mistake it invites, are in the client guide.

Tools

ToolDescription
geocodePlace name/address → coordinates (Nominatim or Photon)
reverse_geocodeCoordinates → nearest address
routeDistance and duration between 2+ waypoints, foot/car/bike; optional turn-by-turn summary
route_matrixTravel time/distance from every origin to every destination in one call
optimize_routeBest visiting order for a set of stops (traveling-salesman, OSRM trip)
isochroneReachable area within a time or distance budget (Valhalla, or ORS with key)
find_nearby_poisPOIs around a location by category or raw OSM tag, sorted by distance (Overpass)
poi_detailsFull OSM record of one element: opening hours, website, phone, …
suggest_meeting_pointFair meeting venue for 2–8 people (balanced travel times)
straight_line_distanceGreat-circle distance, computed offline
map_linkopenstreetmap.org marker / directions links, computed offline

Every place input accepts either a name/address (geocoded automatically) or literal coordinates as "lat,lon".

Structured output

Every tool declares an outputSchema and answers with structuredContent alongside the text block, so a client can use the result without parsing prose:

jsonc
{  "untrusted": true,  "source": "openstreetmap",  "profile": "foot",  "engine": "osrm",  "waypoints": ["Berlin Hauptbahnhof", "Brandenburger Tor"],  "distance": "2.3 km",  "distance_m": 2317,  "duration": "29 min",  "duration_s": 1740,}

Every tool carries untrusted: true and source: "openstreetmap" — there is no exception list, because OpenStreetMap is editable by anyone on earth and no tool here answers with anything else. A client that reads only the structured half would otherwise get a mapper's free text with no framing at all.

What this server computes — distances, durations, coordinates, which routing engine ran — is described exactly. What comes out of OSM is described but left open: the tag namespace has no schema, and a mapper adding payment:bitcoin must not take poi_details out of service. The SDK validates every result against its schema before it goes out, so a stricter shape would do exactly that.

The control-character and BiDi stripping this server has always done to its text now runs over the structured value too, key by key. It used to happen on the serialized JSON, which reached every string in it for free.

Usage policies & attribution

This server talks to shared community infrastructure. It enforces the published limits client-side, but the operator asks users to keep overall usage light and non-commercial:

  • Data: © OpenStreetMap contributors, licensed under ODbL 1.0.
  • Nominatim: max 1 request/second, identifying User-Agent mandatory, results cached (policy).
  • OSRM / Valhalla (FOSSGIS): reasonable, non-commercial use; max 1 request/second (about).
  • Overpass: ~2 concurrent slots per IP, <10 000 queries/day (wiki).
  • Photon: fair use (photon.komoot.io).

For heavy or commercial use, self-host the services and point the *_BASE_URL variables at your instances.

Not exposed, on purpose

No editing. All eleven tools are read-only against OpenStreetMap; the editing API is not wired up at all, so there is no write mode to switch off.

No rendering and no tracking. Results are structured data plus links rather than images — map_link hands you a URL to look at the map yourself — and there is no state between calls.

No offline mode. Every answer comes from the public OpenStreetMap services, under their usage policies.

Safety

  • All tools are read-only; the server never writes to OpenStreetMap.
  • No credentials are required; the optional ORS_API_KEY is removed from the process environment after loading and redacted from error messages.
  • OSM-sourced content (names, addresses, tags) is marked as untrusted data in tool results so the model treats it as data, not instructions.
  • Upstream error bodies are truncated and HTML error pages dropped before they reach the model context; the HTTP status is decided before a body is read.
  • Every value a service answers is shaped before it reaches a result: finite numbers, bounded strings, one malformed element dropped rather than the whole listing.
  • Redirects are never followed; all requests time out.

Documentation

The full guide, tool reference and security notes live at osm-mcp.ni-c.de (source in docs/).

Development

sh
npm installnpm run lint          # oxlint + prettiernpm test              # unit tests (all upstream APIs mocked)npm run test:coveragenpm run buildnpm run smoke         # opt-in LIVE test against the real public services

Releasing

Tag-driven, no manual publish step:

  1. Move the [Unreleased] entries into a new ## [x.y.z] - YYYY-MM-DD section in CHANGELOG.md and bump package.json.
  2. npm run lint && npm run build && npm run test:coverage.
  3. Commit, then a signed annotated tag: git tag -s vx.y.z -m "vx.y.z".
  4. git push origin main vx.y.z.

release.yml then runs the tests, publishes to npm with provenance via Trusted Publishing (no token secret involved), creates the GitHub release from the CHANGELOG section, and publishes to the MCP registry as io.github.ni-c/osm-mcp. ci.yml pushes the multi-arch image to GHCR on the same tag.

If the registry step fails, fix it on main and dispatch the Publish to MCP Registry workflow — do not re-run the tag job, which would check out the old tree.

Contributing

Issues, discussions and pull requests are welcome — see CONTRIBUTING.md. For vulnerabilities please use private reporting rather than a public issue; the policy is in SECURITY.md.

License

MIT © Willi Thiel

來源:README.md,提交 b4779f6

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

2
  1. v0.3.2最新Oct 15, 2026
  2. v0.3.1Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分