Lemma VS Code extension
Lets an MCP agent edit and run the notebook open in VS Code or Cursor, live in the editor. Edits go through vscode.NotebookEdit (in-memory, no disk write) so there is no "file changed on disk" conflict.
How it works
The extension runs a local HTTP bridge on 127.0.0.1 (random port, per-session token) and writes a discovery file at ~/.lemma/vscode-<pid>.json. The Lemma MCP server finds that file and proxies vscode_* tool calls through the bridge into the editor.
Cells run via notebook.cell.execute. Output is captured from onDidChangeNotebookDocument and returned as compact text (no base64).
Build and package
cd extensions/vscode
npm install
npm run compile
npx @vscode/vsce package # produces lemma-vscode-<version>.vsix
Press F5 in VS Code to launch an Extension Development Host for local testing.
Install
lemma installs the extension automatically for any detected code / cursor, from the marketplace:
code --install-extension lemma.lemma-vscode # VS Code Marketplace
cursor --install-extension lemma.lemma-vscode # Open VSX
To sideload a local build instead (before it is published), point the installer at the packaged .vsix:
LEMMA_VSIX="$(pwd)/lemma-vscode-1.2.1.vsix" lemma --only cursor
Publishing (one-time per release)
npx @vscode/vsce publish # VS Code Marketplace — needs a publisher account + Azure DevOps PAT
npx ovsx publish # Open VSX — needs an Open VSX token
The bridge exposes routes for all vscode_* MCP tools: vscode_status, vscode_execute_cell, vscode_insert_cell, vscode_edit_cell, vscode_run_cell, vscode_add_markdown, vscode_delete_cell, vscode_read_notebook, vscode_get_state, vscode_inspect_variable, vscode_save_notebook, vscode_restart_kernel.
Mutation tools (edit, insert, delete, add_markdown) return a +/- unified diff of the change.