This extension provides Stata integration for Visual Studio Code and Cursor IDE using the Model Context Protocol (MCP). The extension allows you to:
Run Stata commands directly from VS Code or Cursor
Execute selections or entire .do files
View Stata output in the editor in real-time
Get AI assistant integration through the MCP protocol
Experience enhanced AI coding with Cursor or Cline
Features
Run Stata Commands: Execute selections or entire .do files directly from 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
Automatic Stata Detection: Automatically finds your Stata installation
Real-time Output: See Stata results instantly in your editor
Demo
Watch how this extension enhances your Stata workflow with Cursor (or VS Code) and AI assistance:
Stata MCP Extension Demo
[ Full Video Version](https://github.com/hanlulong/stata-mcp/raw/main/images/demo.mp4) | [ View Generated PDF Report](examples/auto_report.pdf)
<sub>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."</sub>
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.
Download the extension package stata-mcp-0.2.1.vsix from 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.2.2.vsix from 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
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.
Extension Settings
You can customize the extension behavior through VS Code settings:
stata-vscode.stataPath: Path to Stata installation directory
stata-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)
Usage
Open a Stata .do file
Run commands using:
View output in the editor panel
How It Works
The extension creates a local MCP server that connects your editor to Stata, enabling:
Command Execution: Run Stata commands and see results instantly
Context Awareness: AI assistants understand your Stata data and commands
Enhanced Productivity: Get intelligent code suggestions and documentation
Cursor MCP Configuration
The extension automatically configures Cursor MCP integration. To verify it's working:
Open Cursor
Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) to open the Command Palette
Type "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:
Windows:
Linux:
Manual Cursor Configuration
If you need to manually configure Cursor MCP:
Create or edit the MCP configuration file:
Add the Stata MCP server configuration:
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
Cline MCP Configuration
Open your Cline MCP settings file:
Add the Stata MCP server configuration:
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
Claude Desktop MCP Configuration
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:
Find the path to mcp-proxy:
Configure Claude Desktop by editing the MCP config file:On Windows (typically at %APPDATA%\Claude Desktop\claude_desktop_config.json):On macOS (typically at ~/Library/Application Support/Claude Desktop/claude_desktop_config.json):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.
Python Environment Management
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:
Follow 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 windows
Open Task Manager (Ctrl+Shift+Esc):
Remove the extension folder:
Install UV manually (if needed):
Restart your computer (recommended but optional)
Install the latest version of the extension from the marketplace
macOS/Linux
Close all VS Code/Cursor windows
Kill any running Python processes:
Remove the extension folder:
Install UV manually (if needed):
Restart 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:
If you get permission errors:
If the extension still fails to initialize:
For persistent issues:
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
This extension provides Stata integration for Visual Studio Code and Cursor IDE using the Model Context Protocol (MCP). The extension allows you to:
Run Stata commands directly from VS Code or Cursor
Execute selections or entire .do files
View Stata output in the editor in real-time
Get AI assistant integration through the MCP protocol
Experience enhanced AI coding with Cursor or Cline
Features
Run Stata Commands: Execute selections or entire .do files directly from 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
Automatic Stata Detection: Automatically finds your Stata installation
Real-time Output: See Stata results instantly in your editor
Demo
Watch how this extension enhances your Stata workflow with Cursor (or VS Code) and AI assistance:
Stata MCP Extension Demo
[ Full Video Version](https://github.com/hanlulong/stata-mcp/raw/main/images/demo.mp4) | [ View Generated PDF Report](examples/auto_report.pdf)
<sub>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."</sub>
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.
Download the extension package stata-mcp-0.2.1.vsix from 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.2.2.vsix from 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
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.
Extension Settings
You can customize the extension behavior through VS Code settings:
stata-vscode.stataPath: Path to Stata installation directory
stata-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)
Usage
Open a Stata .do file
Run commands using:
View output in the editor panel
How It Works
The extension creates a local MCP server that connects your editor to Stata, enabling:
Command Execution: Run Stata commands and see results instantly
Context Awareness: AI assistants understand your Stata data and commands
Enhanced Productivity: Get intelligent code suggestions and documentation
Cursor MCP Configuration
The extension automatically configures Cursor MCP integration. To verify it's working:
Open Cursor
Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) to open the Command Palette
Type "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:
Windows:
Linux:
Manual Cursor Configuration
If you need to manually configure Cursor MCP:
Create or edit the MCP configuration file:
Add the Stata MCP server configuration:
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
Cline MCP Configuration
Open your Cline MCP settings file:
Add the Stata MCP server configuration:
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
Claude Desktop MCP Configuration
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:
Find the path to mcp-proxy:
Configure Claude Desktop by editing the MCP config file:On Windows (typically at %APPDATA%\Claude Desktop\claude_desktop_config.json):On macOS (typically at ~/Library/Application Support/Claude Desktop/claude_desktop_config.json):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.
Python Environment Management
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:
Follow 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 windows
Open Task Manager (Ctrl+Shift+Esc):
Remove the extension folder:
Install UV manually (if needed):
Restart your computer (recommended but optional)
Install the latest version of the extension from the marketplace
macOS/Linux
Close all VS Code/Cursor windows
Kill any running Python processes:
Remove the extension folder:
Install UV manually (if needed):
Restart 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:
If you get permission errors:
If the extension still fails to initialize:
For persistent issues:
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