# Jupyter地球MCP服务器
## 基本信息
- Slug: `datalayer-jupyter-earth-mcp-server`
- Source: modelscope
- Publisher: @datalayer/jupyter-earth-mcp-server
- Categories: research-and-data / education-and-learning-tools
- Hosted: No
- License: BSD 3-Clause "New" or "Revised" License
- Source URL: https://www.modelscope.cn/mcp/servers/@datalayer/jupyter-earth-mcp-server
## 简介
一种模型上下文协议服务器实现，它在Jupyter笔记本中提供地理空间分析工具，特别是用于下载NASA地球数据颗粒。
## 安装提示

```bash
pip install jupyterlab jupyter-collaboration ipykernel pip uninstall -y pycrdt datalayer_pycrdt pip install datalayer_pycrdt
```

## MCP Server 详情

<!--
  ~ 版权所有 (c) 2023-2024 Datalayer, Inc.
  ~
  ~ BSD 3-Clause 许可证
-->

[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)

[![成为赞助者](https://img.shields.io/static/v1?label=Become%20a%20Sponsor&message=%E2%9D%A4&logo=GitHub&style=flat&color=1ABC9C)](https://github.com/sponsors/datalayer)

# 🌎 ✨ Jupyter Earth MCP 服务器

[![Github Actions 状态](https://github.com/datalayer/jupyter-earth-mcp-server/workflows/Build/badge.svg)](https://github.com/datalayer/jupyter-earth-mcp-server/actions/workflows/build.yml)
[![PyPI - 版本](https://img.shields.io/pypi/v/jupyter-earth-mcp-server)](https://pypi.org/project/jupyter-earth-mcp-server)


🌍 Jupyter Earth MCP 服务器是一个 [Model Context Protocol](https://modelcontextprotocol.io) (MCP) 服务器实现，它为在 📓 Jupyter 笔记本中进行 🗺️ 地理空间分析提供了一套工具。

以下演示使用了 [Earthdata MCP 服务器](https://github.com/datalayer/earthdata-mcp-server) 在 NASA Earthdata 上搜索数据集和数据颗粒，使用此 MCP 服务器在 Jupyter 中下载数据，并使用 [jupyter-mcp-server](https://github.com/datalayer/jupyter-mcp-server) 进行进一步的分析。

<div>
  <a href="https://www.loom.com/share/c2b5b05f548d4f1492d5c107f0c48dbc">
    <p>使用 AI 驱动的地理空间工具和 Jupyter 分析海平面上升 - 观看视频</p>
  </a>
  <a href="https://www.loom.com/share/c2b5b05f548d4f1492d5c107f0c48dbc">
    <img style="max-width:100%;" src="https://cdn.loom.com/sessions/thumbnails/c2b5b05f548d4f1492d5c107f0c48dbc-598a84f02de7e74e-full-play.gif">
  </a>
</div>

## 启动 JupyterLab

确保已安装以下内容。协作包是必需的，因为借助 [Jupyter 实时协作](https://jupyterlab.readthedocs.io/en/stable/user/rtc.html)，可以在笔记本上看到所做的修改。

```bash
pip install jupyterlab jupyter-collaboration ipykernel
pip uninstall -y pycrdt datalayer_pycrdt
pip install datalayer_pycrdt
```


然后，使用以下命令启动 JupyterLab。

```bash
jupyter lab --port 8888 --IdentityProvider.token MY_TOKEN --ip 0.0.0.0
```


您也可以运行 `make jupyterlab`。

> [!NOTE]
>
> `--ip` 设置为 `0.0.0.0` 以允许在 Docker 容器中运行的 MCP 服务器访问您的本地 JupyterLab。

## 与 Claude Desktop 一起使用

Claude Desktop 可以从 [此页面](https://claude.ai/download) 下载 macOS 和 Windows 版本。

对于 Linux，我们成功使用了基于 nix 的 [非官方构建脚本](https://github.com/k3d3/claude-desktop-linux-flake)。

```bash
# ⚠️ UNOFFICIAL
# You can also run `make claude-linux`
NIXPKGS_ALLOW_UNFREE=1 nix run github:k3d3/claude-desktop-linux-flake \
  --impure \
  --extra-experimental-features flakes \
  --extra-experimental-features nix-command
```


要与 Claude Desktop 一起使用，请将以下内容添加到您的 `claude_desktop_config.json`（有关更多信息，请参阅 [MCP 文档网站](https://modelcontextprotocol.io/quickstart/user#2-add-the-filesystem-mcp-server)）。

> [!IMPORTANT]
>
> 确保 `SERVER_URL` 和 `TOKEN` 的端口与 `jupyter lab` 命令中使用的端口匹配。
>
> `NOTEBOOK_PATH` 应该是相对于启动 JupyterLab 的目录的路径。

### macOS 和 Windows 上的 Claude 配置

```json
{
  "mcpServers": {
    "jupyter-earth": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "SERVER_URL",
        "-e",
        "TOKEN",
        "-e",
        "NOTEBOOK_PATH",
        "datalayer/jupyter-earth-mcp-server:latest"
      ],
      "env": {
        "SERVER_URL": "http://host.docker.internal:8888",
        "TOKEN": "MY_TOKEN",
        "NOTEBOOK_PATH": "notebook.ipynb"
      }
    }
  }
}
```


### Linux 上的 Claude 配置

```bash
CLAUDE_CONFIG=${HOME}/.config/Claude/claude_desktop_config.json
cat <<EOF > $CLAUDE_CONFIG
{
  "mcpServers": {
    "jupyter-earth": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "SERVER_URL",
        "-e",
        "TOKEN",
        "-e",
        "NOTEBOOK_PATH",
        "--network=host",
        "datalayer/jupyter-earth-mcp-server:latest"
      ],
      "env": {
        "SERVER_URL": "http://localhost:8888",
        "TOKEN": "MY_TOKEN",
        "NOTEBOOK_PATH": "notebook.ipynb"
      }
    }
  }
}
EOF
cat $CLAUDE_CONFIG
```


## 组件

### 工具

服务器目前提供了 1 个工具：

1. `download_earth_data_granules`

- 在 Jupyter 笔记本中添加一个代码单元格，用于从 NASA Earth Data 下载地球数据颗粒。
- 输入：
  - `folder_name` (字符串)：保存数据的本地文件夹名称。
  - `short_name` (字符串)：要下载的地球数据集的简称。
  - `count` (整数)：要下载的数据颗粒数量。
  - `temporal` (元组)：(可选) 时间范围，格式为 (date_from, date_to)。
  - `bounding_box` (元组)：(可选) 边界框，格式为 (左下经度, 左下纬度, 右上经度, 右上纬度)。
- 返回：单元格输出。

### 提示

1. `download_analyze_global_sea_level`
    - 用于请求在 Jupyter 中下载和分析全球海平面数据。
    - 返回：正确格式化的提示。

## 构建

你可以从源代码构建 Docker 镜像。

```bash
make build-docker
```

