stata-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| STATA_DIR | No | Stata installation directory | parent of MCP directory |
| STATA_EXE | No | Path to Stata executable (used in registration examples) | %STATA_DIR%/StataMP-64.exe |
| STATA_MCP_DIR | No | MCP project directory | auto-detected project root |
| STATA_COM_PROG_ID | No | Stata Automation ProgID | stata.StataOLEApp |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| stata_runA | 在最近的 Stata MCP session 对应 GUI 中将 commands 作为一个完整代码块执行;每次覆盖该 session 的最新运行 text log,并自动返回实际输出。可先用 stata_session(action='set_recent') 切换目标 session。 |
| stata_run_dofileA | 在 Stata GUI 中运行一个 do 文件。该工具以 session_id 表示一个复现任务/同一个 Stata GUI;同一任务的原始 do、检查 do、续跑 do 应使用同一个 session_id。每次调用都会覆盖该 session 在项目 .stata-mcp/cache/ 下的最新运行 text log,并自动返回日志内容;不会修改用户原始 do 文件。 |
| stata_sessionB | 管理 Stata MCP session:列出、查询、销毁、切换最近 session。session_id 代表同一复现任务/同一个 Stata GUI,并关联 entry/source/current do、每个 do 的 log_paths 和 last_log_path。 |
| stata_write_dofileA | 将 Stata 代码写入 do 文件并保存到磁盘,返回文件路径;相对文件名会写入最近 session 项目的 .stata-mcp/dofiles/,不会使用 MCP runtime。 |
| stata_append_dofileA | 向已有 do 文件追加内容 |
| stata_read_dofileA | 读取 do 文件内容,返回给 Claude 检查、解释或继续修改 |
| stata_read_logA | 读取 Stata text log。path 留空时读取最近 session 的 last_log_path;推荐 output_format='dict',它会把日志解析成命令-结果对,便于 AI 判断报错位置。 |
| stata_install_packageA | 在已打开的 Stata GUI 中安装外部包,如 estout、ivreg2、rdrobust 等 |
| stata_get_resultsA | 运行 return list 或 ereturn list,并通过 session 最新运行日志将 r() 或 e() 存储结果直接返回给调用端 |
| stata_get_data_infoB | 运行 describe,并通过 session 最新运行日志将当前数据集基本信息直接返回给调用端 |
| stata_get_data_schemaB | 使用独立且每次覆盖的 schema text log,读取当前 Stata 数据集结构、缺失摘要和样本预览并返回给调用端 |
| stata_statusA | 检查 Stata MCP 服务器状态、内存 session 和项目局部 .stata-mcp/cache/task_registry.json 中记录的 session/do/log 关系 |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 12 tools
Each tool targets a distinct artifact (do file, log, session, package, data metadata), and the descriptions clarify the boundaries well. A few pairs like stata_run/stata_run_dofile and stata_get_data_info/stata_get_data_schema are close enough that an agent could initially pick the wrong one.
Almost all tools follow a consistent stata_verb_noun pattern in snake_case. Minor deviations are stata_session and stata_status, which are noun-only names rather than verb_object, and stata_run which lacks an explicit object.
12 tools is well within the ideal scope for a domain-specific server. Each tool covers a meaningful part of the do-file, session, log, and data-inspection workflow without unnecessary bloat.
The tool surface covers the full write-do-file, append, read, run, read-log, install-package, and retrieve-results workflow coherently. Minor gaps exist around explicit session creation and do-file deletion, but arbitrary command execution via stata_run mitigates most dead ends.