Metadata-Version: 2.4
Name: stata-mcp
Version: 1.17.3
Summary: Let LLM help you achieve your regression analysis with Stata
Project-URL: Homepage, https://www.statamcp.com
Project-URL: Documentation, https://docs.statamcp.com
Project-URL: Source, https://github.com/sepinetam/stata-mcp
Project-URL: Issues, https://github.com/sepinetam/stata-mcp/issues
Project-URL: Changelog, https://github.com/sepinetam/stata-mcp/blob/master/CHANGELOG.md
Author-email: Song Tan <sepinetam@gmail.com>
License: AGPL-3.0
License-File: LICENSE
Keywords: agent,ai,computational social science,econometrics,mcp,stata
Requires-Python: >=3.11
Requires-Dist: mcp[cli]>=1.27.1
Requires-Dist: openpyxl>=3.1.5
Requires-Dist: pandas<4.0.0,>=3.0.0
Requires-Dist: pathvalidate>=3.3.1
Requires-Dist: pexpect>=4.9.0
Requires-Dist: psutil>=7.2.2
Requires-Dist: pyreadstat>=1.3.4
Requires-Dist: python-dotenv>=1.2.2
Requires-Dist: requests>=2.34.0
Requires-Dist: tomli-w>=1.2.0
Description-Content-Type: text/markdown

<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">Stata-MCP</h1>

<p align="center"> 
    Let LLM help you achieve your regression analysis with Stata ✨ <br>
    Evolve from reg monkey to causal thinker 🐒 -> 🧐
</p>

