World Monitor
Real-time global intelligence on conflict, markets, energy, trade, shipping and cyber. 100 tools.
通过 pystata 驱动真实 Stata 的 MCP 服务器:数据加载/清洗/建模/诊断/图形导出,75 个工具覆盖完整计量工作流。
Lists are ordered by a usage score (out of 100) built from these parts
| Popularity | 0/80 | GitHub stars or weekly downloads: the larger counts 60, the smaller 20 |
|---|---|---|
| Freshness | 7/12 | Full marks for a release or code change within 30 days |
| Still answering | 0/8 | The cloud endpoint answered at the last check |
| Usage score | 7/100 |
Quality: Passed 3/3 basic checks (shown, not used for ordering) · Momentum: No data yet (Used only on the Trending tab)
Pick the AI app you use, then copy the settings.
Let your AI install it with one sentence
Please install Stata MCP Server. Follow https://mcp.popnx.com/i/aliveranme-stata-mcp.md, show me the commands and wait for my OK before running them.Paste it into an AI that can work on your computer (such as Claude Code or Cursor). It reads our steps, shows you the commands and waits for your OK. No key, no sign-up. · See the full text your AI reads
Passed 3/3 checks · Runs on your computer · ✓ Commands checked Nov 14, 2026
First: which AI do you use?
Pick your app and the steps appear below.
Works with Claude, with some setup first
1 setting(s) to fill in (STATA_HOME) · Install Node.js on your computer first (one time) · Only the Claude desktop app (Windows or Mac), not the web or phone
Copy this message into a Claude chat. The AI checks your computer, tells you which file it will change, and waits for your OK every time.
Please install the MCP server Stata MCP Server for Claude on this computer, in this order: 1) Check Node.js with node -v. If it is missing, tell me to install it from https://nodejs.org/en/download; do not install it yourself. 2) Use only this config (already checked by PopNx MCP): { "mcpServers": { "stata": { "command": "npx", "args": [ "-y", "@aliveranme/stata-mcp" ], "env": { "STATA_HOME": "your-value" } } } } 3) Tell me the full path of the file you will change, or the command you will run, and wait for my OK. 4) For STATA_HOME, leave "your-value" in place and tell me to paste the real value myself into the file or the app’s field. Never ask me to type a key in chat. 5) Do what we agreed, then check that the Stata MCP Server tools really show up.This message has no key in it. If a key is needed, the AI will ask you to paste it yourself into the file or the app’s field.
Already installed? Check first · Open Terminal, type this command and press Enter
node -vMac: press ⌘ + Space, type Terminal, press Enter
Windows: open Start, type Windows PowerShell, then Open
Not installed: Open the official download page, pick the LTS version and the click-through installer: .pkg on Mac · .msi on Windows. Double-click and follow it to the end. No curl command needed
Open the Node.js download page ↗
When it’s done, close Terminal, open it again and run the same command. You should see a version number: node -v
Install once; it works for everything that needs Node.js
These are program settings, not keys. No sign-up needed; fill them in as the maker describes.
STATA_HOME Stata 安装目录(含 utilities/pystata),如 /Applications/StataNowDescriptions are as written by the maker.
SettingsDeveloperEdit Config
{
"mcpServers": {
"stata": {
"command": "npx",
"args": [
"-y",
"@aliveranme/stata-mcp"
],
"env": {
"STATA_HOME": "your-value"
}
}
}
}Use Stata MCP Server and tell me what you can do for me, then show me one thing✓ If Claude says it is using Stata MCP Server or shows a Stata MCP Server tool in the answer, you are connected
The command above works without these. Add them only if you want to change something, following the maker’s description.
STATA_EDITION Stata 版本 mp|se|be · default mpSTATA_ALLOWED_ROOTS 路径沙箱白名单(分号分隔);可选Descriptions are as written by the maker.
Menu names checked against Anthropic’s help page on Nov 11, 2026 · your screen may differ slightly by app version
ChatGPT cannot connect Stata MCP Server yet
Stata MCP Server runs on your computer, but ChatGPT can only connect servers that run on the web
A · Use an app that can connect Stata MCP Server
B · Others in Other that work with ChatGPT
Picked from the most used in the same category, only ones that connect by address with no key
Works with Claude Code, with some setup first
1 setting(s) to fill in (STATA_HOME) · Install Node.js on your computer first (one time)
Copy this message into a Claude Code chat. The AI checks your computer, tells you which file it will change, and waits for your OK every time.
Please install the MCP server Stata MCP Server for Claude Code on this computer, in this order: 1) Check Node.js with node -v. If it is missing, tell me to install it from https://nodejs.org/en/download; do not install it yourself. 2) Use only this config (already checked by PopNx MCP): claude mcp add --scope user stata --env STATA_HOME=your-value -- npx -y @aliveranme/stata-mcp 3) Tell me the full path of the file you will change, or the command you will run, and wait for my OK. 4) For STATA_HOME, leave "your-value" in place and tell me to paste the real value myself into the file or the app’s field. Never ask me to type a key in chat. 5) Do what we agreed, then check that the Stata MCP Server tools really show up.This message has no key in it. If a key is needed, the AI will ask you to paste it yourself into the file or the app’s field.
Already installed? Check first · Open Terminal, type this command and press Enter
node -vMac: press ⌘ + Space, type Terminal, press Enter
Windows: open Start, type Windows PowerShell, then Open
Not installed: Open the official download page, pick the LTS version and the click-through installer: .pkg on Mac · .msi on Windows. Double-click and follow it to the end. No curl command needed
Open the Node.js download page ↗
When it’s done, close Terminal, open it again and run the same command. You should see a version number: node -v
Install once; it works for everything that needs Node.js
These are program settings, not keys. No sign-up needed; fill them in as the maker describes.
STATA_HOME Stata 安装目录(含 utilities/pystata),如 /Applications/StataNowDescriptions are as written by the maker.
Mac: press Command+Space and type Terminal · Windows: open PowerShell
claude mcp add --scope user stata --env STATA_HOME=your-value -- npx -y @aliveranme/stata-mcpYou should see Stata MCP Server listed as connected
Use Stata MCP Server and tell me what you can do for me, then show me one thing✓ If Claude Code says it is using Stata MCP Server or shows a Stata MCP Server tool in the answer, you are connected
The command above works without these. Add them only if you want to change something, following the maker’s description.
STATA_EDITION Stata 版本 mp|se|be · default mpSTATA_ALLOWED_ROOTS 路径沙箱白名单(分号分隔);可选Descriptions are as written by the maker.
Menu names checked against Anthropic’s help page on Nov 11, 2026 · your screen may differ slightly by app version
Works with Cursor, with some setup first
1 setting(s) to fill in (STATA_HOME) · Install Node.js on your computer first (one time)
Copy this message into a Cursor chat. The AI checks your computer, tells you which file it will change, and waits for your OK every time.
Please install the MCP server Stata MCP Server for Cursor on this computer, in this order: 1) Check Node.js with node -v. If it is missing, tell me to install it from https://nodejs.org/en/download; do not install it yourself. 2) Use only this config (already checked by PopNx MCP): { "mcpServers": { "stata": { "command": "npx", "args": [ "-y", "@aliveranme/stata-mcp" ], "env": { "STATA_HOME": "your-value" } } } } 3) Tell me the full path of the file you will change, or the command you will run, and wait for my OK. 4) For STATA_HOME, leave "your-value" in place and tell me to paste the real value myself into the file or the app’s field. Never ask me to type a key in chat. 5) Do what we agreed, then check that the Stata MCP Server tools really show up.This message has no key in it. If a key is needed, the AI will ask you to paste it yourself into the file or the app’s field.
Already installed? Check first · Open Terminal, type this command and press Enter
node -vMac: press ⌘ + Space, type Terminal, press Enter
Windows: open Start, type Windows PowerShell, then Open
Not installed: Open the official download page, pick the LTS version and the click-through installer: .pkg on Mac · .msi on Windows. Double-click and follow it to the end. No curl command needed
Open the Node.js download page ↗
When it’s done, close Terminal, open it again and run the same command. You should see a version number: node -v
Install once; it works for everything that needs Node.js
These are program settings, not keys. No sign-up needed; fill them in as the maker describes.
STATA_HOME Stata 安装目录(含 utilities/pystata),如 /Applications/StataNowDescriptions are as written by the maker.
In the Stata MCP Server settings, STATA_HOME is empty; add your key and save
Use Stata MCP Server and tell me what you can do for me, then show me one thing✓ If Cursor says it is using Stata MCP Server or shows a Stata MCP Server tool in the answer, you are connected
The command above works without these. Add them only if you want to change something, following the maker’s description.
STATA_EDITION Stata 版本 mp|se|be · default mpSTATA_ALLOWED_ROOTS 路径沙箱白名单(分号分隔);可选Descriptions are as written by the maker.
Menu names checked against Cursor’s help page on Nov 11, 2026 · your screen may differ slightly by app version
Works with VS Code, with some setup first
1 setting(s) to fill in (STATA_HOME) · Install Node.js on your computer first (one time)
Copy this message into a VS Code chat. The AI checks your computer, tells you which file it will change, and waits for your OK every time.
Please install the MCP server Stata MCP Server for VS Code on this computer, in this order: 1) Check Node.js with node -v. If it is missing, tell me to install it from https://nodejs.org/en/download; do not install it yourself. 2) Use only this config (already checked by PopNx MCP): { "servers": { "stata": { "type": "stdio", "command": "npx", "args": [ "-y", "@aliveranme/stata-mcp" ], "env": { "STATA_HOME": "your-value" } } } } 3) Tell me the full path of the file you will change, or the command you will run, and wait for my OK. 4) For STATA_HOME, leave "your-value" in place and tell me to paste the real value myself into the file or the app’s field. Never ask me to type a key in chat. 5) Do what we agreed, then check that the Stata MCP Server tools really show up.This message has no key in it. If a key is needed, the AI will ask you to paste it yourself into the file or the app’s field.
Already installed? Check first · Open Terminal, type this command and press Enter
node -vMac: press ⌘ + Space, type Terminal, press Enter
Windows: open Start, type Windows PowerShell, then Open
Not installed: Open the official download page, pick the LTS version and the click-through installer: .pkg on Mac · .msi on Windows. Double-click and follow it to the end. No curl command needed
Open the Node.js download page ↗
When it’s done, close Terminal, open it again and run the same command. You should see a version number: node -v
Install once; it works for everything that needs Node.js
These are program settings, not keys. No sign-up needed; fill them in as the maker describes.
STATA_HOME Stata 安装目录(含 utilities/pystata),如 /Applications/StataNowDescriptions are as written by the maker.
In the Stata MCP Server settings, STATA_HOME is empty; add your key and save
Use Stata MCP Server and tell me what you can do for me, then show me one thing✓ If VS Code says it is using Stata MCP Server or shows a Stata MCP Server tool in the answer, you are connected
The command above works without these. Add them only if you want to change something, following the maker’s description.
STATA_EDITION Stata 版本 mp|se|be · default mpSTATA_ALLOWED_ROOTS 路径沙箱白名单(分号分隔);可选Descriptions are as written by the maker.
Menu names checked against VS Code’s help page on Nov 11, 2026 · your screen may differ slightly by app version
Other apps that use MCP, such as Windsurf, Zed or Gemini CLI, each add servers differently. See how in the app list.
JSON settings are under “For developers” below
Claude Code
claude mcp add --scope user stata --env STATA_HOME=your-value -- npx -y @aliveranme/stata-mcpClaude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"stata": {
"command": "npx",
"args": [
"-y",
"@aliveranme/stata-mcp"
],
"env": {
"STATA_HOME": "your-value"
}
}
}
}Cursor (~/.cursor/mcp.json)
{
"mcpServers": {
"stata": {
"command": "npx",
"args": [
"-y",
"@aliveranme/stata-mcp"
],
"env": {
"STATA_HOME": "your-value"
}
}
}
}VS Code (mcp.json)
{
"servers": {
"stata": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@aliveranme/stata-mcp"
],
"env": {
"STATA_HOME": "your-value"
}
}
}
}STATA_HOME required envSTATA_EDITION envSTATA_ALLOWED_ROOTS envDescriptions are as written by the maker.
These settings are generated from the maker’s registry entry. If the README says otherwise, follow the README.
Based on how this server connects and on each app’s own docs, checked Nov 10, 2026.
Run on your computer in
ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast
Runs on your computer; the tool list appears in your AI app after you install it.
We check information anyone can see; we have not read the code. Checks that do not apply are left out of the count. · Checked Nov 19, 2026
The registry name was verified with the GitHub account aliveranme, which owns the repo
Code last changed 3 months ago
Uses MIT
This one runs on your computer; there is no internet endpoint
Runs on your computer and uses local settings instead
Runs on your computer; we can only read tool lists from internet endpoints
No entries on OSV.dev for @aliveranme/stata-mcp@1.0.10
Checks only this package version, not every dependency · checked Nov 16, 2026
If you made this, paste this code into your README. The badge links back to this page.
[](https://mcp.popnx.com/en/servers/aliveranme-stata-mcp)Ask, share a tip or report that it does not work. Sorted by what people marked helpful.
No posts yet. Be the first to ask or share.
Posts here are written by users, not the PopNx team.
No reviews yet
Compared with every active server in this category in the registry. Stars count only when the publisher owns the repo.
It passed 3 of 3 applicable basic checks. We have not read the code. Before adding a key or token, see what access the server asks for and use a key with only the permissions you need.
The registry does not list a required key, though some servers ask you to sign in on first use.
It runs on your computer. Your AI app starts it when needed, and data does not pass through the maker’s servers (unless it calls an online service itself).
The GitHub repo last changed 3 months ago, and the latest version (1.0.10) reached the registry 3 months ago.
Apps that support MCP, such as Claude Desktop, Claude Code, Cursor and VS Code. You also need Node.js on your computer.
In the same category: World Monitor, openstatus, Oh My Posh Validator, Strata, Jitsu
Same category, other makers, commands already checked. Official ones first, then by stars.
Reading a card:↓ Downloads per weeki★ GitHub starsiThree pillars: reviews · checks · usageiUpdated = latest version published to the registryi
Real-time global intelligence on conflict, markets, energy, trade, shipping and cyber. 100 tools.
Manage monitors, status pages, incidents and maintenances in your openstatus workspace.
Validate oh-my-posh configurations and segment snippets against the official schema.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Manage Jitsu data pipelines: destinations, streams, connections, functions, live events.
| This one Stata MCP Server | World Monitor | openstatus | Oh My Posh Validator | Strata | Jitsu | |
|---|---|---|---|---|---|---|
| Runs where | Installs on your computer | Runs in the cloud, nothing to install | Runs in the cloud, nothing to install | Runs in the cloud, nothing to install | Runs in the cloud, nothing to install | Runs in the cloud, nothing to install |
| Needs a key | No | No | No | No | No | No |
| Add with + in Claude | No | No | No | No | No | No |
| Basic checks | 3/3 | 4/4 | 4/4 | 4/4 | 1/4 | 4/4 |
| License | MIT | AGPL-3.0 | AGPL-3.0 | MIT | Apache-2.0 | MIT |
| Price | No cost listed in the registry | No cost listed in the registry | No cost listed in the registry | No cost listed in the registry | No cost listed in the registry | No cost listed in the registry |
Copied from the maker’s repo as written. PopNx MCP has not reviewed or endorsed it. HTML, images and scripts are removed. Links lead off this site.
在 Claude Code 里用自然语言做 Stata 分析。你描述要什么,Agent 自己写命令、执行、 读结果、继续下一步 —— 加载数据、清洗、建模、诊断、导出,全在一个持久的 Stata 会话里完成,数据不用反复载入。
你: 加载 auto.dta,用 weight 和 mpg 回归 price,并检查异方差
Agent 自动完成(无需你写任何 Stata 命令):
stata_use_dataset("auto.dta") → 74 obs, 12 vars 已载入
stata_regress("price", "weight mpg") → R² = 0.293 ; weight 1.75 (p=0.008) stata_run("estat hettest") → Breusch–Pagan χ² 检验异方差 stata_graph("rvfplot", export="…png") → 残差图导出为文件
数据从第一步起就留在内存里,后面每一步都接着用 —— 这正是 stata_run("regress …") 之外还值得有一个 MCP Server 的原因。
两部分组成,一起装进 Claude Code:
pystata 直接调用 Stata 的运行时,把 75 个工具 暴露给 Agent。stata_run 执行任意命令、stata_help 查任意命令的官方语法,二者 合起来即「全量内置命令支持」;其余专用工具(回归 / 面板 / IV / 生成变量 / 数据 清洗 / 后估计 / 文件资源 / 后台任务 …)是给高频命令加结构化参数与校验的便利层。pystata 通过 ctypes 在进程内加载 Stata 运行时,而非每条命令起一个子进程:
stata_more 翻页), 硬上限 120K 字符防止撑爆 MCP 通道;长命令有 60s 超时看门狗(可显式调大)。utilities/pystatagit clone https://gitea.aliveranme.space/aliveranme/stata-mcp.git
cd stata-mcp python setup.py
装在非标准位置(如外置卷
/Volumes/xxx/Applications/StataNow)时自动检测会失败 ——
先
export STATA_HOME=/你的/Stata路径再跑setup.py即可。
setup.py 会:检测 Stata 安装(常见路径 + STATA_HOME 环境变量,跨平台)→ 创建虚拟环境并安装 fastmcp → 生成 .mcp.json(保留你已有的其他 MCP Server 配置) → 验证 Server 可启动。
手动安装(自动检测失败时)
# 1. 指定 Stata 路径(替换为你本机实际路径)
export STATA_HOME="C:/Program Files/StataNow/StataNow19" # Windows
export STATA_EDITION=mp # mp / se / be
cd mcp-stata-server uv venv source .venv/Scripts/activate # Windows Git Bash
uv pip install "fastmcp>=3.2.0"
cd .. cp .mcp.json.example .mcp.json # 编辑其中的
</details>
若你已有 Node.js ≥ 18 与 uv(无 uv 时需 Python 3.10+ 且已装 fastmcp>=3.2.0),可直接使用已发布的 npm 包 @aliveranme/stata-mcp:
export STATA_HOME="/你的/Stata路径" # 含 utilities/pystata
export STATA_EDITION=mp
npx -y @aliveranme/stata-mcp
Claude Code .mcp.json 配置:
{
"mcpServers": { "stata": { "command": "npx", "args": ["-y", "@aliveranme/stata-mcp"], "env": { "STATA_HOME": "/Applications/StataNow", "STATA_EDITION": "mp" } } } }
npx @aliveranme/stata-mcp与npx stata-mcp-server(bin 名)等价,二者都触发同一个启动器。
重启 Claude Code(或 /reload-plugins),.mcp.json 里的 stata Server 会自动连接。 然后在对话里直接说:
帮我加载 auto.dta 并做描述统计
Agent 会自动走 stata_use_dataset → stata_describe → stata_summarize。
除 Claude Code 外,本 MCP 可接入所有支持 MCP 的客户端/Agent。逐平台教程见 docs/agent-setup/:
| Agent / 客户端 | 配置位置 | 教程 |
|---|---|---|
| Claude Code | .mcp.json / claude mcp add | claude-code.md |
| Claude Desktop | claude_desktop_config.json | claude-desktop.md |
| Cursor | .cursor/mcp.json | cursor.md |
| Cline / Roo Code / Continue / Zed / Windsurf | 通用 mcpServers schema(Zed 用 context_servers) | other-clients.md |
插件 / 扩展市场分发(Claude Code 插件、Cursor 扩展、Claude Desktop
.mcpb)的可行性
能力边界不在工具数量上:
stata_run+stata_help已覆盖全部内置命令。下面的
专用工具是给高频命令加结构化参数与校验的便利层。
| 类别 | 工具 |
|---|---|
| 核心执行 | stata_run(任意命令,含危险前缀拦截;save_output= 完整输出落盘并登记为资源)· stata_run_do_file(执行前自动拆出 ssc install 单独安装,已装跳过) |
| 数据管理 | stata_use_dataset · stata_import(excel/csv/sas/spss/dbase/parquet)· stata_use_example(sysuse/webuse)· stata_save_dataset · stata_set_cwd · stata_generate · stata_egen · stata_xtset(面板/时序声明) |
| 数据重构 / 校验 | stata_merge · stata_append · stata_reshape · stata_collapse · stata_frame(多数据集)· stata_verify(count/assert/duplicates/isid/missing)· stata_replace · stata_drop · stata_keep · stata_rename · stata_recode · stata_destring |
| 数据探索 | stata_describe · stata_codebook · stata_summarize · stata_list · stata_tabulate · stata_correlate · stata_display |
| 估计 | stata_regress · stata_logistic · stata_probit · stata_poisson · stata_ttest · stata_xtreg · stata_ivregress · stata_logit · stata_mlogit · stata_nbreg · stata_qreg · stata_mixed |
| 后估计 | stata_margins · stata_test · stata_predict · stata_estat(vif/hettest/ovtest/ic)· stata_estimates(存取与并排比较)· stata_lincom · stata_nlcom · stata_hausman · stata_return_list |
| 图形 / 导出 | stata_graph(导出即验证文件写入)· stata_scheme(主题)· stata_export_excel · stata_export_delimited · stata_etable(回归表直出 Word/Excel) |
| 文件资源回传 | stata_list_resources · stata_read_file(info/base64)· stata_register_file —— 导出产物经资源协议(resources/read 读 stata-file:///)取回二进制 |
| 包管理与帮助 | stata_help(查任意命令帮助)· stata_install_package · stata_uninstall_package · stata_describe_package · stata_find_package · stata_list_packages |
| 会话生命周期 | stata_clear(scope 重置)· stata_snapshot(save/list/restore/erase)· stata_more(翻页)· stata_status · stata_ping |
| 长任务控制 | stata_background(后台执行,单块上限 3600s)· stata_task_status · stata_task_cancel · stata_task_result · stata_task_list |
| 服务器日志 | stata_read_log(tail/path) |
各工具的参数与说明
数据管理 — stata_use_dataset 加载 .dta(可只载入子集);stata_import 覆盖官方 import 命令族,按扩展名推断格式;stata_save_dataset 保存;stata_set_cwd 改工作目录; stata_generate / stata_egen 创建变量(支持官方 [type] 存储类型与 [if] [in]); stata_xtset 声明面板 / 时序结构 —— 它是 stata_xtreg 的前提。
数据探索 — stata_summarize / stata_codebook / stata_list / stata_tabulate 均支持 condition;stata_correlate 可选 pairwise 走 pwcorr;stata_display 算表达式 / 看返回值。
估计 — stata_regress(OLS)、stata_logistic、stata_probit(可选 marginal_effects)、stata_poisson(可选 irr)、stata_ttest(可按组)、 stata_xtreg(effects = fe/re/be/mle/pa,需先 xtset)、stata_ivregress (2sls/liml/gmm)。扩展族:stata_logit(报告原始系数,OR 用 logistic)、 stata_mlogit(多分类,baseoutcome 定基准)、stata_nbreg(负二项)、 stata_qreg(分位,quantile 默认 0.5)、stata_mixed(多水平,random="|| id:")。
数据清洗 — stata_replace 覆盖变量值、stata_drop/stata_keep 删/留变量或观测 (两种形态二选一)、stata_rename 重命名(单个或批量)、stata_recode 重编码 (values="(1=0) (2/4=1)" 官方规则组)、stata_destring 字符串转数值(必须 replace=True 或 generate())。
后估计(须先跑估计命令)— stata_margins(dydx / at)、stata_test (Wald 检验)、stata_predict(预测值 / 残差,会创建变量)、stata_lincom / stata_nlcom(线性 / 非线性组合检验)、stata_hausman(模型比较,需先 stata_estimates action="store" 存两个模型)。
图形 / 导出 — stata_graph 把 graph 与 export 原子执行,以文件是否真被写入判定 成败。导出选项按格式自动适配官方边界:尺寸单位(位图与 svg 用像素、pdf 用英寸、 eps/ps/emf 不支持)、quality(仅 jpg)、mag(仅 pdf/eps/ps)、fontface (仅矢量格式)—— 不适用的选项被丢弃并在返回信息中说明,而非让 Stata 静默失败。 stata_scheme 列出 / 查询 / 设置主题(不传 scheme 时不会改动你当前的主题)。 stata_export_excel 导数据为 .xlsx(支持 sheet_mode / cell / firstrow / if-in 筛选);stata_export_delimited 导 CSV / TSV / 自定义分隔符。 回归表用 stata_etable(官方 etable,Stata 17+,无第三方依赖): estimates="m1 m2 m3" 并排多模型,直出 .docx / .xlsx / .pdf / .tex / .html / .md, 并以文件是否真被写入判定成败 —— etable 会先把表打印出来再报导出错误,只看输出 很容易把失败当成功。
包管理与帮助 — stata_help("命令") 查任意内置 / 已装外置命令的官方语法; stata_find_package 走 net search 联网找包;stata_install_package 装(ssc 或 URL); stata_uninstall_package 卸载(ado uninstall,纯本地);stata_describe_package 查包详情(默认本地 ado describe,source="ssc" 走联网 ssc describe 供装前了解); stata_list_packages 列已装。
会话 — stata_more 翻上一条命令的完整输出;stata_status 一次给出数据集、工作目录、 frame、面板/时序设定、已存与活跃的估计结果、内存 —— 即 Agent 调 xtreg / margins / predict 前需要确认的全部前提;stata_ping 心跳。stata_clear 按 scope 重置会话(data/estimates/graphs/panels/all);stata_snapshot 用 Stata 原生快照在数据 阶段间快速回退(save/list/restore/erase)。
文件资源回传 — 导出工具(stata_graph / stata_export_* / stata_etable / stata_save_dataset / stata_run save_output=)成功后把文件登记为 MCP 资源。远程 客户端经 resources/read 读 stata-file:///<路径> 取回图表 / Excel / CSV / dta 的 二进制,或 stata_read_file 取 base64 / 元信息;stata_list_resources 列出全部登记 文件,stata_register_file 登记已有的磁盘文件。安全边界:只读登记过的文件。
长任务控制 — stata_background 把耗时长命令放到后台(立即返回任务号,单块超时 上限 3600s,运行期间其他调用会等待共享的 _stata_lock);stata_task_status 查进度、 stata_task_cancel 显式取消、stata_task_result 取结果、stata_task_list 列全部。 stata_read_log 读本服务器运行日志排查问题。
.claude/skills/stata/SKILL.md 是 Agent 的 Stata 编程参考:
| 模块 | 内容 |
|---|---|
| 核心原则 | 分析前先探数据、变量名大小写、路径规范、返回值检查 |
| 语法要点 | 命令结构、if 条件陷阱、因子变量、循环与条件块、egen 函数 |
| 命令地图 | 3500+ 内置命令按族归类,语法一律指向 stata_help |
| 分析模板 | 数据探索、OLS / Logit、面板、工具变量、DID —— 均经真实 Stata 验证 |
| 外置命令表 | reghdfe / ivreg2 / estout / coefplot / did / rdrobust … 按计量方向组织 |
| 常见陷阱 | 变量名冲突、缺失值、字符串转换、路径、do 文件 |
| 组件 | 要求 |
|---|---|
| Stata | StataNow 19 / Stata 18(MP / SE / BE),需含 utilities/pystata |
| Python | 3.10+ |
| Claude Code | 最新版(支持 MCP stdio) |
| 操作系统 | Windows、macOS(setup.py 跨平台检测;Linux 亦受 setup.py 支持但未实测) |
pystata是 Stata 官方的 Python 集成,随 Stata 一同分发,Windows / macOS / Linux
均提供。本项目在 Windows 与 macOS(StataNow 19.5 MP)上均实测可用。
环境变量
| 变量 | 默认值 | 说明 |
|---|---|---|
STATA_HOME | C:\Program Files\StataNow\StataNow19 | Stata 安装目录。环境变量优先级最高;未设置时由 setup.py 自动检测。 |
STATA_EDITION | mp | Stata 版本(mp / se / be) |
STATA_ALLOWED_ROOTS | 未设置 | 路径沙箱白名单,分号分隔(例 C:/data;D:/projects)。两重限制:未设置时不限制绝对路径;设置后既校验工具的路径参数,也审计 stata_run / stata_run_do_file / stata_background 自由文本命令里的引号路径(use "越界路径" 同样被拒)。宏路径 fail-open,未配置白名单时不启用。 |
STATA_ALLOW_UNC | 未设置 | 设为 1 允许 UNC 网络路径,默认拒绝。 |
JAVA_TOOL_OPTIONS | 自动追加 -Djava.awt.headless=true | MCP 无 GUI 会话时自动启用 Java headless,避免图形导出触发 AWT 渲染错误。若已显式设置 -Djava.awt.headless=true/false,则保留原值。 |
开发 / 调试
# 调试模式启动 Server
cd mcp-stata-server source .venv/bin/activate # 或 .venv/Scripts/activate (Windows) python server.py
python -m pytest tests/ -q
STATA_HOME=/path/to/StataNow python -m pytest tests_e2e/ -q
#