The Stata MCP Extension connects Visual Studio Code and Cursor IDE to Stata through the Model Context Protocol (MCP), allowing you to run Stata commands directly from your editor, view real-time output, and benefit from AI assistant integration.
code --install-extension DeepEcon.stata-mcp
Or:
stata-mcp-0.2.5.vsix
from the releases pagecode --install-extension path/to/stata-mcp-0.2.5.vsix
Or:
stata-mcp-0.2.5.vsix
from the releases pagecursor --install-extension path/to/stata-mcp-0.2.5.vsix
Or:
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 on activation (default: true)stata-vscode.debugMode
: Show detailed debug information (default: false)stata-vscode.forcePort
: Force the MCP server to use the specified port (default: false)stata-vscode.clineConfigPath
: Custom path to Cline configuration file (optional)stata-vscode.runFileTimeout
: Timeout for 'Run File' operations (default: 600 seconds)stata-vscode.stataEdition
: Stata edition to use (MP, SE, BE) - default: MPstata-vscode.logFileLocation
: Location for Stata log files (default: extension)stata-vscode.customLogDirectory
: Custom directory for Stata log filesThe extension automatically configures Cursor integration. To verify it's working:
Ctrl+Shift+P
(or Cmd+Shift+P
on Mac)For manual configuration, edit the appropriate file:
~/.cursor/mcp.json
%USERPROFILE%\.cursor\mcp.json
~/.cursor/mcp.json
Add the Stata MCP server configuration:
{
"mcpServers": {
"stata-mcp": {
"url": "http://localhost:4000/mcp",
"transport": "sse"
}
}
}
Edit the Cline MCP settings file and add:
{
"mcpServers": {
"stata-mcp": {
"url": "http://localhost:4000/mcp",
"transport": "sse"
}
}
}
Or configure through VS Code settings:
"cline.mcpSettings": {
"stata-mcp": {
"url": "http://localhost:4000/mcp",
"transport": "sse"
}
}
pip install mcp-proxy
# On Mac/Linux
which mcp-proxy
# On Windows (PowerShell)
(Get-Command mcp-proxy).Path
{
"mcpServers": {
"stata-mcp": {
"command": "/path/to/mcp-proxy",
"args": ["http://127.0.0.1:4000/mcp"]
}
}
}
Ctrl+Shift+Enter
(or Cmd+Shift+Enter
on Mac)Ctrl+Shift+D
(or Cmd+Shift+D
on Mac)Control where log files are saved:
If you encounter issues, try these steps:
uvicorn
processes in Task Manager%USERPROFILE%\.vscode\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
curl -LsSf https://astral.sh/uv/install.sh | sh
For persistent issues:
python --version
uv --version
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "stata-mcp" '{"url":"http://localhost:4000/mcp","transport":"sse"}'
See the official Claude Code MCP documentation for more details.
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 > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"stata-mcp": {
"url": "http://localhost:4000/mcp",
"transport": "sse"
}
}
}
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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"stata-mcp": {
"url": "http://localhost:4000/mcp",
"transport": "sse"
}
}
}
3. Restart Claude Desktop for the changes to take effect