OpenStreetMap MCP Serverのロゴ

OpenStreetMap MCP Server

組織
NERVsystems

OpenStreetMap MCP server providing precision geospatial tools for LLMs via Model Context Protocol. Features geocoding, routing, nearby places, neighborhood analysis, EV charging stations, and more.

公開者NERVsystems
リポジトリosmmcp
言語Go
フォーク
4
スター
29
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    OpenStreetMap MCP Serverは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには29件のスターと4件のフォークがあります。

OpenStreetMap MCP Server

Go Go Report Card

Overview

This is a Go OpenStreetMap MCP server. It implements the Model Context Protocol to enable LLMs to interact with geospatial data.

Our focus is on precision, performance, maintainability, and ease of integration with MCP desktop clients.

Features

The server provides LLMs with tools to interact with OpenStreetMap data, including:

  • Geocoding addresses and place names to coordinates
  • Reverse geocoding coordinates to addresses
  • Finding nearby points of interest
  • Calculating routes and getting directions between locations
  • Searching for places by category within a bounding box
  • Suggesting optimal meeting points for multiple people
  • Exploring areas and getting comprehensive location information
  • Finding EV charging stations near a location
  • Finding EV charging stations along a route
  • Analyzing commute options between home and work
  • Performing neighborhood livability analysis
  • Finding schools near a location
  • Finding parking facilities

Implemented Tools

Tool NameDescriptionExample Parameters
bbox_from_pointsCreate a bounding box that encompasses all given geographic coordinates{"points": [{"latitude": 37.7749, "longitude": -122.4194}, {"latitude": 37.8043, "longitude": -122.2711}]}
centroid_pointsCalculate the geographic centroid (mean center) of a set of coordinates{"points": [{"latitude": 37.7749, "longitude": -122.4194}, {"latitude": 37.8043, "longitude": -122.2711}]}
enrich_emissionsEnrich route options with CO2 emissions, calorie burn, and cost estimates{"options": [{"mode": "car", "distance": 5000}, {"mode": "bike", "distance": 4500}]}
filter_tagsFilter OSM elements by specified tags{"elements": [...], "tags": {"amenity": ["restaurant", "cafe"]}}
geocode_addressConvert an address or place name to geographic coordinates{"address": "1600 Pennsylvania Ave, Washington DC"}
geo_distanceCalculate the distance between two geographic coordinates{"from": {"latitude": 37.7749, "longitude": -122.4194}, "to": {"latitude": 37.8043, "longitude": -122.2711}}
get_map_imageRetrieve and display an OpenStreetMap image for analysis{"latitude": 37.7749, "longitude": -122.4194, "zoom": 14}
osm_query_bboxQuery OpenStreetMap data within a bounding box with tag filters{"bbox": {"minLat": 37.77, "minLon": -122.42, "maxLat": 37.78, "maxLon": -122.41}, "tags": {"amenity": "restaurant"}}
polyline_decodeDecode an encoded polyline string into a series of geographic coordinates{"polyline": "a~l~FfynpOnlB_pDhgEhjD"}
polyline_encodeEncode a series of geographic coordinates into a polyline string{"points": [{"latitude": 37.7749, "longitude": -122.4194}, {"latitude": 37.8043, "longitude": -122.2711}]}
reverse_geocodeConvert geographic coordinates to a human-readable address{"latitude": 38.8977, "longitude": -77.0365}
route_fetchFetch a route between two points using OSRM routing service{"start": {"latitude": 37.7749, "longitude": -122.4194}, "end": {"latitude": 37.8043, "longitude": -122.2711}, "mode": "car"}
route_sampleSample points along a route at specified intervals{"polyline": "a~l~FfynpOnlB_pDhgEhjD", "interval": 100}
sort_by_distanceSort OSM elements by distance from a reference point{"elements": [...], "ref": {"latitude": 37.7749, "longitude": -122.4194}}
find_nearby_placesFind points of interest near a specific location{"latitude": 37.7749, "longitude": -122.4194, "radius": 1000, "category": "restaurant", "limit": 5}
get_route_directionsGet detailed turn-by-turn directions for a route between locations{"start_lat": 37.7749, "start_lon": -122.4194, "end_lat": 37.8043, "end_lon": -122.2711, "mode": "car"}
suggest_meeting_pointSuggest an optimal meeting point for multiple people{"locations": [{"latitude": 37.7749, "longitude": -122.4194}, {"latitude": 37.8043, "longitude": -122.2711}], "category": "cafe", "limit": 3}
explore_areaExplore an area and get comprehensive information about it{"latitude": 37.7749, "longitude": -122.4194, "radius": 1000}
find_charging_stationsFind electric vehicle charging stations near a location{"latitude": 37.7749, "longitude": -122.4194, "radius": 5000, "limit": 10}
analyze_commuteAnalyze transportation options between home and work locations{"home_latitude": 37.7749, "home_longitude": -122.4194, "work_latitude": 37.8043, "work_longitude": -122.2711, "transport_modes": ["car", "cycling", "walking"]}
analyze_neighborhoodEvaluate neighborhood livability for real estate and relocation decisions{"latitude": 37.7749, "longitude": -122.4194, "radius": 1000, "include_price_data": true}
find_schools_nearbyFind educational institutions near a specific location{"latitude": 37.7749, "longitude": -122.4194, "radius": 2000, "school_type": "elementary", "limit": 5}
find_parking_facilitiesFind parking facilities near a specific location{"latitude": 37.7749, "longitude": -122.4194, "radius": 1000, "type": "surface", "include_private": false, "limit": 5}