[![en](https://img.shields.io/badge/lang-English-red.svg)](README.md)
[![cn](https://img.shields.io/badge/语言-中文-yellow.svg)](source/docs/README/cn/README.md)
[![Publish to PyPI](https://github.com/SepineTam/stata-mcp/actions/workflows/python-package.yml/badge.svg)](https://github.com/SepineTam/stata-mcp/actions/workflows/python-package.yml)
[![Build and Push Docker Images](https://github.com/SepineTam/stata-mcp/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/SepineTam/stata-mcp/actions/workflows/docker-publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/stata-mcp.svg)](https://pypi.org/project/stata-mcp/)
[![PyPI Downloads](https://static.pepy.tech/badge/stata-mcp)](https://pepy.tech/projects/stata-mcp)
[![License: AGPL 3.0](https://img.shields.io/badge/License-AGPL%203.0-blue.svg)](LICENSE)
[![Issue](https://img.shields.io/badge/Issue-report-green.svg)](https://github.com/sepinetam/stata-mcp/issues/new)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/SepineTam/stata-mcp)

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

---
**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](https://github.com/jackdark425/aigroup-stata-mcp) 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](https://github.com/github/dmca/blob/master/2025/12/2025-12-30-stata-mcp.md) to learn about.

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

**更新**: 侵权项目已通过GitHub DMCA被takedown，点击[这里](https://github.com/github/dmca/blob/master/2025/12/2025-12-30-stata-mcp.md)查看详情。

</details>

---
**News**:
- Find more in WeChat: [Why I made it?](https://mp.weixin.qq.com/s/VYkykdDgfPMa5KN0_1BeFQ), and [8 figures find out Stata-MCP](https://mp.weixin.qq.com/s/RKPKA4OWAM5SeZmGtbMRew)
- 🦞 **OpenClaw Support**: Standalone CLI tools for OpenClaw integration (`stata-mcp tool`), see [OpenClaw guide](https://docs.statamcp.com/agents/openclaw.md)
- ✨ **Claude Code Plugin Support**: Official plugin package with MCP server and Stata LSP integration
- Use Stata-MCP in Claude Code, look [here](#advanced---claude-code), or Codex [here](#advanced---codex)

> Finding our **newest research**? Click [here](source/reports/README.md) or visit [reports website](https://www.statamcp.com/reports).

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

> **MCP or AI about Stata**
> - A session based MCP server for Stata, [mcp-stata](https://github.com/tmonk/mcp-stata)
> - A VScode or Cursor integrated [here](https://github.com/hanlulong/stata-mcp). Confused it? 💡 [Comparison](#comparison)
> 
> **Datasets and Information**  
> - [STOP Dataset](https://opendata.ai4cssci.com): 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](https://github.com/asjadnaqvi/DiD): If you want to fetch the newest information about DID (Difference-in-Difference), click [here](https://asjadnaqvi.github.io/DiD/). Now there is a Chinese translation by [Sepine Tam](https://github.com/sepine) and [StataMCP-Team](https://github.com/statamcp-team) 🎉
> - Jupyter Lab Usage (Important: Stata 17+) [here](source/docs/JupyterStata.md) and [nbstata](https://github.com/hugetim/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.

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

</details>

If you don't have `uv`, visit [here](https://docs.astral.sh/uv/getting-started/installation) to install it. 
Or, use our beta install script (auto-installs `uv` if missing):

**macOS / Linux:**
```bash
curl -fsSL https://raw.githubusercontent.com/SepineTam/stata-mcp/master/scripts/install.sh | bash
```

**Windows (PowerShell):**
```powershell
irm https://raw.githubusercontent.com/SepineTam/stata-mcp/master/scripts/install.ps1 | iex
```

If you don't know how to use them, try click [here](https://github.com/SepineTam/stata-mcp/tree/master/scripts) 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 Stata-MCP 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](https://github.com/anthropics/claude-code)

Generally, you can install Stata-MCP 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 Stata-MCP 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 [Stata-MCP](https://github.com/sepinetam/stata-mcp) and [Stata LSP](https://github.com/euglevi/stata-language-server) maintained by @euglevi. 

```bash
# Add the Stata-MCP marketplace
claude plugin marketplace add SepineTam/stata-mcp

# 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 Stata-MCP than other agents. 

You just need to say `Install Stata-MCP for yourself globally from https://www.statamcp.com or visit https://github.com/SepineTam/stata-mcp` 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:
    ```
    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](https://docs.statamcp.com/usage).

### Prerequisites
- [uv](https://github.com/astral-sh/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>

```
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](source/docs/ChinaUsers/uv.md).
> 2. Claude is the best choice for Stata-MCP, 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](https://statamcp.com/reports/2025/09/21/stata_mcp_a_research_report_on_ai_assisted_empirical_research).

## Comparison

There are several Stata-related MCP projects. The table below was generated by Claude Code after analyzing each codebase directly.

| Feature | Stata-MCP (this) | hanlulong/stata-mcp | tmonk/mcp-stata |
|---|---|---|---|
| **Agents** | All | VSCode window must stay active | All |
| **Type** | MCP Server + CLI toolkit | VSCode Extension (localhost server, not standalone MCP) | Session-based MCP Server |
| **Execution** | do-file via subprocess | IDE-embedded runner via localhost :4000 | pystata (Stata 17+) |
| **Safety** | Command guard + RAM monitor | — | — |
| **Data analysis** | CSV, DTA, XLSX, SPSS handlers | — | In-session `describe` / `codebook` |
| **Logs** | Text + SMCL readers | — | Built-in log reader |
| **Graphs** | — | — | Export, cache, SVG/PNG |
| **CLI Support** | Native (same tools as MCP server) | — | — |
| **Sessions** | — | — | Multi-session, background tasks |
| **IDE plug-in** | — | Native VSCode / Cursor | Stata Workbench (VS Code) |
| **Install** | `uvx stata-mcp install` | VS Code Marketplace | `uvx` or install script |
| **Best for** | Agent-driven analysis (Claude Code, Codex, OpenClaw) | Users who write and run Stata code inside VSCode themselves | Research workflows (replication, robustness, publication QA) |

## 📝 Documentation
> Stata-MCP documents visit https://docs.statamcp.com

### Core Documentation
- **[Complete Documentation](https://docs.statamcp.com/)**: Full documentation site with all features
- **[Configuration Guide](https://docs.statamcp.com/configuration)**: Unified TOML-based configuration system
- **[Security Guard](https://docs.statamcp.com/security)**: Security validation for dangerous commands
- **[Monitoring System](https://docs.statamcp.com/monitoring)**: RAM monitoring and resource limits
- **[Architecture Overview](https://docs.statamcp.com/overview)**: System design and integration patterns

### Key Features
- **[Security Guard](https://docs.statamcp.com/security)**: Blocks dangerous commands (`!`, `shell`, `erase`, etc.)
- **[RAM Monitoring](https://docs.statamcp.com/monitoring)**: Prevents memory exhaustion with configurable limits
- **[Unified Configuration](https://docs.statamcp.com/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](https://github.com/sepinetam/stata-mcp/issues/new).

## 📄 License
[GNU Affero General Public License v3.0](LICENSE)

## 📚 Citation
If you use Stata-MCP 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 = {Stata-MCP: Let LLM help you achieve your regression analysis with Stata},
  year = {2025},
  url = {https://github.com/sepinetam/stata-mcp},
  version = {1.13.0}
}
```

### APA
```
Song Tan. (2025). Stata-MCP: Let LLM help you achieve your regression analysis with Stata (Version 1.13.0) [Computer software]. https://github.com/sepinetam/stata-mcp
```

### Chicago
```
Song Tan. 2025. "Stata-MCP: Let LLM help you achieve your regression analysis with Stata." Version 1.13.0. https://github.com/sepinetam/stata-mcp.
```

## 📬 Contact
Email: [sepinetam@gmail.com](mailto:sepinetam@gmail.com)

Or contribute directly by submitting a [Pull Request](https://github.com/sepinetam/stata-mcp/pulls)! We welcome contributions of all kinds, from bug fixes to new features.

## ❤️ Acknowledgements
The author sincerely thanks the Stata official team for their support and the Stata License for authorizing the test development.

## 📃 Statement
The Stata referred to in this project is the commercial software Stata developed by [StataCorp LLC](https://www.stata.com/company/). This project is not affiliated with, endorsed by, or sponsored by StataCorp LLC. This project does not include the Stata software or any installation packages; users must obtain and install a validly licensed copy of Stata from StataCorp. This project is licensed under [AGPL-3.0](LICENSE). The project maintainers accept no liability for any loss or damage arising from the use of this project or from actions related to Stata.

More information: refer to the Chinese version at [cn/README.md](source/docs/README/cn/README.md); in case of any conflict, the Chinese version shall prevail.

## ✨ Star History

[![Star History Chart](https://api.star-history.com/svg?repos=sepinetam/stata-mcp&type=Date)](https://www.star-history.com/#sepinetam/stata-mcp&Date)
