GDAL MCP

GDAL MCP

An MCP server providing geospatial analysis tools for raster and vector data, integrated with a reflection system that requires AI agents to justify their methodological decisions. It enables accurate mapping and spatial operations by ensuring reasoned choices for coordinate systems, resampling, and data transformations.

Category
访问服务器

README

GDAL MCP

Geospatial AI with epistemic reasoning

GDAL MCP is a Model Context Protocol (MCP) server that provides AI agents with geospatial analysis capabilities while requiring them to justify their methodological choices through a reflection middleware system.

🎉 v1.1.1 Released (2025-10-26) — Vector tool parity + cross-domain reflection validated
🧠 Reflection System — Domain-based epistemic reasoning that transcends data types
⚡ 75% Cache Hit Rate — Methodology reasoning carries across raster ↔ vector operations

CI License: MIT Python 3.11+ FastMCP 2.0 PyPI Downloads


📚 Documentation


🧠 The Reflection System

What Makes GDAL MCP Different?

Most AI tool systems execute operations immediately when requested. GDAL MCP requires the AI to justify methodological decisions before execution, creating a conversation about the "why" rather than just executing the "what."

Traditional AI tool approach:

User: "Reproject this DEM to Web Mercator"
AI: *silently executes operation*
Result: DEM reprojected (but with what resampling? why that CRS? what tradeoffs?)

GDAL MCP with reflection:

User: "Reproject this DEM to Web Mercator for my web map"
AI: *reflection middleware intercepts*
AI: "Before reprojecting to EPSG:3857, let me justify this CRS choice:
     
     Intent: Web Mercator preserves angles (conformal projection),
             essential for web tile rendering and navigation
     
     Alternatives considered:
     - EPSG:4326 (WGS84) → rejected: not conformal, distorts shapes
     - Local UTM → rejected: limited extent, not web-standard
     
     Tradeoffs: Area distortion increases at high latitudes
                (acceptable for web visualization)
     
     Confidence: High - this is the standard for web mapping"

*justification stored, operation proceeds*
Result: DEM reprojected with documented methodology

Why This Matters

1. Utilizes Full MCP Protocol Capabilities

The Model Context Protocol isn't just about tool execution—it's about agentic reasoning and interaction. The reflection system leverages MCP's design to enable:

  • Pre-execution prompting (tool dependencies)
  • Structured reasoning (schema-validated justifications)
  • Stateful workflows (justification caching)
  • Human-in-the-loop interaction (advisory prompts)

2. Prevents Silent Failures

Geospatial operations can execute successfully while producing methodologically incorrect results:

  • Nearest-neighbor resampling on continuous elevation data (creates artifacts)
  • Web Mercator for area calculations (40%+ distortion possible)
  • Bilinear interpolation on categorical data (creates invalid class values)

The reflection system surfaces these choices for validation.

3. Educational, Not Restrictive

The AI isn't blocked from executing operations—it's required to demonstrate understanding:

  • First use: Explains reasoning, teaches methodology
  • Cached: Instant execution (knowledge persists)
  • Result: 75%+ cache hit rates, minimal friction

4. Creates Audit Trail

Every methodological decision is documented with:

  • Intent (what property must be preserved?)
  • Alternatives (what else was considered?)
  • Rationale (why this choice?)
  • Tradeoffs (what are the limitations?)
  • Confidence (high/medium/low)

This enables reproducible geospatial science.

🎯 Example Workflow

Multi-Operation Geospatial Analysis

User: "I need to reproject this DEM to UTM for accurate slope analysis,
       then reproject this vector layer to the same CRS for overlay"

AI Workflow:
1. Inspects DEM metadata (raster_info)
2. REFLECTION: Justifies UTM Zone 10N choice (accurate distance/area)
3. REFLECTION: Justifies cubic resampling (smooth gradients for derivatives)
4. Reprojects DEM (raster_reproject)
5. Inspects vector metadata (vector_info)
6. CACHE HIT: Reuses UTM justification (cross-domain!)
7. Reprojects vector (vector_reproject) - instant, no re-prompting
8. Both datasets now aligned in UTM Zone 10N

Result: 2 operations, 2 reflections (not 3!)
Cache hit rate: 50% → Saves time, maintains methodology

The Key Innovation: The CRS justification from step 2 is reused in step 6 because the methodology (why UTM Zone 10N?) is domain-based, not tool-based. It doesn't matter if you're working with raster or vector data—the projection choice reasoning is the same.

