- Home
- MCP servers
- PostGIS
PostGIS
- python
1
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
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.
How to use
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.
How to install
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.server
Additional sections
Configuration 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"
}
Available tools
query_nearby
Query nearby features using a given coordinate and radius to return spatial elements within the specified distance.
query_bbox
Query features within a bounding box defined by coordinates or extent.
query_attribute
Query features by attribute values, enabling attribute-based filtering.
buffer_geometry
Create a buffer around a geometry with a specified distance.
get_area
Calculate the area of a given geometry.
get_length
Calculate the length of a given geometry.
transform_coords
Convert geometry coordinates between coordinate reference systems.
simplify_geom
Simplify a geometry to reduce complexity while preserving shape.
measure_distance
Compute the distance between two geometries.
test_intersection
Check whether two geometries intersect.
test_containment
Check whether one geometry contains another.
union_geoms
Merge multiple geometries into a single geometry.
get_centroid
Compute the centroid of a geometry.
postgis_version
Retrieve the installed PostGIS version information.
list_extensions
List the spatial extensions installed on the database.
discover_spatial_tables
Discover tables that contain spatial columns in the database.
table_info
Get detailed spatial information for a specific table.
create_index
Create a GIST index on a spatial column to improve query performance.
analyze
Analyze a table to update planner statistics for query optimization.
vacuum
Vacuum a table to reclaim storage and maintain performance.
spatial_extent
Get the spatial bounding box or extent for a table.
validate_geometries
Check geometries for validity and report any issues.
join_spatial
Perform spatial joins between datasets to combine related features.
find_nearest
Find the nearest K neighbors to a given geometry or point.
cluster_spatial
Cluster spatial features using algorithms like DBSCAN.
compute_convex_hull
Compute the convex hull of a set of geometries.
generate_voronoi
Generate Voronoi polygons from a set of points.
interpolate_line
Interpolate points along a line to create a set of sampled positions.
snap_geometry
Snap geometries to a target grid or snapping tolerance.
split_line
Split a line by provided points or geometries.
nl_to_sql
Convert natural language queries into PostGIS SQL statements.
execute_sql
Safely execute SQL queries with user confirmation when required.