Stata Econ MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Stata Econ MCP
让 Claude(Claude Desktop 聊天 / Claude Code)直接驱动你本机的 Stata 跑回归。
使用 Stata 官方自带的 pystata 引擎(
<Stata 安装目录>/utilities/pystata),用的是你自己的 Stata、许可证和已安装的外部命令(reghdfe、csdid 等)。Stata 跑在独立子进程里,会话常驻:数据、
estimates store、locals 在调用之间保留;卡死可stata_restart。内置应用计量知识包(面板 FE / DID / 错时 DID / DDD / 事件研究 / LaTeX 表 / 审稿标准),Claude 通过
stata_guide读取。
环境要求
Stata 17 或更高(MP / SE / BE),已在本机安装并激活许可证
uv(或 Python 3.11+)
已在 macOS (Apple Silicon) + Stata 18 MP 上测试;Linux / Windows 理论可用但未测试,需要设置
STATA_DIR
Related MCP server: io.github.aliveranme/stata-mcp
安装
git clone https://github.com/shanyuzhang/stata-econ-mcp.git
cd stata-econ-mcp
uv sync可执行文件位于 <仓库路径>/.venv/bin/stata-econ-mcp(下文记为 <SERVER>,请填绝对路径)。
接入 Claude Code
claude mcp add stata --scope user -- "<SERVER>"接入 Claude Desktop
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json(Windows:%APPDATA%\Claude\claude_desktop_config.json),在 mcpServers 中加入:
{
"mcpServers": {
"stata": {
"command": "<SERVER>",
"args": []
}
}
}保存后完全退出并重新打开 Claude Desktop。
如果 Stata 不在默认位置(macOS 默认搜索 /Applications/Stata、/Applications/StataNow 等),在配置里加环境变量:
"env": { "STATA_DIR": "/path/to/Stata", "STATA_EDITION": "mp" }工具
工具 | 作用 |
| 执行一段代码(快速检查) |
| 存成 do 文件并执行,带 log(正式分析用) |
| 长任务继续等待 / 重启 Stata |
| 数据概览、describe、summarize、xtdescribe、缺失值等 |
| 结构化读取系数、SE、p 值、N、聚类数、FE |
| esttab 生成 booktabs LaTeX 回归表 |
| 导出图(PNG 在对话中显示 + PDF 给 LaTeX) |
| 读官方 / 外部命令的帮助文件 |
| 计量知识包 |
| 状态与已装包检查 / 切换项目文件夹 |
输出位置
<项目文件夹>/stata_output/{do,logs,tables,figures}
Claude Code(或 Desktop 的 Code 页签):项目文件夹 = 会话所在文件夹。
Desktop 普通聊天(没有文件夹):默认
~/Documents/Stata研究/;也可以直接告诉 Claude "项目放在某某目录",它会调用stata_set_workdir。每条命令都会追加到
logs/history_<日期>.do,便于复现。
环境变量(可选)
变量 | 默认值 |
| 自动搜索 |
| 按安装目录自动判断(mp / se / be) |
| 自动(会话文件夹 → 默认目录) |
|
|
|
|
|
|
推荐安装的 Stata 外部命令
ssc install reghdfe
ssc install ftools
ssc install estout
ssc install coefplot
ssc install csdid
ssc install drdid
ssc install did_imputation
ssc install eventstudyinteract
ssc install event_plot
ssc install bootteststata_status 会列出哪些已安装。
已知事项
如果你的
profile.do含有只在图形界面下可用的命令(如window menu),无界面模式下它会中途停止;服务器启动后会补设more off、type double、maxvar、linesize。Stata 内嵌 Python 不支持带空格的解释器路径;若仓库放在带空格的目录下,worker 会自动创建无空格的软链接(
~/.cache/stata-econ-mcp/python)绕过。安全约束(不执行
shell/!、不删除用户文件、安装外部命令前先询问)只通过给 Claude 的指令实现,代码层面没有强制拦截;它运行的是你本机的完整 Stata,请只在信任的客户端中使用。
许可证
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
A statistical analyst in your AI chat: bring data and a question, get a citable, re-runnable report.
Work on your own computers from Claude or ChatGPT: run commands, edit and search files.
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
Chief of Staff, strategy and writing tools that give your Claude subscription structure and memory.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceConnects AI agents to a local Stata installation, enabling execution of Stata code, data inspection, graph generation, and result verification through natural language interactions.546 PyPI92AGPL 3.0
- AlicenseNot gradedqualityBmaintenanceMCP server that enables Claude to directly drive Stata, providing a persistent session and 75 tools for data management, estimation, post-estimation, graphs, and export. It lets users perform full Stata analyses through natural language instructions.MIT
- AlicenseCqualityDmaintenanceProvides project-local, reproducible Stata execution for humans and AI agents, with immutable run artifacts, provenance tracking, planning gates, and a shared dashboard.22AGPL 3.0
- AlicenseAqualityBmaintenanceEnables LLM/agent applications to execute Stata code, load and inspect data, obtain structured regression results and graphs, and manage background tasks through the Model Context Protocol.10MIT