See Tools Reference for detailed examples of all available tools.

⚡ Key Features

🧠 Reflection Middleware

  • Pre-execution reasoning for CRS selection, resampling methods
  • Structured justifications (intent, alternatives, choice, tradeoffs, confidence)
  • Persistent cache with 75% hit rates in multi-operation workflows
  • Cross-domain cache sharing - CRS justification works for both raster AND vector

🛠️ Comprehensive Toolset

  • Raster tools: info, convert, reproject, stats
  • Vector tools: info, reproject, convert, clip, buffer, simplify
  • See Tools Reference for complete documentation

🛡️ Production Quality

  • Full type safety (mypy strict mode)
  • 72 passing tests
  • Workspace security (path validation middleware)
  • Python-native (Rasterio/PyProj/pyogrio)
  • Real-time feedback via FastMCP Context API

📚 MCP Resources

  • Workspace catalog for autonomous file discovery
  • Metadata intelligence for format detection
  • Reference knowledge base (CRS, resampling methods, compression options)

📦 Quick Start

Install via uvx (Recommended)

# Run directly from PyPI
uvx --from gdal-mcp gdal --transport stdio

MCP Configuration (Claude Desktop)

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "gdal-mcp": {
      "command": "uvx",
      "args": ["--from", "gdal-mcp", "gdal", "--transport", "stdio"],
      "env": {
        "GDAL_MCP_WORKSPACES": "/path/to/your/geospatial/data"
      }
    }
  }
}

See QUICKSTART.md for:

  • Alternative installation methods (Docker, local development)
  • Detailed MCP client configuration
  • Workspace security setup
  • Troubleshooting guide

🔧 Available Tools

GDAL MCP provides 12 production-ready tools across three categories:

Raster Operations

  • raster_info - Inspect metadata (CRS, resolution, bands, nodata)
  • raster_convert - Format conversion with compression & overviews (COG support)
  • raster_reproject ⚡ - CRS transformation (with reflection)
  • raster_stats - Statistical analysis with histograms

Vector Operations

  • vector_info - Inspect metadata (CRS, geometry, attributes)
  • vector_reproject ⚡ - CRS transformation (with reflection)
  • vector_convert - Format migration (SHP ↔ GPKG ↔ GeoJSON)
  • vector_clip - Spatial subsetting
  • vector_buffer - Proximity analysis
  • vector_simplify - Geometry simplification

Reflection System

  • store_justification - Cache epistemic reasoning (used internally)
  • Advisory prompts for CRS selection and resampling methods

⚡ = Reflection-enabled: These tools require methodological justification on first use, then cache for instant subsequent execution.

See TOOLS.md for complete documentation with examples and parameters.

🧪 Testing

# Run all tests
uv run pytest test/ -v

# With coverage
uv run pytest test/ --cov=src --cov-report=term-missing

Status: ✅ 72 passing tests including reflection system integration

🏗️ Architecture

Python-Native Stack (ADR-0017):

  • Rasterio - Raster I/O and manipulation
  • PyProj - CRS operations and transformations
  • pyogrio - High-performance vector I/O (fiona fallback)
  • Shapely - Geometry operations
  • NumPy - Array operations and statistics
  • Pydantic - Type-safe models with JSON schema

Key Design Decisions (26 ADRs guide development):

  • ADR-0026: Reflection system and epistemic governance
  • ADR-0017: Python-native over CLI shelling for performance
  • ADR-0011: Explicit resampling required (prevents silent data corruption)
  • ADR-0022: Workspace isolation for security

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for:

  • Development setup
  • Code style guide (Ruff + mypy)
  • Testing requirements (pytest + fixtures)
  • ADR process

📝 License

MIT License - see LICENSE for details.

🙏 Acknowledgments

🗺️ Roadmap

Current Status: v1.1.1 - Phase 2 Complete ✅

  • Reflection middleware operational
  • Vector/raster tool parity achieved
  • Cross-domain cache sharing validated (75% hit rates)

Next: Phase 3 - Workflow Intelligence (v2.0+)

  • Formal workflow composition
  • Multi-step orchestration
  • Analysis pattern libraries

See Vision for the complete long-term roadmap.


Built with ❤️ for the geospatial AI community

Geospatial operations that think, not just execute.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选