MCP-for-Stata (Stata-MCP)
Runs Stata do-files on your own machine and hands the logs and data summaries back to an AI agent
Runs Stata code, reads datasets, stored results and graphs in a local Stata install over MCP
By Thomas Monk (individual) Python Local · stdio Data and analytics
46 popularity score ★ 92 ↓ 2.4k/mo
Opens the app, which asks before it adds the server.
claude mcp add stata -- uvx --refresh --refresh-package mcp-stata --from mcp-stata@latest mcp-stata{
"mcpServers": {
"stata": {
"command": "uvx",
"args": [
"--refresh",
"--refresh-package",
"mcp-stata",
"--from",
"mcp-stata@latest",
"mcp-stata"
]
}
}
}{
"mcpServers": {
"stata": {
"command": "uvx",
"args": [
"--refresh",
"--refresh-package",
"mcp-stata",
"--from",
"mcp-stata@latest",
"mcp-stata"
]
}
}
}{
"servers": {
"stata": {
"type": "stdio",
"command": "uvx",
"args": [
"--refresh",
"--refresh-package",
"mcp-stata",
"--from",
"mcp-stata@latest",
"mcp-stata"
]
}
}
}[mcp_servers.stata]
command = "uvx"
args = ["--refresh", "--refresh-package", "mcp-stata", "--from", "mcp-stata@latest", "mcp-stata"]gemini mcp add --scope user stata uvx -- --refresh --refresh-package mcp-stata --from mcp-stata@latest mcp-stataSTATA_PATH |
Optional: Path to the Stata executable, needed only when automatic discovery fails. |
|---|---|
MCP_STATA_TEMP |
Optional: Writable folder for temporary files, for permission problems (common on Windows). |
MCP_STATA_STARTUP_DO_FILE |
Optional: One or more do-files run when a session starts, separated by : (Unix) or ; (Windows). |
MCP_STATA_NO_RELOAD_ON_CLEAR |
Optional: Set to 1 to stop startup files re-running after clear all. |
MCP_STATA_ALLOWED_ROOTS |
Optional: Extra folders, path-separator delimited, where do-files and datasets may be read without allow_unsafe_paths. |
MCP_STATA_LOGLEVEL |
Optional: Server log level, DEBUG by default in server.py. |
mcp-stata connects an assistant to a copy of Stata installed on your own computer. It loads Stata through pystata, the Python bridge that ships with Stata, and keeps one or more named Stata sessions open, so commands run one after another against the same data in memory, as they would in the Stata window.
Through it an assistant can run commands or whole do-files (in the foreground or as background jobs it can poll, interrupt or cancel), load datasets, describe and list variables, read r(), e() and s() stored results as structured data, export graphs, read Stata help and search the log files each run writes. On top of that sit research helpers written by Thomas Monk at the London School of Economics for empirical economics: a dataset audit, an estimation plan, side-by-side comparison of model specifications, a publication check of tables and graphs, a reproducibility report, and a runner for test_*.do files. It also offers prompts, a set of stata:// resources and a catalogue of skill files.
The README's tool section lists 10 tools; the server.py of release 3.3.0 registers 20, adding stata_research_audit, stata_estimation_plan, stata_compare_specs, stata_publication_check, stata_project_reproducibility_report, stata_doctor and four test tools. A side HTTP API for a VS Code data browser starts with it on 127.0.0.1.
| Runtime | Python 3.11+ |
|---|
A licensed local install of Stata 17 or later (MP, SE or BE, StataNow supported) on macOS, Windows or Linux; Python 3.11+; uv for the uvx launch command. The server finds Stata itself in standard locations; set STATA_PATH to the Stata executable when it does not. It uses the pystata module inside the Stata install: do not install the unrelated pystata package from PyPI.
A synchronous stata_run returns only the last 5,000 characters of output (server.py, v3.3.0); the full output is in the log file, read with stata_read_log. With default settings, a do-file path or double-quoted path in a command that lies outside the working directory, the system temp folder, ~/.mcp-stata/temp and the package's own folder is refused unless the call sets allow_unsafe_paths or the folder is added in MCP_STATA_ALLOWED_ROOTS, a setting the README does not mention. Cancelling a running command is best-effort and can leave partial output. The data-browser API caps a page at 500 rows.
Economists and other researchers who already hold a Stata licence and want an assistant to run regressions, check data and rerun do-files against their real Stata, with the session kept between calls. It is no use without Stata on the same machine, and it cannot reach a Stata on a server you only log into remotely. Because it runs whatever Stata code it is given, people who only want an assistant to read data can use the read_only option on stata_run, which refuses commands it classes as writing, deleting, installing or fetching URLs.
stata_runstata_task_statusstata_controlstata_read_logstata_load_datastata_inspect_datastata_manage_graphsstata_get_resultsstata_get_helpstata_manage_sessionstata_research_auditstata_estimation_planstata_compare_specsstata_publication_checkstata_project_reproducibility_reportstata_doctorstata_run_testsstata_run_teststata_discover_testsstata_get_test_results