Token导航 LogoToken导航TokenDH.com
Ogc MCP Server logo
数据服务stdio官方级别未说明来源级核验

Ogc MCP Server

MCP Server

OGC MCP Server 是一个通过自然语言处理技术连接用户与地理空间数据的服务,使得非专业用户能够通过自然语言查询获取地理空间数据和分析结果。

工具数

13

提示词数

0

GitHub Stars

0

资源数

0
数据分析PythonClaude自然语言处理Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

hanzila1

提供方

hanzila1

最后核验

2026/5/17 20:22

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

OGC MCP服务器

GSoC 2026·52°北空间信息研究有限公司

通过模型上下文协议和OGC API连接自然语言和地理空间数据。

![License: Apache 2.0](https://opensource.org/licenses/Apache-2.0) ![Python 3.10+](https://www.python.org/) ![Tests: 221 passing](#testing) ![GSoC 2026](https://summerofcode.withgoogle.com/) ![52North](https://52north.org/)

______________________________________________________________________

愿景

非专业城市规划师类型:

*“我的哪个城市公园为居民提供了最好的降温效果?”*

系统 自主地:

  • 选择正确的OGC服务器
  • 发现冷点分析过程
  • 使用公园数据执行分析
  • 返回一个简单的语言答案

没有GIS专业知识。没有服务器URL。没有技术参数。问吧。

该项目构建了一个 模型上下文协议(MCP) 将大型语言模型与全套 OGC API,使每个人都可以通过自然语言访问地理空间数据和分析。

______________________________________________________________________

现场演示输出

User: "Which Münster park provides the best cooling effect for residents?"

  System thinking...
  🔧 list_processes(localhost:5000)
  🔧 get_features(parks)
  🔧 run_analysis(cool-spot-demo)

  Assistant: Schlosspark has the highest tree coverage at 80%, making it the most
  efficient cooling park per unit area. Central Park, being 341 ha, provides the
  largest overall cooling contribution to the city. Aasee Park with its water body
  adds additional cooling through evaporation.
User: "Show me major rivers in Africa"

  System thinking...
  🔧 find_collection(rivers)        → gnosis.earth (749 global collections)
  🔧 get_features(NaturalEarth rivers, bbox=-18,-35,52,38)

  Assistant: Found rivers including the Ogooué, Pongola, Cuito, Gwayi across
  central and southern Africa. The dataset uses scalerank to indicate river
  prominence — I can refine by specific country or region if needed.
User: "What are ocean conditions near Iceland? Is it warm or cold?"

  System thinking...
  🔧 get_environmental_data(icoads-sst, lon=-20, lat=65)

  Assistant: Sea surface temperature near Iceland averages 4.2°C — this is
  cold North Atlantic water, heavily influenced by the East Greenland Current.

三个完全不同的OGC服务器。三种不同的API类型。用户提供的服务器URL为零。

______________________________________________________________________

建筑

建筑

OGC MCP Server Architecture

核心模块

文件目的
src/ogc_mcp/ogc_client.py适用于所有OGC API类型的纯异步HTTP客户端
src/ogc_mcp/mapper.py翻译OGC对象→ MCP协议对象
src/ogc_mcp/server.pyFastMCP服务器——工具、资源、提示
main.pyMCP服务器的入口点

关键创新——动态工具生成

每个OGC流程都会自动成为MCP工具:

# Server connects to any OGC endpoint
# Calls /processes to discover available processes
# Automatically generates MCP Tools from process descriptions

# Connected to demo.pygeoapi.io:
#   13 fixed tools + 6 dynamic = 19 tools total

# Connected to maps.gnosis.earth:
#   13 fixed tools + 11 dynamic = 24 tools total

# Connected to localhost:5000:
#   13 fixed tools + 2 dynamic = 15 tools total

当服务器添加新进程时,您的MCP客户端会自动拾取它。零维护。

______________________________________________________________________

OGC API覆盖范围

OGC API状态工具
功能✅ 完成get_collections, get_features, get_collection_detail
流程✅ 完成discover_processes, execute_process, get_job_status, get_job_results +动态
记录✅ 完成search_catalog, get_catalog_record
EDR✅ 完成query_edr_position, query_edr_area
常见✅ 完成discover_ogc_server

______________________________________________________________________

项目结构

ogc-mcp-server/
│
├── src/ogc_mcp/              # Core library
│   ├── __init__.py
│   ├── ogc_client.py         # Async HTTP client for all OGC API types
│   ├── mapper.py             # OGC → MCP translation layer
│   └── server.py             # FastMCP server implementation
│
├── examples/                 # Demo scripts
│   ├── autonomous_demo.py    # ★ Autonomous geospatial assistant (main demo)
│   ├── gemini_mcp_demo.py    # Gemini LLM integration with 5 scenarios
│   ├── test_stage5_e2e.py    # End-to-end integration tests
│   ├── test_stage5_part2.py  # Records + EDR tests
│   ├── test_stage5_part3.py  # Dynamic tool generation tests
│   ├── test_multi_server.py  # Multi-server compatibility tests
│   ├── test_mcp_client.py    # MCP protocol tests
│   └── test_stage3.py        # Docker backend tests
│
├── tests/                    # Unit tests
│   ├── test_ogc_client.py    # OGC HTTP client tests (10 tests)
│   └── test_schema_mapping.py # JSON schema validation (30 tests)
│
├── schemas/                  # Formal MCP-OGC mapping specification
│   ├── ogc-mcp-mapping.schema.json      # Meta-schema (29 mapping rules)
│   ├── ogc-mcp-mapping-instance.json    # Concrete mapping instance
│   ├── MAPPING_RATIONALE.md             # Design decisions explained
│   └── mapping-summary.md               # Quick reference
│
├── docker/                   # OGC API Processes backend
│   ├── Dockerfile
│   ├── entrypoint.sh
│   └── pygeoapi/
│       ├── pygeoapi-config.yml
│       ├── data/
│       │   └── parks.geojson            # Münster parks dataset
│       └── processes/
│           ├── cool_spot_analysis.py    # Urban heat island analysis
│           └── geospatial_buffer.py     # Spatial buffer process
│
├── main.py                   # MCP server entry point
├── requirements.txt
├── .env.example              # Environment variable template
└── .gitignore

______________________________________________________________________

快速开始

先决条件

1.克隆和安装

git clone https://github.com/hanzila1/ogc-mcp-server.git
cd ogc-mcp-server

python -m venv venv
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate

pip install -r requirements.txt

2.配置环境

cp .env.example .env

编辑 .env:

OGC_SERVER_URL=https://demo.pygeoapi.io/master
GEMINI_API_KEY=your_gemini_api_key_here

您的API密钥从未提交给git- .env 在...里 .gitignore.

3.启动本地OGC后端(Docker)

# Build the Münster parks + cool spot analysis backend
docker build -t ogc-mcp-pygeoapi ./docker

# Run it
docker run -p 5000:80 --name ogc-backend ogc-mcp-pygeoapi

# Verify it works
curl http://localhost:5000/processes

要重新启动,请执行以下操作:

docker stop ogc-backend
docker rm ogc-backend
docker run -p 5000:80 --name ogc-backend ogc-mcp-pygeoapi

4.运行自主演示

# Interactive chat — just ask anything
python examples/autonomous_demo.py

# Automated showcase — 6 scenarios across 3 servers
python examples/autonomous_demo.py demo

5.运行Gemini LLM演示(5个场景)

python examples/gemini_mcp_demo.py

6.启动MCP服务器

python main.py

服务器通过stdio传输运行,准备连接到任何兼容MCP的LLM客户端(Claude Desktop等)。

______________________________________________________________________

演示场景

自主助理(无需服务器URL)

python examples/autonomous_demo.py

尝试以下提示:

What are the ocean conditions near Iceland?
Show me major rivers in Africa
Find historic windmills near Utrecht in the Netherlands
Which Münster park is best for urban cooling?
What historical Dutch water management datasets exist?
What terrain analysis can I do with global elevation data?
What are lakes in Canada?
Find cultural heritage sites in the Netherlands

Gemini LLM集成

python examples/gemini_mcp_demo.py

运行5个自动化场景:

  1. 服务器发现——有哪些可用数据?
  2. 特征查询——带bbox过滤器的欧洲湖泊
  3. 酷点分析——精确的北纬52°城市规划师情景
  4. 目录搜索--荷兰语元数据记录
  5. EDR查询——地中海海面温度

多服务器兼容性测试

python examples/test_multi_server.py

证明同一客户端适用于三个独立的服务器:

  • demo.pygeoapi.io --17个集合,6个进程
  • localhost:5000 --定制明斯特后端
  • maps.gnosis.earth --749个集合,11个进程

______________________________________________________________________

测试

7个测试文件中的221个测试全部通过。

# Run all tests
pytest tests/ examples/ -v

# Individual test suites
pytest tests/test_ogc_client.py -v          # OGC HTTP client (10 tests)
pytest tests/test_schema_mapping.py -v      # JSON schema spec (30 tests)
pytest examples/test_mcp_client.py -v       # MCP protocol (12 tests)
pytest examples/test_stage5_e2e.py -v       # End-to-end (35 tests)
pytest examples/test_stage5_part2.py -v     # Records + EDR (35 tests)
pytest examples/test_stage5_part3.py -v     # Dynamic tools (92 tests)

测试结果总结

tests/test_ogc_client.py          10 tests  ✅
tests/test_schema_mapping.py      30 tests  ✅
examples/test_mcp_client.py       12 tests  ✅
examples/test_stage3.py            7 tests  ✅
examples/test_stage5_e2e.py       35 tests  ✅
examples/test_stage5_part2.py     35 tests  ✅
examples/test_stage5_part3.py     92 tests  ✅

Total: 221 tests — all passing

______________________________________________________________________

MCP-OGC标测规范

一个正式的JSON模式规范,定义了将OGC API概念转换为MCP协议对象的29个具体规则。位于 schemas/.

覆盖

OGC API Common    → MCP Server metadata, capabilities
OGC API Features  → MCP Tools (get_features, get_collections...)
OGC API Processes → MCP Tools (dynamic: execute_{process_id})
OGC API Records   → MCP Tools (search_catalog, get_catalog_record)
OGC API EDR       → MCP Tools (query_edr_position, query_edr_area)

关键设计决策

动态过程映射 --每个OGC进程在运行时都成为MCP工具。inputSchema直接从OGC过程描述中导出。当新进程添加到服务器时,它们会自动显示为MCP工具,无需更改代码。

服务器不可知体系结构 --服务器URL始终是一个参数,从不硬编码。同一MCP客户端适用于全球任何符合OGC标准的服务器。

模块化设计 -每个OGC API类型独立映射。添加对新的OGC API(例如,Coverages、Tiles)的支持只需要新的映射器功能,而不需要架构更改。

阅读 schemas/MAPPING_RATIONALE.md 了解完整的设计原理。

______________________________________________________________________

本地OGC API流程后端

Docker后端演示了一个完整的OGC API流程部署,其中包含两个自定义地理空间流程。

冷点分析

52°北项目描述中的关键场景——公园规划的城市热岛分析。

端点: POST /processes/cool-spot-demo/execution

输入:

{
  "inputs": {
    "park_geometries": {
      "type": "FeatureCollection",
      "features": [
        {
          "type": "Feature",
          "properties": {
            "name": "Aasee Park",
            "area_ha": 52.3,
            "tree_coverage": 0.45,
            "has_water": true
          },
          "geometry": {
            "type": "Polygon",
            "coordinates": [[[7.607,51.949],[7.617,51.949],[7.617,51.957],[7.607,51.957],[7.607,51.949]]]
          }
        }
      ]
    },
    "buffer_km": 0.5,
    "city_name": "Münster"
  }
}

输出:

{
  "city": "Münster",
  "analysis_results": [
    {
      "park_name": "Aasee Park",
      "cooling_intensity": "High",
      "estimated_temp_reduction_celsius": 4.0,
      "cooling_radius_km": 0.79
    }
  ]
}

地理空间缓冲区

端点: POST /processes/geospatial-buffer/execution

在任何点或几何图形周围创建缓冲区,这对于影响评估、规划区域和邻近度分析非常有用。

公园数据集

Central Park   — 341.1 ha, 65% tree coverage
Aasee Park     — 52.3 ha,  45% tree coverage, water body
Schlosspark    — 18.7 ha,  80% tree coverage

______________________________________________________________________

真实世界服务器测试

服务器类型集合进程注释
演示.pygeoapi.iopygeoapi176荷兰数据、美国国家海洋和大气管理局海洋EDR、荷兰元数据
地图.诺斯尼斯.地球独立74911NaturalEarth全球数据,高程分析
localhost:5000pygeoapi(Docker)12定制明斯特公园+酷点分析

该系统在零代码更改的情况下同时针对所有三种情况进行了测试,证明了真正的服务器无关互操作性。

______________________________________________________________________

环境变量

变量必填描述
GEMINI_API_KEY是(用于LLM演示)Google Gemini API密钥
OGC_SERVER_URL默认OGC服务器(默认为demo.pygeoapi.io)

______________________________________________________________________

需求

fastmcp>=0.1.0
httpx>=0.24.0
python-dotenv>=1.0.0
google-genai>=1.0.0
jsonschema>=4.0.0
pytest>=7.0.0
pytest-asyncio>=0.21.0

安装:

pip install -r requirements.txt

______________________________________________________________________

GSoC 2026项目交付成果

该项目是谷歌2026代码之夏的一部分 北纬52°空间信息研究有限公司.

可交付成果1-MCP-OGC正式标测规范

  • 机器可读JSON模式中的29条映射规则
  • 涵盖OGC API功能、流程、记录、EDR和通用
  • 用于验证的元模式
  • 设计原理文件

交付成果2——参考MCP服务器实现

  • FastMCP服务器,每台服务器有13个固定工具+动态工具
  • 异步OGC HTTP客户端支持所有4种API类型
  • OGC → MCP翻译层
  • 全栈221次测试

可交付成果3-OGC API流程后端

  • pygeoapi的Docker部署
  • 自定义冷点分析过程(城市热岛情景)
  • 自定义地理空间缓冲流程
  • 完整的OGC流程生命周期:/流程、/作业、/结果

交付成果4-LLM集成展示

  • Gemini 2.5 Flash集成功能调用
  • 自主地理空间助手(用户无需提供服务器URL)
  • 3台独立OGC服务器上的6个真实场景
  • 自然语言→ 直白的语言

导师

______________________________________________________________________

许可证

Apache软件许可证,版本2.0——请参阅 许可证 了解详情。

______________________________________________________________________

致谢

______________________________________________________________________

*基于Python构建·FastMCP·pygeoapi·Docker·Gemini 2.5 Flash*

目录标签

目录标签

数据分析PythonClaude自然语言处理地理空间数据本地部署OGCAPI自动化工具

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

13

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP