home / mcp / postgis mcp server
Provides 32 PostGIS tools for spatial queries, geometry operations, analyses, and database management via MCP.
Configuration
View docs{
"mcpServers": {
"zmgiser-postgis_yukon_mcp": {
"command": "python",
"args": [
"-m",
"src.server"
]
}
}
}You install and run a PostGIS MCP Server that exposes a comprehensive set of spatial tools via the MCP (Model Context Protocol). This server lets you perform spatial queries, geometry operations, spatial analyses, and PostGIS database management from a standardized tool interface, making it easy to integrate PostGIS functionality into your MCP client workflows.
To use the server, connect your MCP client to the local or remote MCP endpoint and call the available tools by name. You will pass the required parameters for each tool, and receive structured results that you can further process in your application. Focus on practical tasks such as querying nearby features, buffering geometries, computing areas, and performing spatial analyses across your PostGIS database.
Prerequisites you need before installing and running the server are a supported Python environment and network access to install dependencies.
# Step 1: Verify Python version
python3 --version
# Step 2: Create a virtual environment (optional but recommended)
python3 -m venv venv
source venv/bin/activate
# Step 3: Install dependencies
pip install -r requirements.txt
# Step 4: Run the MCP server
python -m src.serverConfiguration and runtime details are provided here so you can tailor the server to your environment.
Database connection configuration is required before running the server. The connection information is defined in the database configuration and should point to your PostGIS-enabled PostgreSQL instance. Here is the configuration snippet you will typically use in your setup:
# src/config/database.py
DB_CONFIG = {
"host": "localhost",
"port": 5432,
"database": "your_database",
"user": "your_user",
"password": "your_password"
}Query nearby features using a given coordinate and radius to return spatial elements within the specified distance.
Query features within a bounding box defined by coordinates or extent.
Query features by attribute values, enabling attribute-based filtering.
Create a buffer around a geometry with a specified distance.
Calculate the area of a given geometry.
Calculate the length of a given geometry.
Convert geometry coordinates between coordinate reference systems.
Simplify a geometry to reduce complexity while preserving shape.
Compute the distance between two geometries.
Check whether two geometries intersect.
Check whether one geometry contains another.
Merge multiple geometries into a single geometry.
Compute the centroid of a geometry.
Retrieve the installed PostGIS version information.
List the spatial extensions installed on the database.
Discover tables that contain spatial columns in the database.
Get detailed spatial information for a specific table.
Create a GIST index on a spatial column to improve query performance.
Analyze a table to update planner statistics for query optimization.
Vacuum a table to reclaim storage and maintain performance.
Get the spatial bounding box or extent for a table.
Check geometries for validity and report any issues.
Perform spatial joins between datasets to combine related features.
Find the nearest K neighbors to a given geometry or point.
Cluster spatial features using algorithms like DBSCAN.
Compute the convex hull of a set of geometries.
Generate Voronoi polygons from a set of points.
Interpolate points along a line to create a set of sampled positions.
Snap geometries to a target grid or snapping tolerance.
Split a line by provided points or geometries.
Convert natural language queries into PostGIS SQL statements.
Safely execute SQL queries with user confirmation when required.