io.github.SepineTam/stata-mcp MCP Server
io.github.SepineTam/stata-mcp
Enable AI agents like Claude to run Stata regression analysis safely on your local device.
What this kind of tool is for
- Query, inspect, or seed a database without writing a one-off script.
- Let your agent look up schema details before it writes migration code.
- Move a small dataset between tools without leaving the terminal.
How to compare servers like this
- Engine match:
- Confirm it speaks your exact database and version, not just the family.
- Access scope:
- Read-only connections are the safe default — start there before granting writes.
- Safety rails:
- Check whether destructive statements need an explicit confirmation before they run.
- Maintenance signal:
- Database drivers change; a recently updated tool is less likely to break mid-query.
This page carries your copy-paste config: pick your MCP client in the install section on this page and use the copy button.
What is the io.github.SepineTam/stata-mcp MCP server?
The MCP-for-Stata server integrates Stata into AI agents (Claude Code, Codex, OpenClaw, Cursor) to enable automated data analysis and regression workflows. It provides safe command execution with security guards and resource monitoring, allowing LLMs to invoke Stata do-files and analyze data directly from your machine.
MCP-for-Stata lets AI agents like Claude Code and Codex execute Stata commands for empirical research, econometric analysis, and data exploration. It includes security features to block dangerous commands, RAM monitoring to prevent resource exhaustion, and support for multiple agents via a single installation. Ideal for researchers replicating studies, testing hypotheses, or learning econometrics with AI assistance.
How to install io.github.SepineTam/stata-mcp
Copy-paste configuration for popular MCP clients.
{
"mcpServers": {
"stata-mcp": {
"command": "uvx",
"args": [
"stata-mcp"
]
}
}
}Tools & capabilities
Tools this server exposes to the agent.
execute_do_file— Execute Stata do-files and capture output logsrun_command— Run individual Stata commands with result capturedata_inspection— Inspect and explore CSV, DTA, XLSX, and SPSS data fileslog_reader— Read and parse Stata text and SMCL format logssecurity_guard— Validate commands against dangerous patterns (!, shell, erase, etc.)resource_monitor— Monitor RAM usage and enforce configurable memory limits
Use cases
- Replicate empirical findings from economics and social science papers using Stata regression analysis
- Validate economic hypotheses through automated statistical testing and model estimation
- Learn econometrics interactively with step-by-step Stata explanations from Claude Code
- Review, optimize, and refactor existing Stata do-files for code quality and efficiency
- Interpret complex regression outputs and statistical results with AI-assisted explanation
io.github.SepineTam/stata-mcp MCP server FAQ
MCP-for-Stata is an MCP server that integrates Stata into AI agents like Claude Code, Codex, and OpenClaw, enabling them to execute regression analysis and data exploration tasks on your local machine safely.
Yes, MCP-for-Stata is free and open-source under the AGPL 3.0 license. You only need a Stata license and an API key for your LLM provider (Claude, DeepSeek, etc.).
Run `uvx stata-mcp install --all` for one-click installation across all supported agents, or use `claude mcp add stata-mcp -- uvx stata-mcp` for Claude Code specifically.
No special authentication is needed for MCP-for-Stata itself. You need a valid Stata license installed locally and API credentials for your LLM provider (Claude, Codex, DeepSeek, etc.).
MCP-for-Stata includes a security guard that blocks dangerous commands (!, shell, erase) and a RAM monitor that prevents memory exhaustion with configurable limits.
MCP-for-Stata supports macOS, Windows, and Linux. Run `uvx stata-mcp doctor` to verify your system is compatible.
README (reference)
Source of truth, from the repository.
MCP-for-Stata: Integrate Stata into your agent
Enable Claude Code, Codex, OpenClaw, and other AI agents to safely invoke Stata on your local device for data analysis.
<!-- mcp-name: io.github.SepineTam/mcp-for-stata -->Stata is a registered trademark of StataCorp LLC. This project is an independent community-developed tool and is not affiliated with, endorsed by, or sponsored by StataCorp LLC.
🆕 News
- Find more in WeChat: Why I made it?, and 8 figures find out Stata-MCP
- 🦞 OpenClaw Support: Standalone CLI tools for OpenClaw integration (
stata-mcp tool), see OpenClaw guide - ✨ Claude Code Plugin Support: Official plugin package with MCP server and Stata LSP integration
- Use MCP-for-Stata in Claude Code, see Claude Code advanced usage, or in Codex see Codex advanced usage
<details> <summary>Looking for others?</summary>Finding our newest research? View latest research reports.
</details> <details> <summary>Why AGPL 3.0 License?</summary>MCP or AI about Stata
- A session based MCP server for Stata, mcp-stata
- IDEs (VScode or Cursor) integrated stata-mcp for VSCode. Confused them? 💡 Comparison
Datasets and Information
- STOP Dataset: StataMCP-Team Opendata Project 📊, we have open-sourced a comprehensive dataset collection for social science research, aiming to enable the future of AI-driven and data-powered research paradigms.
The AGPL 3.0 License is a type of open-source license. It does not affect your daily use, and allows you to use, modify, and distribute this software free of charge, provided that you comply with its terms, such as retaining the original copyright notices.
Notes: While we strive to make open source accessible to everyone, we regret that we can no longer maintain the Apache-2.0 License. Due to individuals directly copying this project and claiming to be its maintainers, we have decided to change the license to AGPL-3.0 to prevent misuse of the project in ways that go against our original vision.
Notes: 尽管我们希望尽可能让所有人都能从开源中获益,但我们很遗憾地宣布无法继续保持 Apache-2.0 License。由于有人直接抄袭本项目并标榜其为项目维护者,我们不得不将 License 更改为 AGPL-3.0,以防止有人滥用本项目进行违背项目初心的事情。
Reason following:
Background: @jackdark425's repository directly copied this project and claimed to be the sole maintainer. We welcome open source collaboration based on forks, including but not limited to adding new features, fixing existing bugs, or providing valuable suggestions for the project, but we firmly oppose plagiarism and false attribution.
Update: The infringing project has been taken down via GitHub DMCA. View DMCA takedown details.
背景: @jackdark425 的仓库直接抄袭了本项目并标榜为项目唯一维护者。我们欢迎基于fork的开源协作,包括但不限于添加新的feature、修改已有bug或对项目提出您宝贵的意见,但坚决反对抄袭和虚假署名行为。
更新: 侵权项目已通过GitHub DMCA被takedown,查看DMCA下架详情。
</details>💡 Quickly Start
🚀 One-click installation for all clients!
No config, no manual JSON editing. Just one command installs MCP-for-Stata for every supported agent (Claude Code, Codex, OpenClaw, Cursor, Gemini CLI, and more):
uvx stata-mcp install --all
<details>
<summary>Supported Agents 🤖</summary>
Based on our own experience and testing, we recommend using Claude Code, Codex, and OpenClaw.
We have found that Claude and DeepSeek are the two best models across any framework.
| Agent | Tag | Command |
|---|---|---|
| Claude Desktop | claude | uvx stata-mcp install -c claude |
| Claude Code | cc | uvx stata-mcp install -c cc |
| Gemini CLI | gemini | uvx stata-mcp install -c gemini |
| Cursor | cursor | uvx stata-mcp install -c cursor |
| Cline (VScode Extension) | cline | uvx stata-mcp install -c cline |
| Codex CLI & Codex Desktop | codex | uvx stata-mcp install -c codex |
| OpenCode | opencode | uvx stata-mcp install -c opencode |
| OpenClaw | openclaw | uvx stata-mcp install -c openclaw |
If you don't have uv, see the uv installation guide to install it.
Or, use our beta install script (auto-installs uv if missing):
macOS / Linux:
curl -fsSL https://raw.githubusercontent.com/SepineTam/mcp-for-stata/master/scripts/install.sh | bash
Windows (PowerShell):
irm https://raw.githubusercontent.com/SepineTam/mcp-for-stata/master/scripts/install.ps1 | iex
If you don't know how to use them, download the installation scripts and double-click it in your device. install.bat for Windows users, and install.command for macOS users.
<a name="advanced-claude-code"></a>
Advanced - Claude Code
As we find Claude Code is the best agent for MCP-for-Stata as its prefect agentic ability, we recommend using it, and there are lots of advanced usage following:
Before using it, please make sure you have ever install Claude Code, if you don't know how to install it, visit on GitHub
Generally, you can install MCP-for-Stata globally for one time, you can run:
claude mcp add stata-mcp --scope user -- uvx stata-mcp
Then, you do not need to watch it again.
<details> <summary>Local and share with your partners</summary>If you want to install it locally only for the certain workspace, you can cd to your working directory, and run:
claude mcp add stata-mcp --env STATA_MCP__CWD=$(pwd) --scope local -- uvx --directory $(pwd) stata-mcp
It would nothing happen, you can type claude and type /mcp to find the status.
Also, collaboration is an essential part of research. You can share your MCP config with your co-authors using:
claude mcp add stata-mcp --scope project -- uvx stata-mcp
In your working directory, you can find a file named .mcp.json, your mcp config will be placed here.
Then, you can use MCP-for-Stata in Claude Code. Here are some scenarios for using it:
- Paper Replication: Replicate empirical studies from economics papers
- Quick Hypothesis Testing: Validate economic hypotheses through regression analysis
- Stata Learning Assistant: Learn econometrics with step-by-step Stata explanations
- Code Organization: Review and optimize existing Stata do-files
- Result Interpretation: Understand complex statistical outputs and regression results
If you use Claude Code inside IDEs (either the integrated terminal or the Claude Code Extension), installing our plugin including MCP-for-Stata and Stata LSP maintained by @euglevi.
# Add the MCP-for-Stata marketplace
claude plugin marketplace add SepineTam/mcp-for-stata
# Install the plugin to local, project or user scope
claude plugin install stata-toolbox -s project
The language server gives AI-generated Stata code better syntax awareness and completion, which improves output quality. We package the LSP in compliance with its license and give full attribution to the original author.
<a name="advanced-codex"></a>
Advanced - Codex
We find that many researchers are using Codex as their agent, therefore we also provide instructions for Codex users.
I figure that researchers are not using Codex CLI but Codex Desktop, so we can say it is easier to config MCP-for-Stata than other agents.
You just need to say Install MCP-for-Stata for yourself globally from https://www.statamcp.com or visit https://github.com/SepineTam/mcp-for-stata then restart your Codex Desktop after it say ready.
Also, if you want to install it manually, here are two ways:
A. Install in Codex Desktop GUI
- Open your Codex Desktop APP
- Click
Settingsin the bottom-left corner - Find
MCP serverson the left side - Click
Add server - Fill with the following:
Name: stata-mcp Command to launch: uvx Arguments: stata-mcp - Click
Save - Then, restart your Codex Desktop and enjoy it.
B. Install with Codex CLI
For CLI mode, just run the following command in your terminal
uvx stata-mcp install -c codex
Or use
codex mcp add stata-mcp -- uvx stata-mcp
Other Clients
Standard config requires: please make sure the stata is installed at the default path, and the stata cli (for macOS and Linux) exists.
The standard config json as follows, you can DIY your config via add envs.
{
"mcpServers": {
"stata-mcp": {
"command": "uvx",
"args": [
"stata-mcp"
]
}
}
}
For more detailed usage information, visit the Usage guide.
Prerequisites
- uv - Package installer and virtual environment manager
- Claude Code, Codex, OpenClaw or other Agents
- Stata License
- Your API-KEY from LLM
If you want to check whether your device is supported, you can run:
uvx stata-mcp doctor
It displays basic information about your device and checks whether your setup is supported.
<details> <summary>Example output</summary>stata-mcp v1.17.0 — Doctor Report
[PASS] os: macOS (Darwin 25.3.0, arm64)
[PASS] python: 3.13.5
[PASS] uv: uv 0.11.13
[PASS] dependencies: all required packages available
[PASS] stata_cli: /usr/local/bin/stata-mp (from env)
[PASS] stata_execution: OK (0.1s)
[PASS] config: /Users/sepinetam/.statamcp/config.toml (loaded)
[PASS] working_dir: /Users/sepinetam/Documents/Github/stata-mcp (writable)
[PASS] guard: enabled, loaded 27 rules
[PASS] monitor: disabled (psutil available)
[PASS] pypi: reachable (4.86s)
[PASS] cleanup: 0 old files (0 B) found; cleanup disabled (CLEAN_LOG_DAYS=-1)
Summary: 12 passed, 0 failed, 0 warning(s), 0 skipped
</details>
Notes:
- If you are located in China and package downloads are slow, see the solution.
- Claude is the best choice for MCP-for-Stata, for Chinese, I recommend to use DeepSeek as your model provider as it is cheap and powerful, also the score is highest in China provider, if you are increased in it, visit the report How to use StataMCP improve your social science research.
Comparison
There are several Stata-related MCP projects. The table below was generated by Claude Code after analyzing each codebase directly.
| Feature | MCP-for-Stata (this) | haoyu-haoyu/stata-ai-fusion | hanlulong/stata-mcp | tmonk/mcp-stata |
|---|---|---|---|---|
| Best for | Agent-driven analysis (Claude Code, Codex, OpenClaw) | Interactive sessions, graph export, and curated Stata knowledge | Users who write and run Stata code inside VSCode themselves | Research workflows (replication, robustness, publication QA) |
| Agents | All | All | VSCode window must stay active | All |
| Type | MCP Server + CLI toolkit | MCP Server + Skill KB + VS Code Extension | VSCode Extension (localhost server, not standalone MCP) | Session-based MCP Server |
| Execution | do-file via subprocess | pexpect interactive session + batch fallback | IDE-embedded runner via localhost :4000 | pystata (Stata 17+) |
| Safety | Command guard + RAM monitor | Cancel command + session cleanup | — | — |
| Data analysis | CSV, DTA, XLSX, SPSS handlers | In-session inspect_data / codebook | — | In-session describe / codebook |
| Logs | Text + SMCL readers | In-session search_log | — | Built-in log reader |
| Graphs | — | Auto-detect + export_graph PNG/SVG/PDF | — | Export, cache, SVG/PNG |
| CLI Support | Native (same tools as MCP server) | Basic entry point | — | — |
| Sessions | — | Multi named sessions with idle timeout | — | Multi-session, background tasks |
| IDE plug-in | — | Native VS Code / Cursor extension | Native VSCode / Cursor | Stata Workbench (VS Code) |
| Skill / Knowledge | Tool-focused skill for MCP-for-Stata (742 lines) | 5,653-line general Stata skill knowledge base | — | 20+ specialized research skills (causal inference, replication, publication QA, etc.) |
| Install | uvx stata-mcp install | uvx --from stata-ai-fusion stata-ai-fusion | VS Code Marketplace | uvx or install script |
📝 Documentation
MCP-for-Stata documents visit https://sepinetam.github.io/mcp-for-stata
Core Documentation
- Complete Documentation: Full documentation site with all features
- Configuration Guide: Unified TOML-based configuration system
- Security Guard: Security validation for dangerous commands
- Monitoring System: RAM monitoring and resource limits
- Architecture Overview: System design and integration patterns
Key Features
- Security Guard: Blocks dangerous commands (
!,shell,erase, etc.) - RAM Monitoring: Prevents memory exhaustion with configurable limits
- Unified Configuration: TOML config + environment variables
- Cross-platform support (macOS, Windows, Linux)
- Automatic log capture and error reporting
🐛 Report Issues
If you encounter any bugs or have feature requests, please open an issue.
📄 License
GNU Affero General Public License v3.0
📚 Citation
If you use MCP-for-Stata in your research, and it really helps you, you can cite this repository using one of the following formats:
BibTeX
@software{sepinetam2025stata,
author = {Song Tan},
title = {MCP-for-Stata: Integrate Stata into your agent},
year = {2025},
url = {https://github.com/sepinetam/mcp-for-stata},
version = {1.20.0}
}
APA
Song Tan. (2025). MCP-for-Stata: Integrate Stata into your agent (Version 1.20.0) [Computer software]. https://github.com/sepinetam/mcp-for-stata
Chicago
Song Tan. 2025. "MCP-for-Stata: Integrate Stata into your agent." Version 1.20.0. https://github.com/sepinetam/mcp-for-stata.
📬 Contact
Email: sepinetam@gmail.com
Or contribute directly by submitting a Pull Request! We welcome contributions of all kinds, from bug fixes to new features.
📃 Statement
Stata is a registered trademark of StataCorp LLC. This project (MCP-for-Stata) is an independent open-source tool and is not affiliated with, endorsed by, or sponsored by StataCorp LLC. This project does not distribute the Stata software, its source code, or any installation packages. Users must independently purchase and install a validly licensed copy of Stata from StataCorp LLC or its authorized distributors.
This project is licensed under AGPL-3.0. The project maintainers accept no liability for any loss or damage arising solely from the use of this project's code or documentation.
More information: refer to the Chinese version at README.zh-CN.md; in case of any conflict, the Chinese version shall prevail.
✨ Star History
Related MCP servers

io.github.SepineTam/latex-mcp
Enable AI agents to compile TeX files with LaTeX inside a Docker container.

Axcient MCP
Query Axcient x360Recover backup health, restore points, and fleet-wide BCDR metrics from a local mirror.

ConnectWise Automate MCP
Sync your ConnectWise Automate fleet to local SQLite and answer cross-client RMM questions offline.

Cove Data Protection MCP
Monitor Cove Data Protection backup health, billing, and storage trends from your terminal via AI.

Sequesign
Cryptographically verifiable receipts of an agent's delegated work, verified offline.
Find verified appliance repair, HVAC, and plumbing technicians by location and brand.