Skip to main content

MCP Server for geospatial operations - geocoding, routing, spatial analysis

Project description

GIS MCP Server

A Model Context Protocol (MCP) server providing geospatial tools for AI agents. Enables Claude, GPT, and other LLMs to perform geocoding, routing, spatial analysis, and file operations.

Features

  • Geocoding: Convert addresses to coordinates and vice versa (via Nominatim/OSM)
  • Routing: Calculate routes between points with distance, duration, and geometry (via OSRM)
  • Spatial Analysis: Buffer, intersection, union, distance calculations
  • File I/O: Read/write Shapefiles, GeoJSON, GeoPackage
  • CRS Transformation: Convert between coordinate reference systems

Installation

# From PyPI (when published)
pip install gis-mcp-server

# From source
git clone https://github.com/your-org/gis-mcp-server.git
cd gis-mcp-server
pip install -e .

Quick Start

With Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "gis": {
      "command": "uvx",
      "args": ["gis-mcp-server"]
    }
  }
}

Direct Usage

# Run the server
gis-mcp-server

Available Tools

Geocoding

geocode

Convert an address to coordinates.

Input: "1600 Pennsylvania Avenue, Washington DC"
Output: {lat: 38.8977, lon: -77.0365, display_name: "White House..."}

reverse_geocode

Convert coordinates to an address.

Input: lat=48.8566, lon=2.3522
Output: {display_name: "Paris, Île-de-France, France", ...}

Geometry

distance

Calculate distance between two points.

Input: lat1=48.8566, lon1=2.3522, lat2=51.5074, lon2=-0.1278
Output: {distance: {meters: 343556, kilometers: 343.56, miles: 213.47}}

buffer

Create a buffer zone around a geometry.

Input: geometry={type: "Point", coordinates: [2.3522, 48.8566]}, distance_meters=1000
Output: {geometry: {type: "Polygon", ...}, area_km2: 3.14}

spatial_query

Perform spatial operations (intersection, union, contains, within, etc.).

Input: geometry1={...}, geometry2={...}, operation="intersection"
Output: {geometry: {...}}

transform_crs

Transform coordinates between CRS.

Input: geometry={...}, source_crs="EPSG:4326", target_crs="EPSG:3857"
Output: {geometry: {...}}

Routing

route

Calculate route between two points.

Input: start_lat=48.8566, start_lon=2.3522, end_lat=48.8606, end_lon=2.3376
Output: {distance: {...}, duration: {...}, geometry: {...}, steps: [...]}

isochrone

Calculate area reachable within a time limit.

Input: lat=48.8566, lon=2.3522, time_minutes=15, profile="driving"
Output: {geometry: {type: "Polygon", ...}}

Files

read_file

Read geospatial files (Shapefile, GeoJSON, GeoPackage).

Input: file_path="data/cities.shp"
Output: {type: "FeatureCollection", features: [...]}

write_file

Write features to geospatial files.

Input: features={...}, file_path="output.geojson", driver="GeoJSON"
Output: {file_path: "...", feature_count: 10}

Configuration

Environment variables:

Variable Default Description
NOMINATIM_URL https://nominatim.openstreetmap.org Nominatim API URL
NOMINATIM_USER_AGENT gis-mcp-server/0.1.0 User agent for Nominatim
OSRM_URL https://router.project-osrm.org OSRM API URL
OSRM_PROFILE driving Default routing profile
GIS_DEFAULT_CRS EPSG:4326 Default CRS
GIS_TEMP_DIR /tmp/gis-mcp Temporary directory

Response Format

All tools return a consistent JSON structure:

{
  "success": true,
  "data": { ... },
  "metadata": {
    "source": "nominatim",
    "confidence": 0.95
  },
  "error": null
}

Rate Limits

  • Nominatim: 1 request/second (enforced automatically)
  • OSRM Demo: Best effort, consider self-hosting for production

Development

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

# Run tests
pytest

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

# Type checking
mypy src/gis_mcp

# Linting
ruff check src/gis_mcp

Architecture

src/gis_mcp/
├── server.py      # MCP server entry point
├── config.py      # Configuration management
├── utils.py       # Common utilities
└── tools/
    ├── geocoding.py   # geocode, reverse_geocode
    ├── routing.py     # route, isochrone
    ├── geometry.py    # buffer, distance, spatial_query, transform_crs
    └── files.py       # read_file, write_file

License

MIT License - see LICENSE for details.

Contributing

Contributions welcome! Please read the contributing guidelines before submitting PRs.

Roadmap

  • Pelias geocoding support (higher accuracy)
  • Valhalla routing integration (native isochrones)
  • PostGIS spatial queries
  • Elevation/terrain data
  • Real-time traffic data
  • Batch geocoding
  • ESRI FileGDB full support

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

gis_mcp_server-0.1.0.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

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

gis_mcp_server-0.1.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gis_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for gis_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b6f9172933a9581eb72e00c05d9391d73fa1c97162f590a1abb80cb0010d5db4
MD5 82abd05e7ce9676043118f35af79ad40
BLAKE2b-256 0cd598ac9d1b634c28d297235d2e7f4ac246809b383872885d06e8909d5a3ebd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gis_mcp_server-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for gis_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5106bfa124802fb65b9211c0569b5c61e86b6e8497cc2a556c9a4af2cbaa08bb
MD5 c9e2df36654d46dc1417df461b74a6af
BLAKE2b-256 9516b7ac5f75a8561d3bca9ae2552cf7f43900371bd3c80c49f14a7e11625032

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