New Geographic and Routing Tools

The v0.1.1 release includes enhanced geographic and routing capabilities:

Geographic Tools

  • Bounding Box Generation: Create geographic bounding boxes that encompass multiple points.
  • Centroid Calculation: Find the mean center of a set of geographic coordinates.
  • Distance Calculation: Calculate precise distances between geographic points using the Haversine formula.
  • OSM Element Filtering: Filter and sort OpenStreetMap elements by tags and distance.

Polyline Tools

  • Polyline Encoding/Decoding: Convert between geographic coordinates and Google's Polyline5 format.
  • Route Sampling: Sample points along routes at specific intervals for detailed analysis.

Route Tools

  • Route Fetching: Obtain routes between points using the OSRM routing service.
  • Emissions Enrichment: Enhance route options with estimated CO2 emissions, calorie burn, and cost data.

These tools provide LLMs with foundational geographic capabilities for building complex location-based applications.

Composable Tool Design

Many of our MCP tools are designed as composable primitives, enabling novel workflows that might not have been foreseen during development. Composite tools exist to efficiently perform common complex operations.

Composition Principles

  • Uniform Interfaces: All tools use consistent parameter naming (e.g., minLat, maxLon) and data structures
  • Single Responsibility: Each tool does one thing and does it well
  • Output/Input Compatibility: The output of one tool can be directly used as input to another
  • Functional Independence: Tools operate without side effects or hidden dependencies
  • Precise Error Messages: When issues occur, detailed feedback indicates exactly what went wrong

Example Workflows

  1. Find Points of Interest Along a Path:

    bbox_from_points → osm_query_bbox → filter_tags → sort_by_distance
  2. Find Optimal Meeting Points:

    centroid_points → find_nearby_places → filter_tags
  3. Analyze Route Characteristics:

    route_fetch → polyline_decode → route_sample → filter_tags

This compositional approach empowers LLMs to create emergent capabilities beyond what any individual tool provides. For example, an LLM can easily create queries like "show the five closest wheelchair-accessible cafés that are open past 22:00 along my route" by combining the appropriate primitive tools, without requiring custom server-side endpoints.

Visual Mapping Capabilities

The MCP server provides visual mapping capabilities through one tool:

  1. get_map_image - Returns map images in SVG format for improved visualization and analysis

Map Images for Analysis

The get_map_image tool provides mapping capabilities that deliver both visual map representation and detailed metadata. This approach offers several advantages:

  • Visual Display: Returns the actual map tile image that displays inline in the conversation
  • Direct Visualization: Enables Claude to visually analyze the map features and geography
  • Comprehensive Metadata: Includes precise coordinates, bounds, and scale information
  • Rich Context: Provides a text description with a direct link to OpenStreetMap for further exploration

The tool returns both the map tile image and a structured text description containing the location coordinates, a direct link to view the map online, and detailed metadata about the map area, making it ideal for both visual analysis and comprehensive location understanding.

Example Usage

To retrieve a map image of San Francisco at zoom level 14:

