地理空间MCP服务器

一款云原生的地理空间MCP服务器,集成了DuckDB空间计算和GeoFlow DAG验证功能,为AI代理提供空间分析能力。

  • by chrislyonsKY
  • Rust
  • 本地部署
  • 更新于
在 GitHub 查看 Null-Island-Labs/geoflow-stac-mcp

使用说明

geoflow-stac-mcp

Cloud-Native Geospatial MCP Server with embedded DuckDB spatial compute and GeoFlow DAG validation


A. 云原生地理空间MCP服务器 这为人工智能代理带来了空间分析——不是作为一个愚蠢的搜索代理,而是作为一个具有类型安全工作流验证的受限分析引擎。

是什么让这与众不同

特征 典型STAC MCP geoflow STAC MCP
STAC搜索 ✅ 通过API ✅ 带验证的结构化搜索
空间计算 ❌ 手动下载COG ✅ 嵌入式DuckDB空间引擎
工作流验证 ❌ 希望LLM做对了✅ GeoFlow DAG防止类型错误
错误恢复 ❌ 隐式SQL错误 ✅ LLM可读更正提示

建筑

AI Agent (Claude, GPT, etc.)
    │
    ▼ MCP over stdio
┌──────────────────────────────────┐
│       geoflow-stac-mcp          │
│                                  │
│  1. GeoFlow DAG Validation       │
│     → Acyclicity check           │
│     → Spatial type compatibility  │
│                                  │
│  2. STAC API Search              │
│     → Microsoft Planetary Computer│
│                                  │
│  3. DuckDB Spatial Engine        │
│     → ST_Area, ST_Intersects...  │
│     → In-memory, zero-copy       │
└──────────────────────────────────┘

快速开始

# Build
cargo build --release

# Run (connects to MCP client via stdio)
./target/release/geoflow-stac-mcp

# Explain stdio usage
./target/release/geoflow-stac-mcp --help

# Print version
./target/release/geoflow-stac-mcp --version

直接终端运行行为

当从普通shell启动时,服务器将等待MCP主机通过stdio连接。 这是预期的行为,并不表示挂起。

故障排除

症状 含义 该怎么办
MCP server ready on stdio ... 然后没有进一步的输出 服务器处于空闲状态,正在等待MCP主机客户端 从Claude Desktop或其他MCP主机启动它
退出代码 0 断开连接后 正常客户端关闭/EOF 无需任何操作
退出代码 1 随着 Failed to start MCP server on stdio transport 真正的启动/协议失败 重新运行 RUST_LOG=debug 并检查标准错误

Claude桌面配置

添加 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "geoflow-stac": {
      "command": "/path/to/geoflow-stac-mcp"
    }
  }
}

MCP工具: stac_compute_query

参数

参数 类型 说明
bbox [f64; 4] 边界框 [west, south, east, north] WGS84
collection string STAC集合(例如。, sentinel-2-l2a)
spatial_operation string 空间操作描述(例如。, compute ST_Area)

支持的操作

矢量:ST_Area、ST_Interces、ST_Buffer、ST_Centroid、ST-Union、ST-Contains、ST_Distance、ST_Transform

光栅:NDVI、BandMath、区域统计

效用:ST_AsGeoJSON,计数

示例

Tool: stac_compute_query
Input: {
  "bbox": [-105.5, 39.5, -104.5, 40.5],
  "collection": "sentinel-2-l2a",
  "spatial_operation": "compute ST_Area of the scene footprints"
}

GeoFlow DAG验证

在任何SQL接触DuckDB之前,请求的工作流都会被解析为有向无环图并进行验证:

  1. 非循环 --无循环依赖(Kahn算法)
  2. 类型兼容性 --矢量运算获取矢量数据,光栅运算获取光栅数据

如果验证失败,错误消息的结构将用于LLM自我纠正:

GEOFLOW_TYPE_MISMATCH: Node 'step1' applies operator 'ST_Area' (expects Vector input)
to source data of type Raster.
To fix: ST_Area operations require Vector data. If your source data is Raster,
use a raster (e.g., NDVI, BandMath, ZonalStats) operator instead.

技术栈

  • 锈 (2021年版)——性能、安全、零成本抽象
  • rmcp v0.16.0——官方Rust MCP SDK
  • 鸭数据库 v1.4.4——具有空间扩展的嵌入式分析数据库
  • 请求 -用于STAC API调用的异步HTTP
  • 东京 --异步运行时

许可证

麻省理工学院

天梭