The Stata MCP Extension provides a seamless integration between Stata and modern code editors like VS Code and Cursor, allowing you to run Stata commands directly from your editor and view results in real-time while leveraging AI assistance through the Model Context Protocol (MCP).
You can install the extension directly from the VS Code Marketplace:
code --install-extension DeepEcon.stata-mcp
Alternatively:
code --install-extension path/to/stata-mcp-0.2.4.vsix
Or through the VS Code interface:
cursor --install-extension path/to/stata-mcp-0.2.4.vsix
Or through the Cursor interface:
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.
Customize the extension 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 filestata-vscode.runFileTimeout
: Timeout in seconds for 'Run File' operations (default: 600 seconds)stata-vscode.stataEdition
: Stata edition to use (MP, SE, IC) - default: MPThe extension automatically configures Cursor MCP integration. To verify it's working:
Ctrl+Shift+P
(or Cmd+Shift+P
on Mac)If you need to manually configure Cursor:
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"
}
}
}
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"
}
}
}
You can also configure Cline through VS Code settings:
"cline.mcpSettings": {
"stata-mcp": {
"url": "http://localhost:4000/mcp",
"transport": "sse"
}
}
Ctrl+Shift+Enter
(or Cmd+Shift+Enter
on Mac)Ctrl+Shift+D
(or Cmd+Shift+D
on Mac) to run the entire fileSelect your preferred Stata edition (MP, SE, or IC) in the extension settings. Make sure it matches the version installed on your system.
If you encounter issues with the extension, try these steps:
uvicorn
processes in Task Manager%USERPROFILE%\.vscode\extensions
(or %USERPROFILE%\.cursor\extensions
)deepecon.stata-mcp-0.x.x
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
ps aux | grep python
kill -9 <PID>
rm -rf ~/.vscode/extensions/deepecon.stata-mcp-0.x.x
# or
rm -rf ~/.cursor/extensions/deepecon.stata-mcp-0.x.x
curl -LsSf https://astral.sh/uv/install.sh | sh
If you see error messages in the Output panel (View -> Output -> Stata-MCP), check for:
For persistent issues, verify:
python --version
or python3 --version
uv --version
You can use this extension with Claude Desktop through mcp-proxy:
pip install mcp-proxy
# or
uv install mcp-proxy
which mcp-proxy # On Mac/Linux
(Get-Command mcp-proxy).Path # On Windows (PowerShell)
%APPDATA%\Claude Desktop\claude_desktop_config.json
(Windows) or ~/Library/Application Support/Claude Desktop/claude_desktop_config.json
(macOS){
"mcpServers": {
"stata-mcp": {
"command": "/path/to/mcp-proxy",
"args": ["http://127.0.0.1:4000/mcp"]
}
}
}
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.