vscode-notebook-mcp
vscode-notebook-mcp
一个 VS Code 扩展,将您 VSCode 编辑器中的 Jupyter 笔记本暴露给兼容 MCP 的 AI 代理(例如 Claude Code)。代理可以读取、编辑并在 VS Code 正在使用的同一内核中运行单元格。
状态:预 alpha 版本,个人开发者项目。全新构建;非分支。
工具 (12)
发现
工具 | 描述 |
| 列出所有打开的笔记本,包含 URI、文件名、单元格数量以及当前活动的笔记本 |
| 列出单元格,包含索引、类型、语言、预览、执行状态 |
| 获取单元格的完整源代码 |
| 获取单元格的输出(文本、错误、base64 格式的图像) |
单元格操作
工具 | 描述 |
| 在任意位置插入代码或 Markdown 单元格;可选择是否执行 |
| 替换现有单元格的内容 |
| 按索引删除单元格 |
执行
工具 | 描述 |
| 执行现有的代码单元格并返回输出 |
| 清除单个单元格的输出 |
| 清除所有单元格的输出 |
内核
工具 | 描述 |
| 语言、状态、笔记本 URI |
| 通过 |
所有工具都接受可选的 notebook_uri(省略则使用活动的笔记本编辑器)和 response_format("markdown" 或 "json")。
Related MCP server: lsp-mcp
设置
如果尚未安装,请在 VS Code 中安装 Jupyter 扩展。
构建并运行此扩展:
npm install npm run build然后在 VS Code 中打开此文件夹并按 F5 启动加载了该扩展的扩展开发主机。
添加到您的 MCP 客户端配置中:
{ "mcpServers": { "notebook": { "url": "http://127.0.0.1:49777/mcp" } } }在扩展开发主机中打开一个
.ipynb文件。在状态栏中查找🪐 :49777指示器。
配置
设置 | 默认值 | 描述 |
|
| 首选端口。如果被占用则自动递增(最多 +99)。 |
命令
Notebook MCP: Restart ServerNotebook MCP: Show Server Info
架构
┌─────────────────────────────────────────────────────────┐
│ VS Code window │
│ │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Jupyter extension (ms-toolsai.jupyter) │ │
│ │ │ │
│ │ Notebook document ◄──► Kernel ──► Outputs │ │
│ └───────────────────────────────────────────────────┘ │
│ ▲ │
│ │ vscode.NotebookEdit, │
│ │ notebook.cell.execute, │
│ │ jupyter.kernels.getKernel │
│ │ │
│ ┌───────────────────────┴───────────────────────────┐ │
│ │ This extension │ │
│ │ │ │
│ │ HTTP server :49777 ──► MCP tools (12) │ │
│ │ (StreamableHTTPServerTransport) │ │
│ └───────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
│ HTTP (MCP protocol)
▼
┌───────────────────────────────┐
│ AI agent │
│ (Claude Code, Cursor, etc.) │
└───────────────────────────────┘实现说明
写入操作通过
vscode.NotebookEdit+vscode.WorkspaceEdit进行,保留撤销/重做功能。执行操作分发
notebook.cell.execute,并通过轮询cell.executionSummary.success的boolean值来等待(VS Code 在执行开始时立即创建摘要,但只有在内核完成时success才会变为布尔值)。插入的单元格被标记有元数据 ID,以便执行器在由于其他并发编辑导致索引偏移后仍能找到它们。
多笔记本支持:每个工具都接受
notebook_uri。解析逻辑:显式 URI → 在vscode.workspace.notebookDocuments中查找(或打开它);否则回退到vscode.window.activeNotebookEditor。
开发
npm install
npm run build # esbuild bundle
npm run watch # rebuild on change
npm run typecheck # tsc --noEmit
npm test # vitest (no tests yet)在 VS Code 中按 F5 启动扩展开发主机。
参考
与本项目类似的其它项目:
datalayer/jupyter-mcp-server — 通过 HTTP/WebSocket 与正在运行的 Jupyter 服务器通信的 MCP 服务器。
olavocarvalho/vscode-runtime-notebook-mcp — 与本项目架构类似(VS Code Notebook API + 内嵌 HTTP MCP 服务器)。
我从零开始构建此项目是为了学习,并留有空间来调整设计和开发新功能。
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Read and write your Fresh Jots notes from Claude, Cursor, and any MCP client.
System-of-record notebook for AI coding agents: pages, datastores, tasks, skills over MCP.
The OpenRouter MCP server plugs OpenRouter into the AI tools you already use. Once connected, your assistant can pull live OpenRouter data (models, prices, your credits, rankings, and docs) and send quick test messages, all without leaving your editor.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to read, edit, execute cells, and capture outputs from Jupyter notebooks directly within VS Code or Cursor via the Model Context Protocol.6 npm16MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with VS Code's language server protocol features (definitions, references, diagnostics) and debugger (breakpoints, stepping, variable inspection) via an MCP server.9 npm1MIT
- AlicenseNot gradedqualityAmaintenanceVS Code extension that bridges local Jupyter Notebooks with AI Agents via MCP, enabling direct control of the active notebook tab.2MIT
- AlicenseNot gradedqualityBmaintenanceEnables external agents to run, edit, create, and manage the Jupyter notebook the user is actively editing in VS Code, headlessly and without approval dialogs. Works with any MCP client and is Jupyter-optional for document operations.1MIT