Stata Workbench
By tmonk
A VS Code compatible extension (Cursor, Windsurf, Antigravity etc.) that allows Stata code to be run directly from the editor. Enables AI agents to directly interact with Stata. Powered by mcp-stata, https://github.com/tmonk/mcp-stata.
- Views
- 2
- Repository stars
- 33
- Platforms
- Windows, macOS, Linux
- Workspace
- IDE
Use cases
- Stata Workbench is a unified agentic toolkit for Stata development, providing a rich IDE experience with deep AI integration: - Integrated Terminal : Rich UI for tracking Stata output with clickable links, integrated search, and persistent history. Provides a Log tab for viewing the full session history with efficient tail-loading. - Data Browser ( stata-workbench.viewData ): High-performance view of millions of rows (~20x faster with Apache Arrow) with live filtering and sorting. - Advanced MCP Tools : Full suite of tools for AI agents (Run, Inspect, Export Graphs, State Diff). - Run Selection/Current Line ( stata-workbench.runSelection ): Executes the selected code or current line via MCP tool run command with normalized output and graphs. - Run Current File ( stata-workbench.runFile ): Runs the entire .do file via MCP tool run do file . - Environment Detection ( stata manage session action="detect"): Returns Stata version, flavor, and OS metadata. - Code Linting ( stata inspect data action="lint"): Static analysis of .do and .ado files to identify style violations and potential errors. - Modern Stata Skill : A specialized knowledge base for agents to use frames, gtools , and other modern Stata features instead of legacy anti-patterns. - Setup Toolkit ( scripts/setup toolkit.py ): Automated registration for Claude Desktop, Codex, VS Code, and Cursor in one command. - Auto-manage MCP configs : Synchronizes your host MCP settings ( mcp.json ) across your favorite AI editors. - Status Bar + Cancel ( stata-workbench.cancelRequest ): Live request states with one-click cancellation. - Test MCP Server ( stata-workbench.testMcpServer ): Quick smoke checks to verify your Stata connection. - Syntax Highlighting : Full support for .do , .ado , .mata , Dyndoc Markdown, and Dyndoc LaTeX. - Install MCP CLI helper ( stata-workbench.installMcpCli ): Bootstraps the mcp-stata toolkit locally when it is missing from the environment. - Durable logs : All run results are logged to the Stata Workbench output channel for persistent reference. For a detailed breakdown of all capabilities, see FEATURES.md.
Platforms
Windows, macOS, Linux
System requirements
- Stata 17+ on macOS, Windows, or Linux. - mcp-stata : The extension requires the mcp-stata toolkit. If it is not found, you will be prompted to run the installation script.
Configuration guide
MCP configuration is synced on extension load and when you toggle the relevant settings. When a setting is enabled, the extension adds or updates the mcp-stata entry in that config. When you turn the setting off, the extension removes the mcp_stata entry cleanly.
| When | Behaviour |
|---|---|
| Extension loads | Adds/updates mcp-stata in each enabled config target |
| Setting toggled ON | Adds/updates mcp-stata in that config |
| Setting toggled OFF | Removes mcp_stata from that config |
The extension detects your editor and writes to the appropriate config file(s).
- User-level
mcp.jsonwith Stata MCP server entry - The extension delegates initial server configuration to the
mcp-statainstaller. - Works for: VS Code, Cursor, Windsurf, Antigravity
- Optional: Claude Code CLI and extension when
stataMcp.configureClaudeCodeis enabled - Optional: Codex CLI and extension when
stataMcp.configureCodexis enabled
Config file locations:
| Editor | macOS | Windows | Linux |
|---|---|---|---|
| VS Code | ~/Library/Application Support/Code/User/mcp.json |
%APPDATA%/Code/User/mcp.json |
~/.config/Code/User/mcp.json |
| VS Code Insiders | ~/Library/Application Support/Code - Insiders/User/mcp.json |
%APPDATA%/Code - Insiders/User/mcp.json |
~/.config/Code - Insiders/User/mcp.json |
| Cursor | ~/.cursor/mcp.json |
%USERPROFILE%/.cursor/mcp.json |
~/.cursor/mcp.json |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
%USERPROFILE%/.codeium/windsurf/mcp_config.json |
~/.codeium/windsurf/mcp_config.json |
| Windsurf Next | ~/.codeium/windsurf-next/mcp_config.json |
%USERPROFILE%/.codeium/windsurf-next/mcp_config.json |
~/.codeium/windsurf-next/mcp_config.json |
| Antigravity | ~/Library/Application Support/Antigravity/User/mcp.json |
%APPDATA%/Antigravity/User/mcp.json |
~/.antigravity/mcp.json |
| Claude Code CLI & extension | Via claude mcp add-json (user scope) |
same | same |
| Codex CLI & extension | stataMcp.codexConfigPath (default ~/.codex/config.toml) |
same | same |
If you want to manage the file yourself, here is the content to add. User-level mcp.json:
{
"servers": {
"mcp_stata": {
"type": "stdio",
"command": "uvx",
"args": ["--refresh", "--refresh-package", "mcp-stata", "--from", "mcp-stata@latest", "mcp-stata"]
}
}
}Stata Workbench
Stata Workbench is unified agentic toolkit for Stata development. The toolkit gives AI agents native control over Stata - run commands, inspect variables, export graphs, and build more quickly and reliably than native Stata alone. Built as a VS Code extension (Cursor, Windsurf, Antigravity), so your agent works inside your editor. Powered by mcp-stata. Featured in News.
Built by Thomas Monk, London School of Economics.
Why use this?
Run Stata without leaving your editor. Execute code, see output, and view graphs - all within VS Code. No switching windows, no copying and pasting between your do-file editor and an AI chat.
For solo work: A modern IDE for Stata—autocomplete, syntax highlighting, multiple cursors, and an AI assistant that can run commands, inspect your variables, and debug errors directly.
For collaboration: Co-authors work in the same environment they use for other code. Shared editor settings, consistent formatting, and AI assistants that understand your project structure.
For teaching: Students learn Stata with the same tools they'll use for everything else - inline errors, an integrated terminal, and an AI that can explain what went wrong.
Installation
Install directly from the marketplace listings by searching for Stata Workbench in the Extensions view.
- VS Code Marketplace: tmonk.stata-workbench
- Open VSX: tmonk/stata-workbench
Offline fallback:
- Download the latest extension .vsix from the releases page.
- In your VS Code/Cursor/Antigravity/Windsurf IDE, open the command palette (
Ctrl+Shift+PorCmd+Shift+Pon Mac) and selectExtensions: Install from VSIX.... - Select the downloaded .vsix file and install.
Quickstart
-
Install the Stata Workbench extension.
-
Open a
.dofile in VS Code (or a compatible editor). -
Run Stata: Run Selection/Line (press the play button on the top right). The Stata Terminal panel opens automatically the first time you run a command. You can interact with this as you would a standard Stata terminal.
-
Run:
sysuse auto, clear summarizeOutput appears as output cards in the panel.
-
Run:
scatter price mpgA Graph artifact card appears - click it to open the generated graph.
-
Open the Data Browser panel to view your data live.
Stata Terminal panel showing output cards and a graph artifact.
Data Browser allows for a live view of your data, with filtering and sorting.
Requirements
- Stata 17+ on macOS, Windows, or Linux.
- mcp-stata: The extension requires the
mcp-statatoolkit. If it is not found, you will be prompted to run the installation script.
Features
Stata Workbench is a unified agentic toolkit for Stata development, providing a rich IDE experience with deep AI integration:
- Integrated Terminal: Rich UI for tracking Stata output with clickable links, integrated search, and persistent history. Provides a Log tab for viewing the full session history with efficient tail-loading.
- Data Browser (
stata-workbench.viewData): High-performance view of millions of rows (~20x faster with Apache Arrow) with live filtering and sorting. - Advanced MCP Tools: Full suite of tools for AI agents (Run, Inspect, Export Graphs, State Diff).
- Run Selection/Current Line (
stata-workbench.runSelection): Executes the selected code or current line via MCP toolrun_commandwith normalized output and graphs. - Run Current File (
stata-workbench.runFile): Runs the entire.dofile via MCP toolrun_do_file. - Environment Detection (
stata_manage_sessionaction="detect"): Returns Stata version, flavor, and OS metadata. - Code Linting (
stata_inspect_dataaction="lint"): Static analysis of.doand.adofiles to identify style violations and potential errors. - Modern Stata Skill: A specialized knowledge base for agents to use frames,
gtools, and other modern Stata features instead of legacy anti-patterns. - Setup Toolkit (
scripts/setup_toolkit.py): Automated registration for Claude Desktop, Codex, VS Code, and Cursor in one command. - Auto-manage MCP configs: Synchronizes your host MCP settings (
mcp.json) across your favorite AI editors. - Status Bar + Cancel (
stata-workbench.cancelRequest): Live request states with one-click cancellation. - Test MCP Server (
stata-workbench.testMcpServer): Quick smoke checks to verify your Stata connection. - Syntax Highlighting: Full support for
.do,.ado,.mata, Dyndoc Markdown, and Dyndoc LaTeX. - Install MCP CLI helper (
stata-workbench.installMcpCli): Bootstraps themcp-statatoolkit locally when it is missing from the environment. - Durable logs: All run results are logged to the
Stata Workbenchoutput channel for persistent reference.
For a detailed breakdown of all capabilities, see FEATURES.md.
Automatic Configuration
MCP configuration is synced on extension load and when you toggle the relevant settings. When a setting is enabled, the extension adds or updates the mcp-stata entry in that config. When you turn the setting off, the extension removes the mcp_stata entry cleanly.
| When | Behaviour |
|---|---|
| Extension loads | Adds/updates mcp-stata in each enabled config target |
| Setting toggled ON | Adds/updates mcp-stata in that config |
| Setting toggled OFF | Removes mcp_stata from that config |
The extension detects your editor and writes to the appropriate config file(s).
- User-level
mcp.jsonwith Stata MCP server entry - The extension delegates initial server configuration to the
mcp-statainstaller. - Works for: VS Code, Cursor, Windsurf, Antigravity
- Optional: Claude Code CLI and extension when
stataMcp.configureClaudeCodeis enabled - Optional: Codex CLI and extension when
stataMcp.configureCodexis enabled
Config file locations:
| Editor | macOS | Windows | Linux |
|---|---|---|---|
| VS Code | ~/Library/Application Support/Code/User/mcp.json |
%APPDATA%/Code/User/mcp.json |
~/.config/Code/User/mcp.json |
| VS Code Insiders | ~/Library/Application Support/Code - Insiders/User/mcp.json |
%APPDATA%/Code - Insiders/User/mcp.json |
~/.config/Code - Insiders/User/mcp.json |
| Cursor | ~/.cursor/mcp.json |
%USERPROFILE%/.cursor/mcp.json |
~/.cursor/mcp.json |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
%USERPROFILE%/.codeium/windsurf/mcp_config.json |
~/.codeium/windsurf/mcp_config.json |
| Windsurf Next | ~/.codeium/windsurf-next/mcp_config.json |
%USERPROFILE%/.codeium/windsurf-next/mcp_config.json |
~/.codeium/windsurf-next/mcp_config.json |
| Antigravity | ~/Library/Application Support/Antigravity/User/mcp.json |
%APPDATA%/Antigravity/User/mcp.json |
~/.antigravity/mcp.json |
| Claude Code CLI & extension | Via claude mcp add-json (user scope) |
same | same |
| Codex CLI & extension | stataMcp.codexConfigPath (default ~/.codex/config.toml) |
same | same |
If you want to manage the file yourself, here is the content to add. User-level mcp.json:
{
"servers": {
"mcp_stata": {
"type": "stdio",
"command": "uvx",
"args": ["--refresh", "--refresh-package", "mcp-stata", "--from", "mcp-stata@latest", "mcp-stata"]
}
}
}