地球数据MCP服务器

Earthdata MCP Server是一个模型上下文协议(MCP)服务器实现,提供与NASA Earth Data交互的工具,支持高效数据集发现和检索,用于地理空间分析,并集成了Jupyter笔记本操作功能。

  • by ngoiyaeric
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 ngoiyaeric/earthdata-mcp-server

使用说明

🪐 ✨ 地球数据MCP服务器

Earthdata MCP服务器是 模型上下文协议 (MCP)服务器实现,提供与之交互的工具 美国国家航空航天局地球数据它能够为地理空间分析提供高效的数据集发现和检索。

🚀 新:此服务器现在包括所有 Jupyter MCP服务器 通过组合工具,为地球数据发现和Jupyter笔记本操作提供统一的界面。

以下演示使用此MCP服务器在NASA地球数据上搜索数据集和数据颗粒 jupyter地球mcp服务器 下载Jupyter中的数据和 jupyter mcp服务器 进行进一步分析。

Analyzing Sea Level Rise with AI-Powered Geospatial Tools and Jupyter - Watch Video

与Claude Desktop一起使用

要在Claude Desktop中使用此功能,请将以下内容添加到您的 claude_desktop_config.json.

{
  "mcpServers": {
    "earthdata": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "datalayer/earthdata-mcp-server:latest"
      ]
    }
  }
}

如果您使用的是Linux,请使用以下命令启动Claude。

make claude-linux

工具

服务器提供 共15个工具:3个地球数据专用工具加上12个Jupyter笔记本操作工具(前缀为 jupyter_).

地球数据工具

search_earth_datasets

  • 搜索美国国家航空航天局地球数据上的数据集。
  • 输入:
    • search_keywords(str):在数据集标题中搜索的关键字。
    • count(int):要返回的数据集数量。
    • temporal(tuple):(可选)时间范围,格式为(date_from,date_to)。
    • bounding_box(tuple):(可选)格式为(lower_lift_lon、lower_left_lat、upper_right_lon、upper_right_lat)的边界框。
  • 返回:数据集摘要列表。

search_earth_datagranules

  • 在NASA地球数据中搜索数据颗粒。
  • 输入:
    • short_name(str):数据集的简称。
    • count(int):要返回的数据颗粒数。
    • temporal(tuple):(可选)时间范围,格式为(date_from,date_to)。
    • bounding_box(tuple):(可选)格式为(lower_lift_lon、lower_left_lat、upper_right_lon、upper_right_lat)的边界框。
  • 返回:数据颗粒列表。

download_earth_data_granules 🆕

  • 从NASA地球数据下载地球数据颗粒,并与Jupyter笔记本集成。
  • 该工具将地球数据搜索功能与jupyter笔记本操作相结合,以创建无缝的下载工作流程。
  • 输入:
    • folder_name(str):用于保存数据的本地文件夹名称。
    • short_name(str):要下载的地球数据集的简称。
    • count(int):要下载的数据颗粒数。
    • temporal(tuple):(可选)时间范围,格式为(date_from,date_to)。
    • bounding_box(tuple):(可选)格式为(lower_lift_lon、lower_left_lat、upper_right_lon、upper_right_lat)的边界框。
  • 返回:包含下载代码准备详细信息的成功消息。
  • 整合:使用组合的jupyter工具将下载代码添加到笔记本中以进行交互式执行。

Jupyter工具(组合)

以下Jupyter笔记本操作工具可用于 jupyter_ 前缀:

  • jupyter_append_markdown_cell:将标记单元格添加到笔记本
  • jupyter_insert_markdown_cell:在特定位置插入标记单元格
  • jupyter_overwrite_cell_source:修改现有单元格内容
  • jupyter_append_execute_code_cell:添加并执行代码单元格
  • jupyter_insert_execute_code_cell:在特定位置插入并执行代码单元格
  • jupyter_execute_cell_with_progress:执行带有进度监控的单元格
  • jupyter_execute_cell_simple_timeout:执行有超时的单元格
  • jupyter_execute_cell_streaming:使用流式输出执行单元格
  • jupyter_read_all_cells:读取所有笔记本单元格
  • jupyter_read_cell:读取特定的笔记本单元格
  • jupyter_get_notebook_info:获取笔记本元数据
  • jupyter_delete_cell:删除笔记本单元格

有关Jupyter工具的详细文档,请参阅 Jupyter MCP服务器文档.

架构:服务器组成

此服务器使用 构图模式 将来自多个MCP服务器的工具组合到一个统一的界面中。实施:

  1. 导入Jupyter MCP服务器 在运行时
  2. 合并工具定义 从Jupyter服务器到Earthdata服务器
  3. 为Jupyter工具添加前缀 随着 jupyter_ 避免命名冲突
  4. 保留所有功能 来自两台服务器

这种方法有几个好处:

  • ✅ 统一接口:用于地球数据和Jupyter操作的单个MCP服务器
  • ✅ 无重复:重用现有的Jupyter MCP服务器代码,无需复制
  • ✅ 命名空间安全:带前缀的工具可防止命名冲突
  • ✅ 故障弱化:仅当Jupyter服务器不可用时才返回Earthdata
  • ✅ 可维护性:Jupyter MCP服务器的更改会自动包含在内

实现细节

该组合在 _compose_jupyter_tools() 功能,其中:

# Simplified version of the composition logic
def _compose_jupyter_tools():
    jupyter_mcp_module = importlib.import_module("jupyter_mcp_server.server")
    jupyter_mcp_instance = jupyter_mcp_module.mcp
    
    # Add jupyter tools with prefixed names
    for tool_name, tool in jupyter_mcp_instance._tool_manager._tools.items():
        prefixed_name = f"jupyter_{tool_name}"
        mcp._tool_manager._tools[prefixed_name] = tool

此模式可以根据需要扩展以组成额外的MCP服务器。

提示

  1. download_analyze_global_sea_level 🆕

    • 生成一个全面的工作流程,用于下载和分析全球平均海平面趋势数据集。
    • 同时使用地球数据下载工具和jupyter分析功能。
    • 返回:完整海平面分析工作流程的详细提示。
  2. sealevel_rise_dataset

    • 搜索与全球海平面上升相关的数据集。
    • 输入:
      • start_year (int):开始考虑年份。
      • end_year (int):年底考虑。
    • 返回:提示格式正确。
  3. ask_datasets_format

    • 询问数据集的格式。
    • 返回:提示格式正确。

建筑

# or run `docker build -t datalayer/earthdata-mcp-server .`
make build-docker

如果你愿意,你可以提取预构建的图像。

make pull-docker