json
{
  "name": "get_map_image",
  "arguments": {
    "latitude": 37.7749,
    "longitude": -122.4194,
    "zoom": 14
  }
}

The response from the tool includes:

  • Visual map tile image displayed inline in the conversation
  • Text description of the location with a direct OpenStreetMap link
  • Precise coordinate information for the map
  • Geographic bounds of the visible area
  • Scale information (meters per pixel)

Improved Geocoding Tools

The geocoding tools have been enhanced to provide more reliable results and better error handling:

Key Improvements

  • Smart Address Preprocessing: Automatically sanitizes inputs to improve success rates
  • Detailed Error Reporting: Returns structured error responses with error codes and helpful suggestions
  • Better Diagnostics: Provides detailed logging to track geocoding issues
  • Improved Formatting Guide: Documentation with specific examples of what works well

Best Practices for Geocoding

For optimal results when using the geocoding tools:

  1. Simplify complex queries:

    • Bad: "Golden Temple (Harmandir Sahib) in Amritsar"
    • Good: "Golden Temple Amritsar India"
  2. Add geographic context:

    • Bad: "Eiffel Tower"
    • Good: "Eiffel Tower, Paris, France"
  3. Read error suggestions:

    • Our enhanced error responses include specific suggestions for fixing failed queries

See the Geocoding Tools Guide for comprehensive documentation and AI Prompts for Geocoding for examples of how to guide AI systems in using these tools effectively.

Code Architecture and Design

