用于VSCode的Jupyter内核MCP服务器

MCP服务器,用于通过AI助手执行Jupyter笔记本单元。在VSCode中为Claude Code构建,但适用于所有情况。
特性
- 让AI模型直接执行Jupyter记事本中的单元格。
- 不需要手动管理jupyter服务器。使用VSCode的本机内核管理。
- 单元格执行时VSCode自动刷新
- 可与任何兼容MCP的AI(Claude Code、Gemini-cli等)配合使用
安装
安装依赖项:
pip install fastmcp jupyter-client nbformat注册MCP服务器:
# For Claude Code
fastmcp install claude-code mcp_server.py
# For other AI tools, replace 'claude-code' with your tool name. Please consult FastMCP documentation.
# Example: fastmcp install gemini-cli mcp_server.py或者手动添加到您的MCP配置中(例如。, ~/.claude/settings.json):
{
"mcpServers": {
"jupyter-kernel": {
"command": "python",
"args": ["/absolute/path/to/mcp_server.py"]
}
}
}用法
1.在笔记本中获取连接信息:
%connect_info2.告诉你的AI:
"Connect to my kernel and execute cell 2"完成。AI读取笔记本,提取连接JSON,连接,执行。
MCP工具
connect_kernel(connection_info) 使用JSON从连接到内核 %connect_info 输出。
execute_cell(notebook_path, cell_index) 在连接的内核中执行单元格。更新 .ipynb 文件。
execute_code(code) 在内核中运行代码进行检查。用于 print(var), df.head()等等。
需求
- Python 3.8+
- Jupyter内核(VSCode Jupyter扩展、JupyterLab等)
- MCP兼容AI
许可证
麻省理工学院
______________________________________________________________________
*这个项目是由 克劳德代码*
