marimo-mcp
Auto-discovers running marimo notebooks and exposes tools for reading, editing, and running cells via MCP, supporting both HTTP and VS Code backends.
README
marimo-mcp
A single MCP server that auto-discovers all running marimo notebooks
and exposes tools for reading, editing, and running cells — no --mcp flag required.
Works with two backends:
- HTTP mode — connects to marimo notebooks running via
marimo edit(standard server) - VS Code mode — connects to marimo notebooks open in VS Code via the companion bridge extension
Architecture
Claude / MCP client
│
▼
marimo-mcp (Python MCP server)
│
├─── HTTP backend ──────► marimo edit --no-token notebook.py
│ (port 2718 by default)
│
└─── VS Code backend ───► marimo-mcp-bridge (VS Code extension)
│ port 42018
▼
vscode.commands.executeCommand('marimo.api', ...)
│
▼
marimo VS Code extension
Discovery runs on every tool call (cached 5 s):
- Scans running processes for
marimocommands, extracts ports - For each port: fetches the HTML page to extract
Marimo-Server-Token, then queries/api/home/running_notebooks - Checks if the bridge extension is running on port 42018 and appends any VS Code notebooks
VS Code backend — how cell execution works:
marimo's VS Code extension does not expose an HTTP server. The bridge extension (marimo-mcp-bridge) fills this gap — it runs a small HTTP server inside VS Code and forwards calls through VS Code's notebook execution pipeline (notebook.cell.execute → executeHandler → marimo LSP → kernel). This means edit_and_run_cell updates the cell visually in VS Code and returns actual stdout/stderr output.
VS Code backend — get_deps and get_variables:
These tools use static analysis of the .py file via marimo's own AST engine. No kernel or bridge needed — just the file on disk. get_variables returns variable names and their kinds (variable, import, function, class); values are only available via the HTTP backend with a running session.
Installation
1. Python MCP server
Requires Python 3.11+ and uv.
git clone <repo>
cd marimo-mcp
uv sync # creates .venv and installs all dependencies
2. VS Code bridge extension (for VS Code notebooks)
cd marimo-mcp-bridge
npm install
bash install.sh # compiles TypeScript, packages as VSIX, installs in VS Code
After installing, reload VS Code window (Developer: Reload Window).
For subsequent updates after code changes, just run bash install.sh again.
Configuration
MCP settings
Add to .vscode/mcp.json or Claude Code's MCP config:
{
"mcpServers": {
"marimo": {
"command": "uv",
"args": ["run", "marimo-mcp"],
"cwd": "/path/to/marimo-mcp",
"env": {
"MARIMO_TOKEN": "optional — only needed if marimo started with token auth"
}
}
}
}
uv run automatically uses the .venv created by uv sync.
Token authentication
By default marimo generates a random access token. Either:
- Start marimo with
--no-tokento disable authentication, or - Set
MARIMO_TOKENto the token from the startup URL (?access_token=...)
Tools
| Tool | HTTP | VS Code | Description |
|---|---|---|---|
list_notebooks |
✓ | ✓ | List all discovered notebooks |
create_notebook |
✓ | ✓ | Create a new .py notebook file |
get_cells |
✓ | ✓ | List cells with IDs and code |
get_cell_outputs |
✓ | — | Visual output and console streams |
get_errors |
✓ | — | All errors grouped by cell |
get_variables |
✓ (with values) | ✓ (names/kinds only) | Variables in the notebook |
get_deps |
✓ | ✓ | Cell dependency graph |
add_cell |
✓ | ✓ | Add a new cell (not executed); cell_type="markdown" for markup |
edit_and_run_cell |
✓ | ✓ | Edit a cell and run it, returns stdout/stderr |
delete_cell |
✓ | ✓ | Delete a cell |
get_cell_outputs and get_errors return an explicit error for VS Code notebooks.
Use edit_and_run_cell with print() calls to inspect values.
add_cell parameters
add_cell(notebook, code, after_cell_id=None, cell_type="code")
cell_type="code"— standard Python cell (default)cell_type="markdown"— markdown cell; in VS Code uses nativeNotebookCellKind.Markup(renders immediately without execution); in HTTP mode wraps inmo.md(...)
Current limitations
- VS Code output is stdout/stderr only — rich outputs (plots, dataframes, marimo UI elements)
are not captured via the bridge. Use the HTTP backend (
marimo edit --no-token) for full output access.
Claude Code skill
A Claude Code skill for working with this MCP server is available at
~/.claude/plugins/marketplaces/marimo-mcp/SKILL.md. It's enabled automatically
when the marimo-mcp@marimo-mcp plugin is active in your Claude Code settings.
This skill is complementary to marimo-pair
(which handles marimo edit HTTP mode). Use marimo-mcp when the notebook is open in VS Code.
Testing guide
Test 1: HTTP backend (marimo running locally)
Start a notebook:
marimo edit --no-token --port 2718 /tmp/test_notebook.py
Verify discovery:
uv run python -c "
import asyncio
from marimo_mcp.discovery import discover_notebooks
async def main():
nbs = await discover_notebooks()
for nb in nbs:
print(f'{nb.name} port={nb.port} via={\"vscode\" if nb.is_lsp else \"http\"}')
asyncio.run(main())
"
Edit and run a cell:
import asyncio
from marimo_mcp.server import get_cells, edit_and_run_cell
async def main():
cells = await get_cells('test_notebook.py')
# get a cell_id from the output
result = await edit_and_run_cell('test_notebook.py', 'CELL_ID', 'x = 6 * 7\nprint(x)')
print(result) # {"output": "42", "stdout": "42\n", ...}
asyncio.run(main())
Test 2: VS Code bridge extension
Verify bridge is running:
curl -s http://127.0.0.1:42018/health
# {"status":"ok"}
List open VS Code notebooks:
curl -s http://127.0.0.1:42018/notebooks | python3 -m json.tool
Full round-trip (edit + run + get output):
import asyncio
from marimo_mcp.server import get_cells, edit_and_run_cell
async def main():
cells = await get_cells('goyda.py') # VS Code notebook
cell_id = ... # from cells output
result = await edit_and_run_cell('goyda.py', cell_id, 'print(6 * 7)')
print(result) # {"output": "42", "stdout": "42\n", "stderr": ""}
asyncio.run(main())
Test 3: Unit tests
uv run pytest tests/ -v
25 tests should pass, covering MarimoClient, discovery logic, and notebook creation.
Troubleshooting
No notebooks found, but marimo is running:
- Run with
--no-token, or setMARIMO_TOKEN - Confirm the port is accessible:
curl http://localhost:2718/
Bridge not available (connection refused on port 42018):
- Check the VS Code Output panel for "marimo-mcp-bridge" channel
- Make sure a
.pymarimo notebook is open — themarimo.apicommand is only available when the marimo extension is active
Bridge needs reinstalling after code changes:
cd marimo-mcp-bridge
bash install.sh
# Then: Developer: Reload Window in VS Code
edit_and_run_cell returns empty output or times out (VS Code):
The cell execution uses VS Code's notebook pipeline. If it times out (15s default):
- Check VS Code Output → marimo for kernel startup errors
- Make sure the notebook is open and visible (not just in the background)
- Try running a cell manually first to warm up the kernel
Wrong Python executable (kernel fails to start):
The bridge resolves Python in this order:
.venv/bin/pythonnext to the notebook file.venv/bin/pythonin any VS Code workspace folder- VS Code Python extension active environment
python3(system fallback)
Create a .venv with marimo in the workspace root:
python3 -m venv .venv
.venv/bin/pip install marimo
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。