XM

x-mckay/geocode-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 4 forks 质量 69 趋势 14MIT

A Basic MCP server to convert locations into Latitude and Longitude Coordinates

概览

A Model Context Protocol (MCP) server that provides latitude/longitude coordinates for cities and locations using the OpenStreetMap Nominatim API. - 🌍 : Get coordinates for any location worldwide - 🆓 : Uses OpenStreetMap Nominatim (no API key required) - � : Works with Cursor, VS Code, Claude Desktop, and other MCP-compatible tools - 📦 : Install via PyPI with uvx geocode-mcp - �️ : Built with Python 3.12+, async/await, and comprehensive testing Install the package from PyPI using uvx (recommended): See the config/ directory for specific examples for different tools. Get latitude and longitude coordinates for a city or location. - location (required): City name, address, or location (e.g., "New York", "Paris, France", "123 Main St, Seattle") - limit (optional): Maximum number of results to return (default: 1, max: 10) Copy the configuration from config/cursor-mcp.json to your Cursor MCP settings. Copy the configuration from config/vscode-mcp.json to your VS Code MCP settings.

README

以下为原文 README 节选,完整内容请查看原文。

Geocode MCP Server

A Model Context Protocol (MCP) server that provides latitude/longitude coordinates for cities and locations using the OpenStreetMap Nominatim API.

Features

  • 🌍 Global Geocoding: Get coordinates for any location worldwide
  • 🆓 Free API: Uses OpenStreetMap Nominatim (no API key required)
  • � MCP Integration: Works with Cursor, VS Code, Claude Desktop, and other MCP-compatible tools
  • 📦 Easy Installation: Install via PyPI with uvx geocode-mcp
  • �️ Modern Tooling: Built with Python 3.12+, async/await, and comprehensive testing

Quick Start

Installation

Install the package from PyPI using uvx (recommended):

uvx geocode-mcp

Or install with pip:

pip install geocode-mcp

MCP Configuration

Add to your MCP client configuration:

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

See the config/ directory for specific examples for different tools.

Available Tools

mcp_geocoding_get_coordinates

Get latitude and longitude coordinates for a city or location.

Parameters:

  • location (required): City name, address, or location (e.g., “New York”, “Paris, France”, “123 Main St, Seattle”)
  • limit (optional): Maximum number of results to return (default: 1, max: 10)

Example Usage:

Get coordinates for Tokyo, Japan
Find the latitude and longitude of London, UK  
What are the coordinates for New York City?
Get coordinates for "1600 Pennsylvania Avenue, Washington DC" with limit 5

Response Format:

{
  "query": "Tokyo, Japan",
  "results_count": 1,
  "coordinates": [
    {
      "latitude": 35.6762,
      "longitude": 139.6503,
      "display_name": "Tokyo, Japan",
      "place_id": "282885117",
      "type": "city",
      "class": "place",
      "importance": 0.9,
      "bounding_box": {
        "south": 35.619,
        "north": 35.739,
        "west": 139.619,
        "east": 139.682
      }
    }
  ]
}

Integration Guides

Cursor

Copy the configuration from config/cursor-mcp.json to your Cursor MCP settings.

VS Code

Copy the configuration from config/vscode-mcp.json to your VS Code MCP settings.

Claude Desktop

Copy the configuration from config/claude-desktop.json to your Claude Desktop config file.

See the config README for detailed setup instructions.

Development

Setup

# Clone the repository
git clone https://github.com/X-McKay/geocode-mcp.git
cd geocode-mcp

# Install with development dependencies
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=src/geocode_mcp --cov-report=html

# Run specific test files
pytest tests/test_geocoding.py -v
pytest tests/test_mcp_server.py -v

Code Quality

# Format code
ruff format

# Lint code
在 GitHub 查看完整 README

安装

uvx geocode-mcp
新手?先看 mcpskill.org 教程 →

配置

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