local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
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
Stata MCP Extension for VS Code and Cursor
This extension provides Stata integration for Visual Studio Code and Cursor IDE using the Model Context Protocol (MCP). It 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 in Cursor IDE with Stata context
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
Looking for other Stata integrations?
Installation Options
Option 1: 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: Cursor Extension Store
For Cursor users:
Or:
- Open Cursor
- Go to Settings > Extensions > Browse Extensions
- Search for "Stata MCP"
- Click "Install"
Option 3: Manual Installation
If you prefer to install manually:
- Download the latest
.vsix
file from the GitHub releases page - For VS Code:
- Open VS Code
- Go to Extensions view
- Click on "..." menu in the top-right
- Select "Install from VSIX..."
- Navigate to and select the downloaded .vsix file
- For Cursor:
- Run this command in a terminal:
cursor --install-extension path/to/stata-mcp-0.1.5.vsix
- Run this command in a terminal:
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.
Extension Settings
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)
Cursor MCP Configuration
To enable AI integration with Stata in Cursor, you need to configure the MCP connection:
- Create or edit the MCP configuration file:
- On macOS/Linux:
~/.cursor/mcp.json
- On Windows:
%USERPROFILE%\.cursor\mcp.json
- On macOS/Linux:
- Add the following configuration to your
mcp.json
file:
- 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
Requirements
- Stata 15 or higher installed on your machine
- UV package manager (automatically installed or can be installed manually if needed)
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:Copy
- Follow the Troubleshooting steps to reinstall the extension
You can control UV usage with the stata-vscode.useUvForPython
setting (default: true).
Usage
- Open a Stata .do file
- Run commands using:
- Run Selection: Select Stata code and press
Ctrl+Shift+Enter
(orCmd+Shift+Enter
on Mac) - Run File: Press
Ctrl+Shift+D
(orCmd+Shift+D
on Mac) to run the entire .do file
- Run Selection: Select Stata code and press
- 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
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):
- Go to the "Processes" tab
- Look for any running Python or
uvicorn
processes - Select each one and click "End Task"
- Remove the extension folder:
- Press Win+R, type
%USERPROFILE%\.vscode\extensions
and press Enter - Delete the folder
deepecon.stata-mcp-0.x.x
(where x.x is the version number) - For Cursor: The path is
%USERPROFILE%\.cursor\extensions
- Press Win+R, type
- Install UV manually (if needed):Copy
- 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:Copy
- Remove the extension folder:Copy
- Install UV manually (if needed):Copy
- 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:
- 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 VS Code/Cursor as Administrator
- macOS/Linux: Check folder permissions with
ls -la
and fix withchmod
if 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:Copy
- For persistent issues:
- Check your system's Python installation:
python --version
orpython3 --version
- Verify UV installation:
uv --version
- Make sure you have Python 3.11 or later installed
- Check if your antivirus software is blocking Python or UV executables
- Check your system's Python installation:
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
License
MIT
Credits
Created by Lu Han Published by DeepEcon
This server cannot be installed
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.