osm-mcp
osm-mcp
一个用于 OpenStreetMap 的 MCP 服务器:提供地理编码、步行/驾车/骑行距离与时长、多点路线优化、等时线及兴趣点搜索——专为 AI 助手的旅行规划而构建。
共 11 个工具,全部为只读。所有后端均为免费的公共 OpenStreetMap 服务;无需 API 密钥。可选择性提供 OpenRouteService 密钥以切换路由引擎。
📖 完整文档:https://osm-mcp.ni-c.de
为什么需要另一个 OSM MCP 服务器?
正确的步行/骑行路线。 公共 OSRM 演示服务器会忽略 OSRM URL 路径中的配置文件段,除非使用 FOSSGIS 的
routed-foot/routed-bike/routed-car路径前缀,否则始终返回驾车路线。大多数现有的 OSM MCP 服务器在这方面都是错误的,会静默地为步行查询返回驾车时间。本服务器使用了这些前缀,其实时冒烟测试断言步行路线的速度远慢于驾车路线。符合策略要求。 按服务进行速率限制(Nominatim 和 OSRM:每秒 1 个请求),每个请求都带有标识性的 User-Agent(Nominatim 使用策略要求),响应缓存,限制 Overpass 并发数(2 个槽位),并在遇到 429/5xx 错误时自动故障转移到 Overpass 镜像。
支持 Photon。 通过 komoot 的 Photon 提供可选的容错地理编码,该服务专为交互式使用而设计——比频繁调用 Nominatim 更适合 LLM 驱动的查询。
Related MCP server: Geo MCP Worker
系统要求
Node.js ≥ 22
能够访问公共 OpenStreetMap 服务(见下表)
配置
所有变量均为可选——服务器开箱即用。
变量 | 默认值 | 描述 |
|
| 发送给每个服务的 User-Agent。Nominatim 要求使用真实且可识别的 User-Agent。 |
|
| 地理编码/反向地理编码 |
|
| 容错地理编码 |
|
| 路由、矩阵、行程优化。必须提供 |
|
| 逗号分隔的 Overpass 端点,在遇到 429/5xx 错误时按顺序尝试 |
|
| 等时线 |
| – | 可选的 OpenRouteService 密钥(机密)。设置后,路线、矩阵和等时线将使用 ORS 而非 OSRM/Valhalla。免费套餐:每天 2000 次方向查询,每分钟 40 次。 |
|
| OpenRouteService 端点 |
|
| 相同上游响应从内存缓存中提供的秒数( |
安装
claude mcp add osm -- npx -y osm-mcpClaude Desktop(claude_desktop_config.json):
{
"mcpServers": {
"osm": {
"command": "npx",
"args": ["-y", "osm-mcp"]
}
}
}Codex(~/.codex/config.toml):
[mcp_servers.osm]
command = "npx"
args = ["-y", "osm-mcp"]容器(多架构,包含 SBOM 和构建来源):
docker run -i --rm ghcr.io/ni-c/osm-mcp-i 是必需的——协议通过标准输入和标准输出运行。没有需要发布的端口。更多客户端配置请参见客户端指南。
工具
工具 | 描述 |
| 地名/地址 → 坐标(Nominatim 或 Photon) |
| 坐标 → 最近地址 |
| 2 个及以上途经点之间的距离和时长,支持 |
| 一次调用即可获取从每个起点到每个终点的旅行时间/距离 |
| 一组停靠点的最佳访问顺序(旅行商问题,OSRM trip) |
| 在时间或距离预算内可到达的区域(Valhalla,或使用密钥的 ORS) |
| 按类别或原始 OSM 标签查找某位置周围的兴趣点,按距离排序(Overpass) |
| 单个元素的完整 OSM 记录:营业时间、网站、电话…… |
| 为 2–8 人寻找公平的会面地点(平衡旅行时间) |
| 大圆距离,离线计算 |
| openstreetmap.org 标记/方向链接,离线计算 |
每个地点输入都接受名称/地址(自动进行地理编码)或文字坐标 "lat,lon"。
使用策略与署名
本服务器与共享的社区基础设施通信。它在客户端强制执行已发布的限制,但运营方要求用户保持整体使用量较低且非商业用途:
数据: © OpenStreetMap 贡献者,根据 ODbL 1.0 许可。
Nominatim: 每秒最多 1 个请求,必须使用可识别的 User-Agent,结果已缓存(策略)。
OSRM / Valhalla (FOSSGIS): 合理的非商业用途;每秒最多 1 个请求(关于)。
Overpass: 每个 IP 约 2 个并发槽位,每天少于 10,000 次查询(维基)。
Photon: 合理使用(photon.komoot.io)。
对于大量或商业用途,请自行托管服务,并将 *_BASE_URL 变量指向您的实例。
安全性
所有工具均为只读;服务器从不向 OpenStreetMap 写入数据。
无需凭据;可选的
ORS_API_KEY在加载后会从进程环境中移除,并在错误消息中被屏蔽。OSM 来源的内容(名称、地址、标签)在工具结果中被标记为不可信数据,以便模型将其视为数据而非指令。
上游错误正文会被截断,HTML 错误页面在到达模型上下文之前会被丢弃。
从不跟随重定向;所有请求都有超时。
开发
npm install
npm run lint # eslint + prettier
npm test # unit tests (all upstream APIs mocked)
npm run test:coverage
npm run build
npm run smoke # opt-in LIVE test against the real public services发布
基于标签驱动,无需手动发布步骤:
将
[Unreleased]条目移至CHANGELOG.md中新的## [x.y.z] - YYYY-MM-DD部分,并更新package.json版本号。运行
npm run lint && npm run build && npm run test:coverage。提交,然后创建一个带签名的注释标签:
git tag -s vx.y.z -m "vx.y.z"。运行
git push origin main vx.y.z。
然后 release.yml 会运行测试,通过 Trusted Publishing(不涉及令牌密钥)将包发布到 npm 并附带来源信息,从 CHANGELOG 部分创建 GitHub 发布,并以 io.github.ni-c/osm-mcp 的名称发布到 MCP 注册表。ci.yml 会在同一标签上将多架构镜像推送到 GHCR。
如果注册表步骤失败,请在 main 分支上修复问题并触发 Publish to MCP Registry 工作流——不要重新运行标签作业,因为那样会检出旧的代码树。
许可证
Available Tools
11 toolsfind_nearby_poisFind nearby places (POIs)ARead-onlyIdempotent
Finds points of interest near a location, sorted by distance. Category shortcuts: restaurant, cafe, bar, pub, fast_food, ice_cream, hotel, hostel, guest_house, apartment, camp_site, attraction, museum, gallery, viewpoint, information, artwork, castle, monument, ruins, supermarket, bakery, convenience, pharmacy, hospital, doctors, police, atm, bank, fuel, charging_station, parking, toilets, drinking_water, bus_stop, train_station, tram_stop, ferry_terminal, bicycle_rental, car_rental, playground, park, beach, swimming_pool. Any other OSM tag works as "key" or "key=value" (e.g. "diet:vegan=yes"). Use poi_details for the full record of one result.
Inputs: near (required), category (required), limit, language, +1 more. Returns: near, note, count, source, +3 more
geocodeGeocode a place or addressARead-onlyIdempotent
Converts a place name or address into coordinates using OpenStreetMap. Returns matching places with lat/lon, a display label and the OSM id. Provider "nominatim" (default) is best for addresses; "photon" is typo-tolerant and better for fuzzy place names.
Inputs: query (required), limit, language, provider, +1 more. Returns: note, source, results, provider, +1 more
isochroneReachable area (isochrone)ARead-onlyIdempotent
Shows how far you can get from a place within a time or distance budget ("what is reachable in 15 minutes on foot?"). Returns a compact summary of the reachable area: bounding box and reach per compass direction. Give exactly one of minutes or kilometers.
Inputs: center (required), profile (required), minutes, language, +1 more. Returns: reach, budget, center, engine, +4 more
map_linkGenerate map linksARead-onlyIdempotent
Generates openstreetmap.org links to open in a browser: a marker link for a single place, or a directions link when from and to are given. Provide either "place", or both "from" and "to".
Inputs: to, from, place, profile, +1 more. Returns: to, from, place, marker, +4 more
optimize_routeOptimize stop orderARead-onlyIdempotent
Finds the best order to visit a set of stops (traveling-salesman optimization) and returns the optimized itinerary with total distance and time. With roundtrip (default) the tour returns to the first stop; without it the first stop is the start and the last stop the end.
Inputs: stops (required), profile (required), language, roundtrip. Returns: legs, engine, source, profile, +4 more
poi_detailsGet POI detailsARead-onlyIdempotent
Fetches the full OpenStreetMap record of one element — all tags (opening hours, website, phone, …), coordinates and a map link. Takes an OSM id as returned by find_nearby_pois or geocode, e.g. "node/240109189".
Inputs: osm_id (required). Returns: lat, lon, map, osm, +4 more
reverse_geocodeReverse geocode coordinatesARead-onlyIdempotent
Converts coordinates into the nearest address or place name (Nominatim).
Inputs: latitude (required), longitude (required), language. Returns: note, result, source, untrusted
routeRoute between placesARead-onlyIdempotent
Calculates the real-world travel distance and time between two or more places, walking, driving or cycling, on OpenStreetMap data. Waypoints are visited in the given order. Set include_steps for a turn-by-turn summary. Use route_matrix to compare many pairs, optimize_route to reorder stops.
Inputs: profile (required), waypoints (required), language, include_steps. Returns: legs, steps, engine, source, +8 more
route_matrixTravel time/distance matrixARead-onlyIdempotent
Computes travel times and distances from every origin to every destination in one call — ideal for comparing options (e.g. 5 hotels against 3 sights). Cells are null where no route exists.
Inputs: origins (required), profile (required), destinations (required), language. Returns: engine, source, origins, profile, +4 more
straight_line_distanceStraight-line distanceARead-onlyIdempotent
Great-circle ("as the crow flies") distance between two places. Instant and independent of any road network — use route for real travel distances.
Inputs: to (required), from (required), language. Returns: to, from, source, distance, +2 more
suggest_meeting_pointSuggest a meeting pointARead-onlyIdempotent
Suggests a fair place to meet for people starting from different locations: finds venues around the geographic midpoint and picks the one with the most balanced travel times for everyone.
Inputs: locations (required), profile, language, venue_category, +1 more. Returns: note, source, profile, midpoint, +4 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool has a clearly distinct purpose: geocode/reverse_geocode handle place-coordinate conversion, route/route_matrix/optimize_route are tightly differentiated by use case, and find_nearby_pois/poi_details form a clear list-to-detail flow. The routing tools could feel similar at first glance, but their descriptions explicitly disambiguate single ordered routes, many-to-many matrices, and stop reordering.
Most multi-word names use a predictable snake_case style: reverse_geocode, route_matrix, find_nearby_pois, straight_line_distance. The set does mix verb-led names like find_nearby_pois and optimize_route with noun-led names like isochrone, poi_details, and map_link, but the overall pattern is still clear and readable.
With 11 tools, the server is well within the ideal range and each tool earns its place by covering a distinct geospatial capability. None of the tools feel redundant, and the count is appropriate for a domain spanning geocoding, routing, POI search, and map links.
The tool set covers the full common workflow for an OSM-based location server: forward and reverse geocoding, routes, matrices, route optimization, isochrones, POI discovery and details, meeting-point suggestions, straight-line distance, and shareable map links. Results from earlier tools feed naturally into later tools, such as POI ids into poi_details and places into route or map_link, leaving no obvious dead ends.
Maintenance
Related MCP Connectors
Geocoding, routing, isochrones, traffic, weather, and place search for AI agents. 19 MCP tools.
Maps, geocoding and time zones for AI coding agents, on OpenStreetMap, with hard prepaid spend caps.
Hosted MCP for live place search, geocoding & turn-by-turn routes. No Maps API key to manage.
Geocoding, static maps and privacy-safe area maps from OpenStreetMap data. Hard caps, no overage.
Related MCP Servers
- AlicenseBqualityDmaintenanceA comprehensive MCP server providing 30 tools for geocoding, routing, and OpenStreetMap data analysis. It enables AI assistants to search for locations, calculate travel routes, and perform quality assurance checks on map data.306MIT
- AlicenseNot gradedqualityCmaintenanceFree geospatial MCP server for AI agents, providing geocoding, reverse geocoding, POI search, and route planning using OpenStreetMap data via Nominatim, Overpass, and OSRM.GPL 3.0
- FlicenseNot gradedqualityBmaintenanceAn MCP server providing geocoding, routing, isochrones, and POI-by-proximity search through self-hosted OpenStreetMap backends.-
- AlicenseNot gradedqualityCmaintenanceMCP server for geocoding, reverse geocoding, place/POI search, and distance calculation using OpenStreetMap Nominatim, with no API key required.89 npm1MIT