stata-mcp: Instructions file for Claude Code

CLAUDE.md

stata-mcp CLAUDE.md is an instructions file for Claude Code from aliveranme/stata-mcp. It costs 24,127 tokens per session, scanned A, original, MIT.

Project instructions for connecting a coding agent to Stata, a program used for statistical data analysis, through an MCP server.

In plain words
What is it for?
Loading and cleaning data, running Stata commands, estimating models, checking command syntax, and exporting results.
Why use it?
They give the agent the Stata rules and command structure it needs, while keeping data available across related commands.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions Claude Code.

This is aliveranme/stata-mcp's own configuration. It tells Claude Code how to work on stata-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything stata-mcp configures →

Not installable: its command points at a path on the author’s own machine, so it runs nowhere else. The line is /Users/x/My.

Reuse

Borrowing it

Nothing to install: this file belongs to aliveranme/stata-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/aliveranme/stata-mcp/master/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/aliveranme/stata-mcp

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for stata-mcp CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/aliveranme/stata-mcp/claude-md/github.svg)](https://agentmods.dev/instructions/aliveranme/stata-mcp/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/aliveranme/stata-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/aliveranme/stata-mcp/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for stata-mcp CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/aliveranme/stata-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/aliveranme/stata-mcp/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 24,127 This file is loaded in full into every session.
When invoked 24,127 The same file — it is already loaded in full.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.24127 $0.24127
Opus 5 $0.12063 $0.12063
Sonnet 5 $0.04825 $0.04825
Haiku 4.5 $0.02413 $0.02413

Measured 9d ago against content hash 9de1d1502d62, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

stata-mcp CLAUDE.md scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

| 慢网络下 `setup.py` 裸 traceback 退出 | 五处 `subprocess.run` 都传了 timeout 却无一捕获 `TimeoutExpired`(它继承自 Exception 而非 OSError) | `install_deps` 捕获并给出重试与手动安装命令;uv 路径超时改走 pip 回退 |
CLAUDE.md · 592 lines

How it starts

The opening of the file, as written. The whole thing — 592 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Stata MCP Server

让 Claude Code Agent 通过 MCP Server 直接驱动 Stata,自动完成数据加载、清洗、建模、结果导出全流程。

架构

stata-mcp/
├── mcp-stata-server/server.py       # MCP 执行层:75 个工具,通过 pystata 调用 Stata DLL
├── mcp-stata-server/tool_modules/   # 便利工具模块(数据重构/扩展估计/后估计),register() 装配
├── .claude/skills/stata/SKILL.md    # 知识层:Stata 语法、模板、陷阱、Agent 协作规范
├── setup.py                         # 安装层:检测 Stata、创建 venv、生成 .mcp.json
├── .gitignore                       # 忽略 .mcp.json(生成) .venv dta/log/smcl

关键链路Claude + SKILL.md → 调用 MCP 工具 → server.py → pystata → Stata DLL

会话持久:Stata 在 MCP Server 启动时初始化一次,所有工具调用共享同一会话,数据跨调用保持。

命令

命令 说明
python setup.py 一键安装(检测 Stata → venv → fastmcp → .mcp.json → 验证)
cd mcp-stata-server && source .venv/Scripts/activate && python server.py 调试模式启动
uv pip install fastmcp && uv pip freeze > requirements.txt 添加新依赖

MCP 工具(75 个)

能力边界不在工具数上stata_run 执行任意命令、stata_help 查任意命令的 官方语法,二者即「全量内置命令支持」。专用工具(回归/面板/IV/生成变量等)是 给高频命令加结构化参数与校验的便利层,不是能力上限。

类别 工具 只读? 说明
核心执行 stata_run, stata_run_do_file 通用命令执行;run_do_file 执行前自动拆出 ssc install 单独安装(已装跳过)。stata_run 另有 save_output:完整输出(不受 120K 裁剪)落盘并登记为文件资源
数据管理 stata_use_dataset, stata_import, stata_save_dataset, stata_set_cwd 读写 .dta、cd;stata_import 覆盖官方 import 族(excel/delimited/sas/spss/dbase/parquet,按扩展名推断)。save_dataset 成功后自动登记为资源
面板/时序 stata_xtset 声明/查询/清除 xtset(面板) 与 tsset(纯时序) —— 是 stata_xtreg 的前提
示例数据 stata_use_example sysuse(本地) / webuse(联网) 加载官方示例数据集;action="list" 列出可用
数据生成 stata_generate, stata_egen 创建变量(改数据集,非只读);支持官方 [type] 存储类型与 [if] [in]
数据重构 stata_merge, stata_append, stata_reshape, stata_collapse, stata_frame, stata_replace, stata_drop, stata_keep, stata_rename, stata_recode, stata_destring 横向合并(1:1/m:1/1:m/m:m)、纵向追加(可多文件)、长宽转换、按组聚合、多数据集 frame;后六个是变量级清洗:replace/recode 覆盖原变量,drop/keep 支持「删变量」或「删观测」两种形态(二选一),destring 强制 replacegenerate() 二选一
数据校验 stata_verify count/assert/duplicates/isid/missing 五合一(missing 走 misstable summarize
数据探索 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 OLS/Logit/Probit/Poisson/t 检验/面板/IV + 扩展族:logit(原始系数,logistic 是 OR)、mlogit 多分类、nbreg 负二项、qreg 分位(quantile 默认 0.5)、mixed 多水平(random|| 开头)
后估计 stata_margins, stata_test, stata_predict, stata_estat, stata_estimates, stata_lincom, stata_nlcom, stata_hausman ✓* 边际效应/Wald 检验/预测(stata_predict 会创建变量,非只读);stata_estat 诊断(vif/hettest/ovtest/ic);stata_estimates 存取与并排比较模型;lincom 线性组合、nlcom 非线性组合(delta 法)、hausman 模型比较(需先 estimates store 两个模型)
返回值 stata_return_list 一次列出 r()/e()/c() 全部返回值,不必逐个 display
图形 stata_graph, stata_scheme — / ✓* 绘图并可选导出(选项按格式自动适配,见下);stata_scheme 列出/查询/设置主题(action="set" 非只读)。stata_graph 导出成功后自动登记为资源
导出 stata_export_excel, stata_export_delimited, stata_etable 数据集导出为 .xlsx 或 CSV/TSV/自定义分隔符(replace 默认 False);回归表导出优先用 stata_etable(官方 etable,无第三方依赖,直出 .docx/.xlsx/.pdf/.tex)。export_excel(results=True) 是旧路径:依赖第三方 estout 且只能产出 CSV。导出成功即登记为资源
文件资源回传 stata_read_file, stata_register_file, stata_list_resources ✓ / — 导出工具成功后会登记输出文件,远程客户端可经 MCP 资源协议(resources/readstata-file:///<路径>)或 stata_read_file(base64)取回图表/Excel/CSV/dta 的实际内容,而不只是路径。安全边界:只读登记过的文件,未登记报错并提示登记方式
包管理与帮助 stata_install_package, stata_uninstall_package, stata_describe_package, stata_find_package, stata_list_packages, stata_help — / ✓ 装/卸(ado uninstall 本地安全)/查详情(本地 ado describe 或联网 ssc describe)/net search 找包/ado dir 列包/stata_help 查任意命令帮助
会话生命周期 stata_clear, stata_snapshot clear 按 scope 重置(data/estimates/graphs/panels/all);snapshot 包 Stata 原生快照 save/list/restore/erase,同会话内数据阶段间快速回退
长任务控制 stata_background, stata_task_status, stata_task_cancel, stata_task_result, stata_task_list — / ✓ 后台执行长任务(大循环/复杂回归/联网,单块最长 3600s),立即返回任务号;进度轮询、显式取消、取结果。后台任务仍持 _stata_lock,运行期间其他调用会等待
翻页 stata_more 大输出分页浏览(缓存 120K chars)
会话 stata_status 数据集 + 工作目录 + frame + 面板/时序设定 + 已存/活跃估计 + 内存 —— 覆盖 Agent 调 xtreg/margins/predict 前需确认的全部前提
心跳 stata_ping 快速检测 Stata DLL 存活状态
服务器日志 stata_read_log 读取本 MCP Server 的运行日志(tail/path),排查远程客户端看不到的服务器侧问题

Read the full file on GitHub · 592 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 592 lines · 24,127 tokens per session scan A 9de1d1502d62

Subscribe to this mod's changes

stata-mcp CLAUDE.md is an instructions file published in the GitHub repository aliveranme/stata-mcp (0 stars, last pushed 10d ago), licensed MIT. It adds 24,127 tokens to every session, about $0.1206 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,153 tokens

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,469 tokens

deepseek-harness AGENTS.md

AGENTS.md instructions for deepseek-ai/deepseek-harness, covering agents.md, pre-stable apis and released session data, repository layout, commands and host sandbox failures.

deepseek-ai/deepseek-harness · 3,735 tokens