io.github.SepineTam/stata-mcp

编码与调试

by sepinetam

让 LLM 借助 Stata 协助完成回归分析流程,包括建模、结果解读与统计探索。

把大模型接上 Stata,能顺畅完成回归建模、统计探索到结果解读,对实证研究和数据分析尤其省心。

什么是 io.github.SepineTam/stata-mcp

让 LLM 借助 Stata 协助完成回归分析流程,包括建模、结果解读与统计探索。

README

<h1 align="center"> <a href="https://www.statamcp.com"> <img src="https://example-data.statamcp.com/logo_with_name.jpg" alt="logo" width="300"/> </a> </h1> <h1 align="center">MCP-for-Stata: Integrate Stata into your agent</h1>

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.

en cn fr es Publish to PyPI PyPI version PyPI Downloads License: AGPL 3.0 Issue Ask DeepWiki

<!-- mcp-name: io.github.SepineTam/mcp-for-stata -->

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,以防止有人滥用本项目进行违背项目初心的事情。

<details> <summary>Reason</summary>

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. Click here to learn about.

背景: @jackdark425 的仓库直接抄袭了本项目并标榜为项目唯一维护者。我们欢迎基于fork的开源协作,包括但不限于添加新的feature、修改已有bug或对项目提出您宝贵的意见,但坚决反对抄袭和虚假署名行为。

更新: 侵权项目已通过GitHub DMCA被takedown,点击这里查看详情。

</details>

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, look here, or Codex here

Finding our newest research? Click here or visit reports website.

<details> <summary>Looking for others?</summary>

MCP or AI about Stata

  • A session based MCP server for Stata, mcp-stata
  • IDEs (VScode or Cursor) integrated here. 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.
  • Trace DID: If you want to fetch the newest information about DID (Difference-in-Difference), click here. Now there is a Chinese translation by Sepine Tam and StataMCP-Team 🎉
  • Jupyter Lab Usage (Important: Stata 17+) here and nbstata
</details>

💡 Quickly Start

Install for all agent

If you do not want to go through complicated setup, just run the following command:

bash
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.
AgentTagCommand
Claude Desktopclaudeuvx stata-mcp install -c claude
Claude Codeccuvx stata-mcp install -c cc
Gemini CLIgeminiuvx stata-mcp install -c gemini
Cursorcursoruvx stata-mcp install -c cursor
Cline (VScode Extension)clineuvx stata-mcp install -c cline
Codex CLI & Codex Desktopcodexuvx stata-mcp install -c codex
OpenCodeopencodeuvx stata-mcp install -c opencode
OpenClawopenclawuvx stata-mcp install -c openclaw
</details>

If you don't have uv, visit here to install it. Or, use our beta install script (auto-installs uv if missing):

macOS / Linux:

bash
curl -fsSL https://raw.githubusercontent.com/SepineTam/mcp-for-stata/master/scripts/install.sh | bash

Windows (PowerShell):

powershell
irm https://raw.githubusercontent.com/SepineTam/mcp-for-stata/master/scripts/install.ps1 | iex

If you don't know how to use them, try click here and download the installation scripts and double-click it in your device. install.bat for Windows users, and install.command for macOS users.

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:

bash
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:

bash
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:

bash
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.

</details>

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.

bash
# 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.

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

  1. Open your Codex Desktop APP
  2. Click Settings in the bottom-left corner
  3. Find MCP servers on the left side
  4. Click Add server
  5. Fill with the following:
    code
    Name: stata-mcp
    Command to launch: uvx
    Arguments: stata-mcp
    
  6. Click Save
  7. Then, restart your Codex Desktop and enjoy it.

B. Install with Codex CLI

For CLI mode, just run the following command in your terminal

bash
uvx stata-mcp install -c codex

Or use

bash
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.

json
{
  "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:

bash
uvx stata-mcp doctor

It displays basic information about your device and checks whether your setup is supported.

<details> <summary>Example output</summary>
code
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:

  1. If you are located in China, a short uv usage document you can find here.
  2. 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.

FeatureMCP-for-Stata (this)hanlulong/stata-mcptmonk/mcp-stata
AgentsAllVSCode window must stay activeAll
TypeMCP Server + CLI toolkitVSCode Extension (localhost server, not standalone MCP)Session-based MCP Server
Executiondo-file via subprocessIDE-embedded runner via localhost :4000pystata (Stata 17+)
SafetyCommand guard + RAM monitor
Data analysisCSV, DTA, XLSX, SPSS handlersIn-session describe / codebook
LogsText + SMCL readersBuilt-in log reader
GraphsExport, cache, SVG/PNG
CLI SupportNative (same tools as MCP server)
SessionsMulti-session, background tasks
IDE plug-inNative VSCode / CursorStata Workbench (VS Code)
Installuvx stata-mcp installVS Code Marketplaceuvx or install script
Best forAgent-driven analysis (Claude Code, Codex, OpenClaw)Users who write and run Stata code inside VSCode themselvesResearch workflows (replication, robustness, publication QA)

📝 Documentation

MCP-for-Stata documents visit https://docs.statamcp.com

Core Documentation

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

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.18.0}
}

APA

code
Song Tan. (2025). MCP-for-Stata: Integrate Stata into your agent (Version 1.18.0) [Computer software]. https://github.com/sepinetam/mcp-for-stata

Chicago

code
Song Tan. 2025. "MCP-for-Stata: Integrate Stata into your agent." Version 1.18.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

Star History Chart

常见问题

io.github.SepineTam/stata-mcp 是什么?

让 LLM 借助 Stata 协助完成回归分析流程,包括建模、结果解读与统计探索。

相关 Skills

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描148.2k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描148.2k

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描148.2k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
86.6k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
57.0k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
47.7k

评论