Jupyter MCP 服务器可助力你启动 JupyterLab 并实现实时协作,还能与 Claude Desktop 结合使用,为你提供便捷的笔记本操作体验。
请确保安装了以下内容。对笔记本的修改可以通过 Jupyter 实时协作(RTC)看到。
pip install jupyterlab jupyter-collaboration ipykernel
然后,使用以下命令启动 JupyterLab:
jupyter lab --port 8888 --IdentityProvider.token MY_TOKEN --ip 0.0.0.0
⚠️ 重要提示
将
--ip设置为0.0.0.0以便运行在 Docker 容器中的 MCP 服务器能够访问您的本地 JupyterLab。
要将其与 Claude Desktop 结合使用,请将以下内容添加到 claude_desktop_config.json 中:
⚠️ 重要提示
确保
SERVER_URL和TOKEN的端口与jupyter lab命令中使用的匹配。NOTEBOOK_PATH应该相对于 JupyterLab 启动目录。
{
"mcpServers": {
"jupyter": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SERVER_URL",
"-e",
"TOKEN",
"-e",
"NOTEBOOK_PATH",
"datalayer/jupyter-mcp-server:latest"
],
"env": {
"SERVER_URL": "http://host.docker.internal:8888",
"TOKEN": "MY_TOKEN",
"NOTEBOOK_PATH": "notebook.ipynb"
}
}
}
}
{
"mcpServers": {
"jupyter": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SERVER_URL",
"-e",
"TOKEN",
"-e",
"NOTEBOOK_PATH",
"--network=host",
"datalayer/jupyter-mcp-server:latest"
],
"env": {
"SERVER_URL": "http://localhost:8888",
"TOKEN": "MY_TOKEN",
"NOTEBOOK_PATH": "notebook.ipynb"
}
}
}
}
当前服务器提供两个工具:
add_execute_code_cellcell_content(字符串):要执行的代码add_markdown_cellcell_content(字符串):Markdown 内容docker build -t datalayer/jupyter-mcp-server .
要通过 Smithery 自动安装 Jupyter MCP Server 用于 Claude Desktop:
npx -y @smithery/cli install @datalayer/jupyter-mcp-server --client claude