Supported as a platform for running the Stata MCP extension, enabling cross-platform functionality
Supported as a platform for running the Stata MCP extension, with specific configuration paths for MCP integration
Required as a dependency for the MCP server, but not directly integrated as a service
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Stata MCP Serverrun summary statistics on the auto dataset"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Stata MCP Extension for VS Code, Cursor, and Antigravity
This extension provides Stata integration for Visual Studio Code, Cursor, and Antigravity IDE using the Model Context Protocol (MCP). It enables AI-powered Stata development with GitHub Copilot, Cursor, Antigravity, Cline, Claude Code, or Codex.
Features
Run Stata Commands: Execute selections or entire .do files directly from your editor
Real-time Output: See Stata results instantly in your editor
Syntax Highlighting: Full syntax support for Stata .do, .ado, .mata, and .doh files
AI Assistant Integration: Contextual help and code suggestions via MCP
Cross-platform: Works on Windows, macOS, and Linux
Multi-Session Parallel Execution: Run multiple Stata sessions simultaneously with AI coding tools
Related MCP server: AI Development Assistant MCP Server
Demo
Watch how this extension enhances your Stata workflow with Cursor (or VS Code/Antigravity) 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?
Requirements
Stata 17 or higher installed on your machine
UV package manager (automatically installed or can be installed manually if needed)
Installation
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.
VS Code Installation
Option 1: From VS Code Marketplace
Install this extension directly from the VS Code Marketplace.
Or:
Open VS Code
Go to Extensions view (Ctrl+Shift+X)
Search for "Stata MCP"
Click "Install"
Option 2: From .vsix file
Download the extension package
stata-mcp-0.4.3.vsixfrom the releases page.Install using one of these methods:
Or:
Open VS Code
Go to Extensions view (Ctrl+Shift+X)
Click on "..." menu in the top-right
Select "Install from VSIX..."
Navigate to and select the downloaded .vsix file
Cursor Installation
Download the extension package
stata-mcp-0.4.3.vsixfrom the releases page.Install using one of these methods:
Or:
Open Cursor
Go to Extensions view
Click on the "..." menu
Select "Install from VSIX"
Navigate to and select the downloaded .vsix file
Antigravity Installation
Google Antigravity uses the Open VSX Registry by default, so you can install directly:
Open Antigravity
Go to Extensions view (Cmd+Shift+X)
Search for "Stata MCP"
Click "Install"
Or install from .vsix file:
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.
Usage
Running Stata Code
Open a Stata .do file
Run commands using:
Run Selection: Select Stata code and press
Ctrl+Shift+Enter(orCmd+Shift+Enteron Mac), or click the play button in the editor toolbarRun File: Press
Ctrl+Shift+D(orCmd+Shift+Don Mac) to run the entire .do file, or click the run-all button in the toolbarStop Execution: Press
Ctrl+Shift+C(orCmd+Shift+Con Mac) to stop a running commandInteractive Mode: Click the graph button in the editor toolbar to run code in an interactive browser window
View output in the Stata Output panel
Note for Cursor/Antigravity Users: Toolbar buttons may be hidden by default. To show them:
Click the ... (three dots) menu in the editor title bar
Select "Configure Icon Visibility"
Enable the Stata buttons you want to see (Run Selection, Run File, Stop, View Data, Interactive)
Data Viewer
Access the data viewer to inspect your Stata dataset:
Click the View Data button (fourth button, table icon) in the editor toolbar
View your current dataset in a table format
Filter data: Use Stata
ifconditions to view subsets of your dataExample:
price > 5000 & mpg < 30Type your condition in the filter box and click "Apply"
Click "Clear" to remove the filter and view all data
Graph Display Options
Control how graphs are displayed:
Auto-display graphs: Graphs are automatically shown when generated (default: enabled)
Disable in Extension Settings:
stata-vscode.autoDisplayGraphs
Choose display method:
VS Code webview (default): Graphs appear in a panel within VS Code
External browser: Graphs open in your default web browser
Change in Extension Settings:
stata-vscode.graphDisplayMethod
Detailed Configurations
Customize the extension behavior through VS Code settings. Access these settings via:
VS Code/Cursor/Antigravity: File > Preferences > Settings (or
Ctrl+,/Cmd+,)Search for "Stata MCP" to find all extension settings
Core Settings
Setting | Description | Default |
| Path to Stata installation directory | Auto-detected |
| Stata edition to use (MP, SE, BE) |
|
| Automatically start MCP server when extension activates |
|
Server Settings
Setting | Description | Default |
| Host for MCP server |
|
| Port for the MCP server |
|
| Force the specified port even if it's already in use |
|
Graph Settings
Setting | Description | Default |
| Automatically display graphs when generated by Stata commands |
|
| Choose how to display graphs: |
|
Log File Settings
Setting | Description | Default |
| Location for Stata log files: |
|
| Custom directory for Stata log files (only used when logFileLocation is set to | Empty |
Advanced Settings
Setting | Description | Default |
| Timeout in seconds for 'Run File' operations |
|
| Timeout in seconds for 'Run Selection' and interactive window commands |
|
| Show detailed debug information in output panel |
|
Working Directory Settings
Control which directory Stata uses when running .do files:
Setting | Description | Default |
| Working directory when running .do files: |
|
| Custom working directory path (only used when workingDirectory is set to | Empty |
Example: If your project structure is project/code/analysis.do and your do-file expects to run from project/, set workingDirectory to parent.
MCP Output Settings
These settings control how Stata output is returned to AI assistants (LLMs) via the MCP protocol, helping to reduce token usage:
Setting | Description | Default |
| Output mode for MCP returns: |
|
| Maximum tokens for MCP output (0 = unlimited). Large outputs are saved to file with a path returned instead |
|
Compact mode filters:
Loop code echoes (foreach/forvalues/while blocks) - keeps actual output only
Program definitions and Mata blocks
Command echoes and line continuations (for
run_fileonly)Verbose messages like "(N real changes made)" and "(N missing values generated)"
Multi-Session Settings
Enable parallel Stata execution with isolated sessions. Each session has its own data, variables, and macros.
Setting | Description | Default |
| Enable multi-session mode for parallel Stata execution |
|
| Maximum number of concurrent sessions (1-100) |
|
| Session idle timeout in seconds. Sessions are automatically destroyed after this period of inactivity |
|
Note: Each session requires ~200-300 MB RAM for Stata. Check your Stata license for concurrent instance limits.
GitHub Copilot supports MCP (Model Context Protocol) starting from VS Code 1.102. You can connect the Stata MCP server to Copilot for AI-powered Stata development.
Configuration
Install the Stata MCP extension in VS Code (see Installation section above)
Start the Stata MCP server: The server should start automatically when you open VS Code with the extension installed. Verify it's running by checking the status bar (should show "Stata").
Add the Stata MCP server to Copilot: You can configure MCP servers either per-workspace or globally.
Option A: Per-Workspace Configuration
Create a
.vscode/mcp.jsonfile in your workspace root:{ "servers": { "stata-mcp": { "type": "sse", "url": "http://localhost:4000/mcp" } } }Option B: Global Configuration (All Workspaces)
Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
Type "MCP: Open User Configuration" and select it
Add the Stata MCP server to the
mcp.jsonfile:{ "servers": { "stata-mcp": { "type": "sse", "url": "http://localhost:4000/mcp" } } }
The user-level
mcp.jsonfile is located at:Windows:
%APPDATA%\Code\User\mcp.jsonmacOS:
~/Library/Application Support/Code/User/mcp.jsonLinux:
~/.config/Code/User/mcp.json
Reload VS Code to apply the configuration.
GitHub Copilot will now have access to Stata tools and can help you:
Write and execute Stata commands
Analyze your data
Generate visualizations
Debug Stata code
Create statistical reports
Verifying the Connection
Open GitHub Copilot Chat (Ctrl+Shift+I / Cmd+Shift+I)
Type
@mcpto see available MCP toolsThe Stata tools (
stata_run_selection,stata_run_file) should appear
Troubleshooting
If Copilot is not recognizing the Stata MCP server:
Verify VS Code version 1.102 or later
Verify the MCP server is running (Status bar should show "Stata")
Check that
.vscode/mcp.jsonexists with the correct contentTry restarting VS Code
Check the extension output panel (View > Output > Stata MCP) for any errors
Ensure MCP is enabled in your organization's Copilot policy (if applicable)
Claude Code is Anthropic's official AI coding assistant available in VS Code, Cursor, and Antigravity. Follow these steps to configure the Stata MCP server:
Installation
Install the Stata MCP extension in VS Code, Cursor, or Antigravity (see Installation section above)
Start the Stata MCP server: The server should start automatically when you open your IDE with the extension installed. Verify it's running by checking the status bar (should show "Stata").
Configuration
Once the Stata MCP server is running, configure Claude Code to connect to it:
Open your terminal or command palette
Run the following command to add the Stata MCP server:
claude mcp add --transport sse stata-mcp http://localhost:4000/mcp --scope userRestart your IDE
Claude Code will now have access to Stata tools and can help you:
Write and execute Stata commands
Analyze your data
Generate visualizations
Debug Stata code
Create statistical reports
Verifying the Connection
To verify Claude Code is properly connected to the Stata MCP server:
Open a Stata .do file or create a new one
Ask Claude Code to help with a Stata task (e.g., "Load the auto dataset and show summary statistics")
Claude Code should be able to execute Stata commands and show results
Troubleshooting
If Claude Code is not recognizing the Stata MCP server:
Verify the MCP server is running (Status bar should show "Stata")
Check that you ran the
claude mcp addcommand with the correct URLTry restarting your IDE
Check the extension output panel (View > Output > Stata MCP) for any errors
Ensure there are no port conflicts (default port is 4000)
You can use this extension with Claude Desktop through mcp-proxy:
Make sure the Stata MCP extension is installed in VS Code, Cursor, or Antigravity 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-proxyFind the path to mcp-proxy:
# On Mac/Linux which mcp-proxy # On Windows (PowerShell) (Get-Command mcp-proxy).PathConfigure 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-proxywith 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.
You can use this extension with OpenAI Codex through mcp-proxy:
Make sure the Stata MCP extension is installed in VS Code, Cursor, or Antigravity and currently running before attempting to configure Codex
Install mcp-proxy:
# Using pip pip install mcp-proxy # Or using uv (faster) uv install mcp-proxyConfigure Codex by editing the config file at
~/.codex/config.toml:On macOS/Linux (
~/.codex/config.toml):# Stata MCP Server (SSE Transport) [mcp_servers.stata-mcp] command = "mcp-proxy" args = ["http://localhost:4000/mcp"]On Windows (
%USERPROFILE%\.codex\config.toml):# Stata MCP Server (SSE Transport) [mcp_servers.stata-mcp] command = "mcp-proxy" args = ["http://localhost:4000/mcp"]If the file already contains other MCP servers, just add the
[mcp_servers.stata-mcp]section.Restart Codex or your IDE
Codex will automatically discover the available Stata tools, allowing you to run Stata commands and analyze data directly from your conversations.
Troubleshooting Codex Configuration
If Codex is not recognizing the Stata MCP server:
Verify the MCP server is running (Status bar should show "Stata")
Check that the configuration file exists at
~/.codex/config.tomlwith the correct contentEnsure mcp-proxy is installed:
pip list | grep mcp-proxyorwhich mcp-proxyTry restarting your IDE
Check the extension output panel (View > Output > Stata MCP) for any errors
Ensure there are no port conflicts (default port is 4000)
Open your Cline MCP settings file:
macOS:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.jsonWindows:
%APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.jsonLinux:
~/.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:
Troubleshooting Cline Configuration
If Cline is not recognizing the Stata MCP server:
Verify the MCP server is running (Status bar should show "Stata")
Check that the configuration file exists with the correct content
Try restarting VS Code
Check the extension output panel (View > Output > Stata MCP) for any errors
The extension automatically configures Cursor MCP integration. To verify it's working:
Open Cursor
Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) to open the Command PaletteType "Stata: Test MCP Server Connection" and press Enter
You should see a success message if the server is properly connected
Cursor Configuration File Paths
The location of Cursor MCP configuration files varies by operating system:
macOS:
Primary location:
~/.cursor/mcp.jsonAlternative location:
~/Library/Application Support/Cursor/User/mcp.json
Windows:
Primary location:
%USERPROFILE%\.cursor\mcp.jsonAlternative location:
%APPDATA%\Cursor\User\mcp.json
Linux:
Primary location:
~/.cursor/mcp.jsonAlternative location:
~/.config/Cursor/User/mcp.json
Manual Cursor Configuration
If you need to manually configure Cursor MCP:
Create or edit the MCP configuration file:
macOS/Linux:
~/.cursor/mcp.jsonWindows:
%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.
Troubleshooting Cursor Configuration
If Cursor is not recognizing the Stata MCP server:
Verify the MCP server is running
Check that the configuration file exists with the correct content
Try restarting Cursor
Ensure there are no port conflicts with other running applications
This extension uses uv, a fast Python package installer built in Rust, to manage Python dependencies. Key features:
Automatic Python setup and dependency management
Creates isolated environments that won't conflict with your system
Works across Windows, macOS, and Linux
10-100x faster than traditional pip installations
If you encounter any UV-related errors during installation:
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 | shFollow the Troubleshooting steps to reinstall the extension
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.
Troubleshooting
If you encounter issues with the extension, follow these steps to perform a clean reinstallation:
Windows
Close all VS Code/Cursor/Antigravity windows
Open Task Manager (Ctrl+Shift+Esc):
Go to the "Processes" tab
Look for any running Python or
uvicornprocessesSelect each one and click "End Task"
Remove the extension folder:
Press Win+R, type
%USERPROFILE%\.vscode\extensionsand press EnterDelete the folder
deepecon.stata-mcp-0.x.x(where x.x is the version number)For Cursor: The path is
%USERPROFILE%\.cursor\extensionsFor Antigravity: The path is
%USERPROFILE%\.antigravity\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
macOS/Linux
Close all VS Code/Cursor/Antigravity 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 # For Antigravity: rm -rf ~/.antigravity/extensions/deepecon.stata-mcp-0.x.xInstall 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 | shRestart your terminal or computer (recommended but optional)
Install the latest version of the extension from the marketplace
Additional Troubleshooting Tips
If you see errors about Python or UV not being found, make sure they are in your system's PATH:
Windows: Type "Environment Variables" in the Start menu and add the installation paths
macOS/Linux: Add the paths to your
~/.bashrc,~/.zshrc, or equivalent
If you get permission errors:
Windows: Run your IDE as Administrator
macOS/Linux: Check folder permissions with
ls -laand fix withchmodif needed
If the extension still fails to initialize:
Open the Output panel (View -> Output)
Select "Stata-MCP" from the dropdown
Check the logs for specific error messages
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:
Check your system's Python installation:
python --versionorpython3 --versionVerify UV installation:
uv --versionMake sure you have Python 3.11 or later installed
Check if your antivirus software is blocking Python or UV executables
If you're having issues with a specific Stata edition:
Make sure the selected Stata edition (MP, SE, or BE) matches what's installed on your system
Try changing the
stata-vscode.stataEditionsetting to match your installed versionRestart the extension after changing settings
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/Antigravity 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
Star History
License
MIT
Credits
Created by Lu Han, Published by DeepEcon.ai