Jupyter Lab MCP Server - 提供远程控制 Jupyter Lab 的 MCP 服务
Project description
DataWise Jupyter Lab MCP Server
提供远程控制 Jupyter Lab 的 MCP (Model Context Protocol) 服务。
功能特性
- 🔗 远程连接: 连接到远程或本地 Jupyter Lab 服务器
- 📓 笔记本管理: 创建、查看、列出笔记本
- ⚡ 代码执行: 在笔记本中执行 Python 代码
- 🔄 内核控制: 管理和重启 Jupyter 内核
- 📊 服务器监控: 获取服务器状态和会话信息
- 🔒 HTTPS 支持: 完整的 SSL/TLS 安全连接支持
- 📥 文件下载: 通过内容 API 下载文件到本地
- 📁 目录浏览: 列出远程目录内容
- 📄 文件信息: 获取文件元数据而不下载内容
安装
pip install data-wise-jupyter-mcp-server
使用方法
启动 MCP 服务器
data-wise-jupyter-mcp-server
或者
datawise-jupyter-mcp
可用工具
1. 服务器管理
get_server_info- 获取 Jupyter Lab 服务器信息- 服务器状态、版本、会话数、内核数
2. 笔记本管理
list_notebooks- 列出所有笔记本create_notebook- 创建新笔记本get_notebook_content- 获取笔记本内容
3. 代码执行
execute_code- 执行代码- 在指定笔记本中执行 Python 代码
4. 内核控制
list_kernels- 列出所有内核restart_kernel- 重启内核
5. 文件操作 🆕
download_file- 下载文件到本地- 支持文本、二进制、笔记本文件
get_file_info- 获取文件信息- 文件大小、类型、修改时间等元数据
list_directory_contents- 列出目录内容- 浏览远程目录结构
配置
Jupyter Lab 服务器设置
确保你的 Jupyter Lab 服务器允许远程访问:
jupyter lab --no-browser --port=8888 --ip=0.0.0.0
获取访问令牌
启动 Jupyter Lab 时,会在控制台显示带有 token 的 URL,例如:
http://localhost:8888/lab?token=4aa4a5e0aec1f504f1738921c9c823ec28515c72bb5d7247
token 就是 4aa4a5e0aec1f504f1738921c9c823ec28515c72bb5d7247
HTTPS 配置 🆕
支持安全的 HTTPS 连接:
# 基本 HTTPS 连接
get_server_info({
"url": "https://your-jupyter-server.com:8888",
"token": "your_token",
"verify_ssl": True
})
# 自签名证书(开发环境)
get_server_info({
"url": "https://localhost:8888",
"token": "your_token",
"verify_ssl": False
})
# 自定义 CA 证书
get_server_info({
"url": "https://company-server.com:8888",
"token": "your_token",
"verify_ssl": True,
"cert_path": "/path/to/ca-cert.pem"
})
文件操作示例 🆕
# 下载文件到本地
download_file({
"url": "http://localhost:8888",
"token": "your_token",
"file_path": "data/report.csv",
"local_path": "./downloaded_report.csv"
})
# 获取文件信息
get_file_info({
"url": "http://localhost:8888",
"token": "your_token",
"file_path": "analysis.ipynb"
})
# 列出目录内容
list_directory_contents({
"url": "http://localhost:8888",
"token": "your_token",
"dir_path": "data/"
})
详细配置请参考:HTTPS_GUIDE.md
开发
环境设置
# 克隆仓库
git clone https://github.com/datawisecenter/jupyter-mcp-server.git
cd jupyter-mcp-server
# 安装依赖
pip install -r requirements.txt
# 安装为开发版本
pip install -e .
运行测试
pytest
API 参考
错误处理
所有工具返回的 JSON 格式:
成功响应:
{
"success": true,
"data": {...},
"message": "操作成功"
}
错误响应:
{
"success": false,
"error": "错误信息",
"data": null
}
支持的 Jupyter Lab 版本
- Jupyter Lab 3.x
- Jupyter Lab 4.x
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
联系方式
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file data_wise_jupyter_mcp_server-1.0.0.tar.gz.
File metadata
- Download URL: data_wise_jupyter_mcp_server-1.0.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf3ca1f4496934f274bc954e82611dace876b72835f83f177ea1f746098232cf
|
|
| MD5 |
38b4747107ab03362436e51db5da72c6
|
|
| BLAKE2b-256 |
b169faa7caa688b64cfa4186eb3ee5ed456ccdfd66c4649c7719d9befe809596
|
File details
Details for the file data_wise_jupyter_mcp_server-1.0.0-py3-none-any.whl.
File metadata
- Download URL: data_wise_jupyter_mcp_server-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fff37e2c7ec89bcdf5ab666a40ffebcd0302dcee057ca42784f246d6b52ca372
|
|
| MD5 |
b08c82e34b5331f3db12d3724db5788a
|
|
| BLAKE2b-256 |
304025c4bde06253424bf3104d08cf6a754ab8996099cf084b5c86b951739f35
|