Skip to main content
Glama

OpenStreetMap MCP Server

OpenStreetMap(OSM)MCP服务器

OpenStreetMap MCP 服务器实现,通过基于位置的服务和地理空间数据增强 LLM 功能。

演示

会合点优化

会议点用例

邻域分析

邻域分析用例

停车位搜索

停车搜索用例

特征

该服务器为 LLM 提供与 OpenStreetMap 数据交互的工具,使基于位置的应用程序能够:

  • 将地址和地名地理编码为坐标
  • 将地理编码坐标反向转换为地址
  • 查找附近的兴趣点
  • 获取位置之间的路线指引
  • 在边界框内按类别搜索地点
  • 为多人推荐最佳会面地点
  • 探索区域并获取全面的位置信息
  • 查找某个地点附近的学校和教育机构
  • 分析家和工作地点之间的通勤选择
  • 定位带有连接器和电源滤波的电动汽车充电站
  • 执行房地产社区宜居性分析
  • 查找停车设施的可用性和费用信息

成分

资源

服务器实现基于位置的资源:

  • location://place/{query} :按名称或地址获取地点信息
  • location://map/{style}/{z}/{x}/{y} :获取指定坐标处的样式地图图块

工具

该服务器实现了几个地理空间工具:

  • geocode_address :将文本转换为地理坐标
  • reverse_geocode :将坐标转换为人类可读的地址
  • find_nearby_places :发现某个地点附近的兴趣点
  • get_route_directions :获取位置之间的逐向导航
  • search_category :查找某个区域内特定类别的地点
  • suggest_meeting_point :为多人寻找最佳会面地点
  • explore_area :获取有关社区的综合数据
  • find_schools_nearby :查找特定位置附近的教育机构
  • analyze_commute :比较家和工作地点之间的交通选择
  • find_ev_charging_stations :通过筛选定位电动汽车充电基础设施
  • analyze_neighborhood :评估房地产社区的宜居性
  • find_parking_facilities :查找目的地附近的停车选项

用例

房地产决策

法学硕士可以帮助用户评估潜在的购房社区:

本地测试

运行服务器

要在本地运行服务器:

  1. 以开发模式安装包:
pip install -e .
  1. 启动服务器:
osm-mcp-server
  1. 服务器将启动并监听标准输入/输出上的 MCP 请求。

使用示例客户端进行测试

该存储库在examples/目录中包含两个示例客户端:

基本客户端示例

client.py演示了 OSM MCP 服务器的基本用法:

python examples/client.py

这将:

  • 连接到本地运行的服务器
  • 获取有关旧金山的信息
  • 搜索该地区的餐馆
  • 通过进度跟踪检索综合地图数据
LLM 集成示例

llm_client.py提供了一个���为 LLM 集成设计的帮助类:

python examples/llm_client.py

此示例展示了法学硕士 (LLM) 如何使用位置助手来执行以下操作:

  • 从文本查询中获取位置信息
  • 查找附近的兴趣点
  • 获取地点之间的路线
  • 寻找最佳会面地点
  • 探索社区

编写自己的客户端

要创建您自己的客户端:

  1. 导入MCP客户端:
from mcp.client import Client
  1. 使用您的服务器 URL 初始化客户端:
client = Client("http://localhost:8000")
  1. 调用工具或访问资源:
# Example: Geocode an address results = await client.invoke_tool("geocode_address", {"address": "New York City"})

配置

安装

克劳德桌面

在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json

"mcpServers": { "osm-mcp-server": { "command": "uv", "args": [ "--directory", "/path/to/osm-mcp-server", "run", "osm-mcp-server" ] } }
"mcpServers": { "osm-mcp-server": { "command": "uvx", "args": [ "osm-mcp-server" ] } }

发展

构建和发布

准备分发包:

  1. 同步依赖项并更新锁文件:
uv sync
  1. 构建软件包分发版:
uv build

这将在dist/目录中创建源和轮子分布。

  1. 发布到 PyPI:
uv publish

注意:您需要通过环境变量或命令标志设置 PyPI 凭据。

调试

由于 MCP 服务器通过 stdio 运行,调试起来可能比较困难。为了获得最佳调试体验,我们强烈建议使用MCP Inspector

您可以使用以下命令通过npm启动 MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /path/to/osm-mcp-server run osm-mcp-server

启动后,检查器将显示一个 URL,您可以在浏览器中访问该 URL 以开始调试。

API 使用示例

以下是如何使用 Python 代码中的关键 API 端点的简单示例:

import asyncio from mcp.client import Client async def main(): client = Client("http://localhost:8000") # Geocode an address results = await client.invoke_tool("geocode_address", {"address": "Empire State Building"}) print(f"Found location: {results[0]['display_name']}") # Get coordinates lat = float(results[0]['lat']) lon = float(results[0]['lon']) # Find nearby coffee shops nearby = await client.invoke_tool( "find_nearby_places", { "latitude": lat, "longitude": lon, "radius": 500, "categories": ["amenity"], "limit": 5 } ) # Print results print(f"Found {nearby['total_count']} nearby places") for category, subcategories in nearby["categories"].items(): for subcategory, places in subcategories.items(): print(f" - {subcategory}: {len(places)} places") if __name__ == "__main__": asyncio.run(main())
Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

通过基于位置的服务和地理空间数据增强 LLM 功能,使用户能够对地址进行地理编码、查找附近的景点、获取路线、优化会议地点并分析社区。

  1. 演示
    1. 会合点优化
    2. 邻域分析
    3. 停车位搜索
  2. 特征
    1. 成分
      1. 资源
      2. 工具
    2. 用例
      1. 房地产决策
    3. 本地测试
      1. 运行服务器
      2. 使用示例客户端进行测试
      3. 编写自己的客户端
    4. 配置
      1. 安装
    5. 发展
      1. 构建和发布
      2. 调试
    6. API 使用示例

      Related MCP Servers

      • A
        security
        A
        license
        A
        quality
        Enables LLMs to perform travel-related tasks by interacting with Google Maps and travel planning services including location search, place details, and travel time calculations.
        Last updated -
        5
        36
        21
        JavaScript
        MIT License
      • A
        security
        A
        license
        A
        quality
        A Model Context Protocol server that provides Google Maps API integration, allowing users to search locations, get place details, geocode addresses, calculate distances, obtain directions, and retrieve elevation data through LLM processing capabilities.
        Last updated -
        7
        163
        25
        TypeScript
        MIT License
      • -
        security
        -
        license
        -
        quality
        Enables large language models to access user geolocation information through EdgeOne Pages Functions using the Model Context Protocol.
        Last updated -
        TypeScript
        MIT License
      • A
        security
        A
        license
        A
        quality
        An MCP server that gives LLMs access to geographic data conversion tools, enabling transformations between different formats like WKT, GeoJSON, CSV, TopoJSON, and KML, as well as performing reverse geocoding.
        Last updated -
        9
        23
        2
        JavaScript
        MIT License
        • Apple
        • Linux

      View all related MCP servers

      MCP directory API

      We provide all the information about MCP servers via our MCP API.

      curl -X GET 'https://glama.ai/api/mcp/v1/servers/jagan-shanmugam/open-streetmap-mcp'

      If you have feedback or need assistance with the MCP directory API, please join our Discord server