The code follows software engineering best practices:

  1. High Cohesion, Low Coupling - Each package has a clear, focused responsibility
  2. Separation of Concerns - Tools, server logic, and utilities are cleanly separated
  3. DRY (Don't Repeat Yourself) - Common utilities are extracted into the pkg/osm package
  4. Security First - HTTP clients are properly configured with timeouts and connection limits
  5. UNIX-like Composability - Small, focused tools that can be combined in powerful ways
  6. Structured Logging - All logging is done via slog with consistent levels and formats:
    • Debug: Developer detail, verbose or diagnostic messages
    • Info: Routine operational messages
    • Warn: Unexpected conditions that don't necessarily halt execution
    • Error: Critical problems, potential or actual failures
  7. SOLID Principles - Particularly Single Responsibility and Interface Segregation
  8. Registry Pattern - All tools are defined in a central registry for improved maintainability
  9. Google Polyline5 Format - Standardized polyline encoding/decoding using Google's Polyline5 format
  10. Precise Geospatial Calculations - Accurate Haversine distance calculations with appropriate tolerances
  11. Context-Aware Operations - All operations properly handle context for cancellation and timeouts

Usage

Installation

To install the OpenStreetMap MCP server:

Option 1: Download Pre-built Binaries

The easiest way to get started is to download the latest release from our releases page. Choose the appropriate binary for your operating system and architecture.

Option 2: Build from Source

If you prefer to build from source:


### Requirements

- Go 1.24 or higher
- OpenStreetMap API access (no API key required, but rate limits apply)

### Building the server

```bash
go build -o osmmcp ./cmd/osmmcp

Running the server

bash
./osmmcp

The server supports several command-line flags:

bash
# Show version information
./osmmcp --version
# The version may differ if built with custom -ldflags

# Enable debug logging
./osmmcp --debug

# Generate a Claude Desktop Client configuration file
./osmmcp --generate-config /path/to/config.json

# Customize rate limits (requests per second and burst)
# Defaults: Nominatim=1 rps/burst 1, Overpass=2 per min/burst 2, OSRM=100 per min/burst 5
./osmmcp --nominatim-rps 1.0 --nominatim-burst 1
./osmmcp --overpass-rps 0.033 --overpass-burst 2
./osmmcp --osrm-rps 1.67 --osrm-burst 5

# Set custom User-Agent string
./osmmcp --user-agent "MyApp/1.0"

Logging Configuration

The server uses structured logging via slog with the following configuration:

  • Debug level: Enabled with --debug flag
  • Default level: Info
  • Format: Text-based with key-value pairs
  • Output: Standard error (stderr)

Example log output:

2024-03-14T10:15:30.123Z INFO starting OpenStreetMap MCP server version=0.1.0 log_level=info user_agent=osm-mcp-server/0.1.0
2024-03-14T10:15:30.124Z DEBUG rate limiter initialized service=nominatim rps=1.0 burst=1

The server will start and listen for MCP requests on the standard input/output. You can use it with any MCP-compatible client or LLM integration.

Using with Claude Desktop Client

This MCP server is designed to work with Claude Desktop Client. You can set it up easily with the following steps:

  1. Build the server:

    bash
    go build -o osmmcp ./cmd/osmmcp
  2. Generate or update the Claude Desktop Client configuration:

    bash
    ./osmmcp --generate-config ~/Library/Application\ Support/Anthropic/Claude/config.json

    This will add an OSM entry to the mcpServers configuration in Claude Desktop Client. The configuration system intelligently:

    • Creates the file if it doesn't exist
    • Preserves existing tools when updating the configuration
    • Uses absolute paths to ensure Claude can find the executable
    • Validates JSON output to prevent corruption
  3. Restart Claude Desktop Client to load the updated configuration.

  4. In a conversation with Claude, you can now use the OpenStreetMap MCP tools.

The configuration file will look similar to this:

json
{
  "mcpServers": {
    "OSM": {
      "command": "/path/to/osmmcp",
      "args": []
    },
  }
}

API Dependencies

The server relies on these external APIs:

  • Nominatim - For geocoding operations
  • Overpass API - For OpenStreetMap data queries
  • OSRM - For routing calculations

No API keys are required as these are open public APIs, but the server follows usage policies including proper user agent identification and request rate limiting.

Development

Project Structure

  • cmd/osmmcp - Main application entry point
  • pkg/server - MCP server implementation
  • pkg/tools - OpenStreetMap tool implementations and tool registry (25 tools)
  • pkg/osm - OpenStreetMap API clients, rate limiting, polyline encoding, and utilities
  • pkg/geo - Geographic types, bounding boxes, and Haversine distance calculations
  • pkg/core - Core utilities including HTTP retry logic, validation, error handling, Overpass query builder, and OSRM service client
  • pkg/cache - TTL-based caching layer for API responses (5-minute default)
  • pkg/monitoring - Prometheus metrics, health checking, connection monitoring, and observability
  • pkg/tracing - OpenTelemetry tracing support for distributed tracing and debugging
  • pkg/testutil - Testing utilities and helpers
  • pkg/version - Build metadata and version information

Adding New Tools

To add a new tool:

  1. Implement the tool functions in a new or existing file in pkg/tools
  2. Add the tool definition to the registry in pkg/tools/registry.go

The registry-based design makes it easy to add new tools without modifying multiple files. All tool definitions are centralized in one place, making the codebase more maintainable.

Testing

Run tests with:

bash
go test ./...

The test suite includes:

  • Unit tests for polyline encoding/decoding
  • Server integration tests
  • Geographic calculation tests
  • Logging utility tests

Acknowledgments

This implementation is based on two excellent sources:

Project History

Originally created by @pdfinn.
All core functionality and initial versions developed prior to organisational transfer.

Documentation

License

MIT License

インストール

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "nervsystems-osmmcp": {
      "command": "npx",
      "args": [
        "-y",
        "osmmcp"
      ]
    }
  }
}

OpenStreetMap MCP ServerのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度OpenStreetMap MCP Serverに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

OpenStreetMap MCP Serverをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. OpenStreetMap MCP ServerのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "nervsystems-osmmcp": {
      "command": "npx",
      "args": [
        "-y",
        "osmmcp"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてOpenStreetMap MCP ServerのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. OpenStreetMap MCP ServerのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
OpenStreetMap MCP Serverを使ってこのタスクを手伝ってもらえますか?
OpenStreetMap MCP Server
はい、読みました。
OpenStreetMap MCP Serverで調べた結果をお伝えします。

よくある質問

OpenStreetMap MCP Server MCPサーバーは何に使いますか?

OpenStreetMap MCP Serverは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでOpenStreetMap MCP Server MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでOpenStreetMap MCP Serverを利用できます。

TypingMindでOpenStreetMap MCP Server MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。OpenStreetMap MCP Serverを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

OpenStreetMap MCP Server MCPをTypingMindに接続するにはどうすればよいですか?

OpenStreetMap MCP ServerはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでOpenStreetMap MCP Server MCPのどのようなツールを利用できますか?

OpenStreetMap MCP ServerはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

OpenStreetMap MCP Server MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。OpenStreetMap MCP Serverで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