PostGIS Yukon MCP
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PostGIS Yukon MCPFind buildings near coordinates 120.5, 30.2 within 500 meters"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PostGIS MCP Server
基于 fastMCP 框架的 PostGIS 工具 MCP 服务器实现。
🌟 新功能: Text-to-SQL
现在支持使用自然语言查询PostGIS数据库!无需编写复杂的SQL语句,只需用中文或英文描述您的查询需求。
示例:
"查询表:buildings 坐标120.5,30.2 附近500米的建筑"
"为表:roads创建100米缓冲区"
"计算表:parks的面积"
详细信息请查看 Text-to-SQL文档
项目简介
本项目使用 fastMCP 框架封装 PostGIS 地理空间数据库工具,通过 MCP (Model Context Protocol) 协议提供标准化的工具接口。
项目结构
yukon_mcp_service/
├── src/
│ ├── __init__.py # 包初始化
│ ├── server.py # MCP 服务器主入口
│ ├── tools/ # 工具模块
│ │ ├── __init__.py
│ │ ├── spatial_query.py # 空间查询工具
│ │ ├── geometry.py # 几何操作工具
│ │ └── analysis.py # 空间分析工具
│ └── config/
│ ├── __init__.py
│ └── database.py # 数据库配置
├── tests/ # 测试文件
│ ├── __init__.py
│ └── test_tools.py
├── pyproject.toml # 项目配置
├── requirements.txt # 依赖列表
└── README.md # 项目说明功能特性
空间查询工具(3个)
query_nearby- 根据坐标查询附近的地理要素query_bbox- 空间范围查询query_attribute- 根据属性查询要素
几何操作工具(5个)
buffer_geometry- 创建几何缓冲区get_area- 计算几何面积get_length- 计算几何长度transform_coords- 坐标系统转换simplify_geom- 简化几何对象
空间分析工具(5个)
measure_distance- 计算两个几何对象之间的距离test_intersection- 检查几何对象相交关系test_containment- 检查几何对象包含关系union_geoms- 合并多个几何对象get_centroid- 计算几何对象质心
数据库管理工具(9个)
postgis_version- 获取 PostGIS 版本信息list_extensions- 列出已安装的数据库扩展discover_spatial_tables- 发现包含空间字段的表table_info- 获取表的详细空间信息create_index- 为空间列创建 GIST 索引analyze- 分析表以更新统计信息vacuum- 清理表以回收空间spatial_extent- 获取表的空间范围validate_geometries- 检查几何对象有效性
高级空间分析工具(8个)
join_spatial- 执行空间连接操作find_nearest- 查找最近的K个邻居cluster_spatial- 使用 DBSCAN 进行空间聚类compute_convex_hull- 计算凸包generate_voronoi- 生成 Voronoi 多边形interpolate_line- 沿线段插值点snap_geometry- 将几何对象捕捉到网格split_line- 使用点分割线段
Text-to-SQL 工具(2个)
nl_to_sql- 将自然语言转换为PostGIS SQL语句execute_sql- 安全执行SQL查询(需用户确认)
共计 32 个专业 PostGIS 工具
安装依赖
pip install -r requirements.txt配置说明
在使用前需要配置 PostGIS 数据库连接信息:
# src/config/database.py
DB_CONFIG = {
"host": "localhost",
"port": 5432,
"database": "your_database",
"user": "your_user",
"password": "your_password"
}运行服务
python -m src.server使用示例
通过 MCP 协议调用工具:
# 查询指定坐标附近的要素
result = await mcp_client.call_tool(
"query_nearby",
{
"longitude": 120.123,
"latitude": 30.456,
"radius": 1000
}
)开发指南
添加新工具
在
src/tools/目录下创建新的工具模块使用
@mcp.tool()装饰器定义工具函数在
server.py中注册新工具
示例:
@mcp.tool()
async def my_spatial_tool(param1: str, param2: float) -> dict:
"""工具描述"""
# 实现逻辑
return {"result": "data"}技术栈
Python 3.8+
fastMCP
PostGIS
psycopg2
asyncio
许可证
MIT License
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zmGiser/PostGIS_Yukon_MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server