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
- Cursor Integration - How to integrate with Cursor
- VSCode Integration - VSCode integration tests and setup
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 locationlimit(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
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
make test - Run linting:
make lint - 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
-
Copy Files: Copy each file section above into files with the respective names
-
Install Dependencies:
pip install -r requirements.txt
-
Run the Server:
python geocoding_server.py -
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df4f55bcc86be010ea91e8c938d1e0a6626f3e2635009d31dd1297609c8ceb24
|
|
| MD5 |
2c41c6aa1ec3b4c3d92967bd56daf537
|
|
| BLAKE2b-256 |
c32809fbdee01024e2301d106d907dffbd1a17edeb8f35bc3babcb774092e0f2
|
File details
Details for the file geocode_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: geocode_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61f37f23bf5cf686a69bd8129422fdb171f196cd871a35edb9a12fca50af45e4
|
|
| MD5 |
41772b1d5e769c55c772f0b1489a8e10
|
|
| BLAKE2b-256 |
44e0bfd47475cacb436af1dbc6dcab02b6b3b5c77c56d45cb390ffc5da643827
|