Stata Econ MCP
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| STATA_DIR | No | Path to the Stata installation directory. Defaults to automatic search (e.g. /Applications/Stata, /Applications/StataNow on macOS). Set this if Stata is not in a default location. | |
| STATA_EDITION | No | Stata edition: mp, se, or be. Defaults to automatic detection based on the installation directory. | |
| STATA_MCP_WORKDIR | No | Project working directory for the server. Defaults to automatic selection (session folder, otherwise the default directory). | |
| STATA_MCP_DEFAULT_DIR | No | Default project directory when no session folder is available. Defaults to ~/Documents/Stata研究. | |
| STATA_MCP_WAIT_SECONDS | No | Number of seconds to wait for a Stata command before returning; the task continues in the background and can be retrieved with stata_wait. Defaults to 240. | |
| STATA_MCP_OUTPUT_SUBDIR | No | Name of the output subdirectory created under the project folder (containing do, logs, tables, figures). Defaults to stata_output. |
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 drives the user's OWN local Stata (official pystata engine, persistent session). Data, estimates, globals persist across calls until stata_restart.
Working rules:
Before any econometric task, read stata_guide("workflow") and the topic guide (panel_fe, did, ddd, event_study, latex_tables, econ_standards). Follow them.
Inspect data first (stata_data: overview / describe / xtdescribe) before modelling.
Put real analysis in do-files via stata_do so it is reproducible; use stata_run for quick checks.
estimates storeevery model, then export publication tables with stata_table (LaTeX/booktabs).Figures: build with Stata graph commands, then stata_graph to export PNG(+PDF) and show it.
Outputs go to /stata_output/ (do/, logs/, tables/, figures/). Every command is also appended to logs/history_.do. Tell the user where files were saved.
Never run shell escapes (
!,shell) or delete user files. Ask beforessc install. Reply in the user's language.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| stata_runA | Run Stata code in the persistent session and return the output.
|
| stata_doB | Save filename: e.g. "01_clean" or "analysis/did_main.do". A bare name goes to stata_output/do/;
a relative path with folders is relative to the working directory; absolute paths are allowed.
If |
| stata_waitB | Keep waiting for a long-running Stata job started earlier and return its output. |
| stata_restartA | Kill and restart the Stata session (clears data in memory). Use if Stata hangs. |
| stata_set_workdirA | Set the project folder. Outputs then go to /stata_output and Stata Use when the user names a project folder, or if the detected folder is wrong. |
| stata_statusA | Show Stata install, working/output folders, and which key econometrics packages are installed. |
| stata_dataB | Inspect the dataset in memory. action: overview | describe | summarize | detail (summarize, detail) | codebook | list |
tabulate | xtdescribe | missing | count
varlist: optional Stata varlist; condition: optional Stata |
| stata_resultsB | Structured coefficients and statistics of the active (or a stored) estimation. name: optional |
| stata_graphA | Export the current (or named) Stata graph to stata_output/figures and display it. Draw the graph first with stata_run/stata_do (e.g. coefplot, twoway, event-study plots). Saves .png (shown inline) and, if pdf=True, .pdf for LaTeX. |
| stata_tableA | Export stored models to a publication LaTeX table (esttab, booktabs) and return the .tex. models: names from |
| stata_helpA | Read the official Stata help file for a command (also works for installed packages, e.g. reghdfe, csdid). |
| stata_guideA | Applied-econometrics playbook written for this server. Read before modelling. topics: index, workflow, panel_fe, did, ddd, event_study, latex_tables, econ_standards, stata_gotchas |
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
Most tools target clearly distinct facets of the Stata workflow (run, wait, restart, workdir, status, data, results, graph, table, help, guide). The main risk is stata_run vs stata_do, which both execute code, but the descriptions explicitly differentiate quick exploration from saved do-files with logs, and stata_help vs stata_guide are separated by 'official help file' vs 'econometrics playbook'.
All names share a uniform snake_case `stata_` prefix, making the set instantly recognizable. There is a minor stylistic split between verb-led names (stata_run, stata_do, stata_wait, stata_restart, stata_set_workdir) and noun-led names (stata_data, stata_results, stata_graph, stata_table), but it stays readable and predictable.
Twelve tools is a well-scoped set for a persistent-session Stata server: session control, execution, inspection, export, and reference docs. Each tool maps to a real step in an econometric workflow with no filler.
The surface covers the full lifecycle: start/run/wait/restart the session, set the project folder, inspect data, extract structured estimates, export figures and LaTeX tables, plus help and a playbook. Minor gaps exist around browsing or cleaning previously produced output files (figures/tables/logs) and non-destructive interrupt, but stata_run is a general escape hatch that mitigates most of these.