Stata Extension
HTTP-SSEProvides Stata integration for VS Code and Cursor IDE using Model Context Protocol.
Provides Stata integration for VS Code and Cursor IDE using Model Context Protocol.
This extension provides Stata integration for Visual Studio Code and Cursor IDE using the Model Context Protocol (MCP). The extension allows you to:
Watch how this extension enhances your Stata workflow with Cursor (or VS Code) and AI assistance:
🎬 Full Video Version | 📄 View Generated PDF Report
Demo prompt: "Write and execute Stata do-files, ensuring that full absolute file paths are used in all cases. Load the auto dataset (webuse auto) and generate summary statistics for each variable. Identify and extract key features from the dataset, produce relevant plots, and save them in a folder named plots. Conduct a regression analysis to examine the main determinants of car prices. Export all outputs to a LaTeX file and compile it. Address any compilation errors automatically, and ensure that LaTeX compilation does not exceed 10 seconds. All code errors should be identified and resolved as part of the workflow."
Looking for other Stata integrations?
Note: Initial installation requires setting up dependencies which may take up to 2 minutes to complete. Please be patient during this one-time setup process. All subsequent runs will start instantly.
Install this extension directly from the VS Code Marketplace.
code --install-extension DeepEcon.stata-mcp
Or:
stata-mcp-0.2.5.vsix
from the releases page.code --install-extension path/to/stata-mcp-0.2.5.vsix
Or:
stata-mcp-0.2.5.vsix
from the releases page.cursor --install-extension path/to/stata-mcp-0.2.5.vsix
Or:
Starting with version 0.1.8, the extension integrates a fast Python package installer called uv
to set up the environment. If uv is not found on your system, the extension will attempt to install it automatically.
You can customize the extension behavior through VS Code settings:
stata-vscode.stataPath
: Path to Stata installation directorystata-vscode.mcpServerHost
: Host for MCP server (default: localhost)stata-vscode.mcpServerPort
: Port for the MCP server (default: 4000)stata-vscode.autoStartServer
: Automatically start MCP server when extension activates (default: true)stata-vscode.debugMode
: Show detailed debug information in output panel (default: false)stata-vscode.forcePort
: Force the MCP server to use the specified port even if it's already in use (default: false)stata-vscode.clineConfigPath
: Custom path to Cline configuration file (optional, defaults to standard locations)stata-vscode.runFileTimeout
: Timeout in seconds for 'Run File' operations (default: 600 seconds / 10 minutes)stata-vscode.stataEdition
: Stata edition to use (MP, SE, BE) - default: MPstata-vscode.logFileLocation
: Location for Stata log files - 'extension' (logs folder in extension directory), 'workspace' (same directory as .do file), or 'custom' (user-specified directory) - default: extensionstata-vscode.customLogDirectory
: Custom directory for Stata log files (only used when logFileLocation is set to 'custom')Ctrl+Shift+Enter
(or Cmd+Shift+Enter
on Mac)Ctrl+Shift+D
(or Cmd+Shift+D
on Mac) to run the entire .do fileThe extension automatically creates log files when running Stata .do files. You can control where these log files are saved:
logs
folder within the extension directory, keeping your workspace cleanTo change this setting:
The extension creates a local MCP server that connects your editor to Stata, enabling:
The extension automatically configures Cursor MCP integration. To verify it's working:
Ctrl+Shift+P
(or Cmd+Shift+P
on Mac) to open the Command PaletteThe location of Cursor MCP configuration files varies by operating system:
macOS:
~/.cursor/mcp.json
~/Library/Application Support/Cursor/User/mcp.json
Windows:
%USERPROFILE%\.cursor\mcp.json
%APPDATA%\Cursor\User\mcp.json
Linux:
~/.cursor/mcp.json
~/.config/Cursor/User/mcp.json
If you need to manually configure Cursor MCP:
Create or edit the MCP configuration file:
~/.cursor/mcp.json
%USERPROFILE%\.cursor\mcp.json
Add the Stata MCP server configuration:
{ "mcpServers": { "stata-mcp": { "url": "http://localhost:4000/mcp", "transport": "sse" } } }
If the file already contains other MCP servers, just add the "stata-mcp"
entry to the existing "mcpServers"
object.
Save the file and restart Cursor.
If Cursor is not recognizing the Stata MCP server:
Open your Cline MCP settings file:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
%APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Add the Stata MCP server configuration:
{ "mcpServers": { "stata-mcp": { "url": "http://localhost:4000/mcp", "transport": "sse" } } }
If the file already contains other MCP servers, just add the "stata-mcp"
entry to the existing "mcpServers"
object.
Save the file and restart VS Code.
You can also configure Cline through VS Code settings:
"cline.mcpSettings": { "stata-mcp": { "url": "http://localhost:4000/mcp", "transport": "sse" } }
If Cline is not recognizing the Stata MCP server:
You can use this extension with Claude Desktop through mcp-proxy:
Make sure the Stata MCP extension is installed in VS Code or Cursor and currently running before attempting to configure Claude Desktop
Install mcp-proxy:
# Using pip pip install mcp-proxy # Or using uv (faster) uv install mcp-proxy
Find the path to mcp-proxy:
# On Mac/Linux which mcp-proxy # On Windows (PowerShell) (Get-Command mcp-proxy).Path
Configure Claude Desktop by editing the MCP config file:
On Windows (typically at %APPDATA%\Claude Desktop\claude_desktop_config.json
):
{ "mcpServers": { "stata-mcp": { "command": "mcp-proxy", "args": ["http://127.0.0.1:4000/mcp"] } } }
On macOS (typically at ~/Library/Application Support/Claude Desktop/claude_desktop_config.json
):
{ "mcpServers": { "stata-mcp": { "command": "/path/to/mcp-proxy", "args": ["http://127.0.0.1:4000/mcp"] } } }
Replace /path/to/mcp-proxy
with the actual path you found in step 3.
Restart Claude Desktop
Claude Desktop will automatically discover the available Stata tools, allowing you to run Stata commands and analyze data directly from your conversations.
Note: There is an alternative way to use Stata MCP in Claude Desktop without installing this extension. See here.
This extension uses uv, a fast Python package installer built in Rust, to manage Python dependencies. Key features:
If you encounter any UV-related errors during installation:
# Windows (PowerShell as Administrator) powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # macOS/Linux curl -LsSf https://astral.sh/uv/install.sh | sh
Starting with version 0.1.8, this extension integrates the fast Python package installer uv to set up the environment. If uv is not found on your system, the extension will attempt to install it automatically.
If you encounter issues with the extension, follow these steps to perform a clean reinstallation:
Close all VS Code/Cursor windows
Open Task Manager (Ctrl+Shift+Esc):
uvicorn
processesRemove the extension folder:
%USERPROFILE%\.vscode\extensions
and press Enterdeepecon.stata-mcp-0.x.x
(where x.x is the version number)%USERPROFILE%\.cursor\extensions
Install UV manually (if needed):
# Open PowerShell as Administrator and run: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Restart your computer (recommended but optional)
Install the latest version of the extension from the marketplace
Close all VS Code/Cursor windows
Kill any running Python processes:
# Find Python processes ps aux | grep python # Kill them (replace <PID> with the process numbers you found) kill -9 <PID>
Remove the extension folder:
# For VS Code: rm -rf ~/.vscode/extensions/deepecon.stata-mcp-0.x.x # For Cursor: rm -rf ~/.cursor/extensions/deepecon.stata-mcp-0.x.x
Install UV manually (if needed):
# Using curl: curl -LsSf https://astral.sh/uv/install.sh | sh # Or using wget: wget -qO- https://astral.sh/uv/install.sh | sh
Restart your terminal or computer (recommended but optional)
Install the latest version of the extension from the marketplace
If you see errors about Python or UV not being found, make sure they are in your system's PATH:
~/.bashrc
, ~/.zshrc
, or equivalentIf you get permission errors:
ls -la
and fix with chmod
if neededIf the extension still fails to initialize:
# Windows py -3.11 -m venv .venv # macOS/Linux python3.11 -m venv .venv
For persistent issues:
python --version
or python3 --version
uv --version
If you're having issues with a specific Stata edition:
stata-vscode.stataEdition
setting to match your installed versionWhen opening an issue on GitHub, please provide:
python --version
)uv --version
)This detailed information will help us identify and fix the issue more quickly. You can open issues at: GitHub Issues
MIT
Created by Lu Han Published by DeepEcon