Skip to main content

MCP server for producing latitude/longitude coordinates for cities and areas using OpenStreetMap Nominatim API

Project description

Geocode MCP Server

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

Features

  • ๐ŸŒ Geocoding: Get coordinates for any location worldwide
  • ๐Ÿ†“ Free API: Uses OpenStreetMap Nominatim (no API key required)
  • ๐Ÿ› ๏ธ MCP Integration: Works with Cursor, VSCode, and other MCP-compatible editors
  • ๐Ÿงช Comprehensive Testing: Full test suite with unit and integration tests
  • ๐Ÿ“ฆ Modern Tooling: Ruff for linting, ty for type checking, pytest for testing

Quick Start

Installation

# Clone the repository
git clone <repository-url>
cd geocode-mcp

# Install dependencies
make install-dev

Running the Server

# Run the MCP server
python scripts/run_mcp_server.py

# Or make it executable and run directly
chmod +x scripts/run_mcp_server.py
./scripts/run_mcp_server.py

Testing

# Run all tests
make test

# Run with coverage
make test-cov

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

Integration Guides

Project Structure

geocode-mcp/
โ”œโ”€โ”€ src/geocode/           # Main source code
โ”‚   โ””โ”€โ”€ mcp_server.py     # MCP server implementation
โ”œโ”€โ”€ tests/                 # All test files
โ”‚   โ”œโ”€โ”€ test_geocoding.py # Unit tests for geocoding
โ”‚   โ”œโ”€โ”€ test_mcp.py       # Unit tests for MCP server
โ”‚   โ”œโ”€โ”€ test_mcp_server.py # Integration tests
โ”‚   โ””โ”€โ”€ test_vscode.py    # VSCode integration tests
โ”œโ”€โ”€ scripts/              # Executable scripts
โ”‚   โ””โ”€โ”€ run_mcp_server.py # MCP server runner
โ”œโ”€โ”€ config/               # Configuration files
โ”‚   โ””โ”€โ”€ cursor-mcp.json   # Cursor MCP configuration
โ”œโ”€โ”€ docs/                 # Documentation
โ”‚   โ””โ”€โ”€ cursor-integration.md
โ”œโ”€โ”€ Makefile              # Development commands
โ”œโ”€โ”€ pyproject.toml        # Project configuration
โ””โ”€โ”€ README.md            # This file

Available Tools

get_coordinates

Get latitude and longitude coordinates for a city or location.

Parameters:

  • location (required): City name, address, or location
  • limit (optional): Maximum number of results (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?

Development

Code Quality

# Lint code
make lint

# Format code
make format

# Type check
make type-check

# Run all checks
make check-all

Testing

# Run all tests
make test

# Run with coverage
make test-cov

# Run specific test categories
pytest tests/test_geocoding.py -v  # Geocoding tests
pytest tests/test_mcp.py -v        # MCP server tests
python tests/test_mcp_server.py    # Integration tests
python tests/test_vscode.py        # VSCode tests

Installation

# Install production dependencies
make install

# Install development dependencies
make install-dev

Configuration

Cursor Integration

See Cursor Integration Guide for detailed setup instructions.

VSCode Integration

Run the VSCode integration tests:

python tests/test_vscode.py

API Reference

Geocoding Function

async def geocode_location(location: str, limit: int = 1) -> dict[str, Any]:
    """Geocode a location using Nominatim API."""

MCP Server

The server provides the get_coordinates tool that can be called via the MCP protocol.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests: make test
  5. Run linting: make lint
  6. Submit a pull request

See CONTRIBUTING.md for more details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • OpenStreetMap for providing the Nominatim geocoding service
  • MCP for the protocol specification

---

## ๐Ÿš€ Quick Setup Instructions

1. **Create Project Folder:**
   ```bash
   mkdir mcp-geocoding-server-python
   cd mcp-geocoding-server-python
  1. Copy Files: Copy each file section above into files with the respective names

  2. Install Dependencies:

    pip install -r requirements.txt
    
  3. Run the Server:

    python geocoding_server.py
    
  4. Configure MCP Client: Add to your MCP client (like Claude Desktop) configuration:

    {
      "mcpServers": {
        "geocoding": {
          "command": "python",
          "args": ["/full/path/to/mcp-geocoding-server-python/geocoding_server.py"]
        }
      }
    }
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geocode_mcp-0.1.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geocode_mcp-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file geocode_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: geocode_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for geocode_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 df4f55bcc86be010ea91e8c938d1e0a6626f3e2635009d31dd1297609c8ceb24
MD5 2c41c6aa1ec3b4c3d92967bd56daf537
BLAKE2b-256 c32809fbdee01024e2301d106d907dffbd1a17edeb8f35bc3babcb774092e0f2

See more details on using hashes here.

File details

Details for the file geocode_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for geocode_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61f37f23bf5cf686a69bd8129422fdb171f196cd871a35edb9a12fca50af45e4
MD5 41772b1d5e769c55c772f0b1489a8e10
BLAKE2b-256 44e0bfd47475cacb436af1dbc6dcab02b6b3b5c77c56d45cb390ffc5da643827

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page