stata mcp
Provides a bridge between Stata statistical software and code editors like VS Code and Cursor, enabling users to run Stata commands directly from the editor, view output in real-time, and get AI-powered assistance with Stata coding.
Provides a bridge between Stata statistical software and code editors like VS Code and Cursor, enabling users to run Stata commands directly from the editor, view output in real-time, and get AI-powered assistance with Stata coding.
This extension provides Stata integration for Visual Studio Code and Cursor IDE using the Model Context Protocol (MCP). It allows you to:
Looking for other Stata integrations? - Use Stata with Notepad++ and Sublime Text 3? See here - Use Stata MCP in Claude or Cline? See here - Use Stata via Jupyter? See here
Install this extension directly from the VS Code Marketplace.
code --install-extension DeepEcon.stata-mcp
Or: 1. Open VS Code 2. Go to Extensions view (Ctrl+Shift+X) 3. Search for "Stata MCP" 4. Click "Install"
For Cursor users:
cursor --install-extension DeepEcon.stata-mcp
Or: 1. Open Cursor 2. Go to Settings > Extensions > Browse Extensions 3. Search for "Stata MCP" 4. Click "Install"
If you prefer to install manually:
.vsix
file from the GitHub releases pagecursor --install-extension path/to/stata-mcp-0.1.5.vsix
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 and wait for the server to start. All subsequent runs will start instantly.
You can customize the extension behavior through VS Code settings:
stata-vscode.stataPath
: Path to Stata installation directorystata-vscode.pythonPath
: Path to Python interpreter. If not set, the extension will try to use the system Python or Anaconda base environmentstata-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.useUvForPython
: Use uv for Python environment management which is faster and more reliable (default: true)To enable AI integration with Stata in Cursor, you need to configure the MCP connection:
~/.cursor/mcp.json
On Windows: %USERPROFILE%.cursormcp.json
Add the following configuration to your mcp.json
file:
{
"mcpServers": {
"stata-mcp": {
"url": "http://localhost:4000/mcp",
"transport": "sse"
}
}
}
If you already have other MCP configurations in the file, just add the "stata-mcp" section to your existing "mcpServers" object.
Save the file and restart Cursor
This configuration allows Cursor's AI to communicate with the Stata MCP server that starts automatically when you use the extension. When properly configured, the AI assistant can: - Interact with your Stata sessions - Execute Stata commands - Understand your datasets and variables - Provide more context-aware coding assistance - Help with data analysis and visualizations
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: 1. Install UV manually:
# 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
2. Follow the Troubleshooting steps to reinstall the extension
You can control UV usage with the stata-vscode.useUvForPython
setting (default: true).
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 creates a local MCP server that connects your editor to Stata, enabling:
If you encounter issues with the extension, follow these steps to perform a clean reinstallation:
uvicorn
processesSelect each one and click "End Task"
Remove the extension folder:
%USERPROFILE%.vscodeextensions
and press Enterdeepecon.stata-mcp-0.x.x
(where x.x is the version number)For Cursor: The path is %USERPROFILE%.cursorextensions
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
macOS/Linux: Add the paths to your ~/.bashrc
, ~/.zshrc
, or equivalent
If you get permission errors:
macOS/Linux: Check folder permissions with ls -la
and fix with chmod
if needed
If the extension still fails to initialize:
If you see Python-related errors, try manually creating a Python 3.11 virtual environment:
# Windows
py -3.11 -m venv .venv
# macOS/Linux
python3.11 -m venv .venv
For persistent issues:
python --version
or python3 --version
uv --version
When opening an issue on GitHub, please provide:
- The complete error message from the Output panel (View -> Output -> Stata-MCP)
- Your operating system and version
- VS Code/Cursor version
- Python version (python --version
)
- UV version (uv --version
)
- Steps to reproduce the issue
- Any relevant log files or screenshots
- The content of your MCP configuration file if applicable
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