mcp-stata
Runs Stata code, reads datasets, stored results and graphs in a local Stata install over MCP
Runs Stata do-files on your own machine and hands the logs and data summaries back to an AI agent
By S.Tam (individual) Python Local · stdio Data and analytics
56 popularity score ★ 275 ↓ 9.6k/mo
Opens the app, which asks before it adds the server.
claude mcp add for-stata-stata -- uvx stata-mcp{
"mcpServers": {
"for-stata-stata": {
"command": "uvx",
"args": [
"stata-mcp"
]
}
}
}{
"mcpServers": {
"for-stata-stata": {
"command": "uvx",
"args": [
"stata-mcp"
]
}
}
}{
"servers": {
"for-stata-stata": {
"type": "stdio",
"command": "uvx",
"args": [
"stata-mcp"
]
}
}
}[mcp_servers.for-stata-stata]
command = "uvx"
args = ["stata-mcp"]gemini mcp add --scope user for-stata-stata uvx -- stata-mcpSTATA_MCP__CWD |
Optional: Working directory for do-files, logs and the .statamcp folder. |
|---|---|
STATA_MCP__IS_GUARD |
Optional: Set to false to turn off the do-file command guard; the makers advise against it. |
STATA_MCP__ADDITIONAL_ALLOWED_DIRS |
Optional: Extra directories, beyond the working directory, that the path checks allow. |
STATA_MCP__ENABLE_DATA_COMMAND_PATH_GUARD |
Optional: Applies the local-path and URL boundaries to data-loading commands inside do-files. |
STATA_MCP__ENABLE_WINDOWS_DATA_INFO |
Optional: Beta: registers get_data_info on Windows, where it is hidden by default. |
STATA_MCP__ADO_INSTALL_ALLOWED_GITHUB_REPOSITORIES |
Optional: GitHub repositories (owner/repo) ado_package_install may install from. |
| Set together: ram monitor | |
STATA_MCP__IS_MONITOR |
Optional: Turns on RAM monitoring of Stata runs. |
STATA_MCP__RAM_LIMIT |
Optional: RAM limit in MB for a stata_do run; applies only when STATA_MCP__IS_MONITOR is true. |
| Set together: async | |
STATA_MCP__IS_ASYNC_DO |
Optional: Beta: runs stata_do asynchronously so several calls can run at once. |
STATA_MCP__MAX_ASYNC_DO |
Optional: How many stata_do runs may run at once when async mode is on. |
MCP-for-Stata, published on PyPI as stata-mcp, connects an AI agent to a copy of Stata installed on the same computer. The agent writes its analysis as a do-file, the server runs that file through the Stata executable it finds (or the one named in its config) and returns the log, so regressions, replications and other econometric work happen in your licensed Stata rather than in a re-implementation. There is no persistent Stata session: every run is a separate do-file.
Beside running do-files it can summarise a data file (Stata .dta, CSV/TSV, Excel and SPSS files, local or by URL), read back .log and .smcl logs, and, on macOS and Linux, fetch the help text for a Stata command. Before a do-file runs, a built-in guard scans it against a list of risky commands (shell escapes such as `!` and `shell`, file deletion) and refuses it if one is found; package-management commands (ssc, net, github, adoupdate, update) are refused even with the guard switched off. An optional monitor can stop runs that pass a RAM limit.
The default server (`all` profile) registers four tools on macOS and Linux: stata_do, get_data_info, help and read_log; `stata-mcp server --core` drops read_log. On Windows help is never registered, and get_data_info is hidden unless STATA_MCP__ENABLE_WINDOWS_DATA_INFO is turned on, because its MCP wrapper has a Windows-only bug, as a comment in mcp_servers.py states. A fifth tool, ado_package_install, appears only when the server is started with `stata-mcp server --unsafe`. The same package ships a CLI with installers that write the config for Claude Code, Codex, Cursor, Gemini CLI, Cline, OpenCode and other agents (`uvx stata-mcp install -c <tag>`), plus a `doctor` check. The project states it is a community tool with no tie to StataCorp.
| Runtime | Python |
|---|---|
| Runs on | macOS, Windows, Linux |
| Stata | Paid planA licensed local Stata install; on macOS and Linux its command-line executable (such as stata-mp) must exist. |
| Also |
|
The standard config assumes Stata sits at its default install path; otherwise the path to the Stata executable is set in the server's config file (~/.statamcp/config.toml). `uvx stata-mcp doctor` checks the setup. Installing ado packages needs the server started with `stata-mcp server --unsafe`, and GitHub packages also need the repository listed in STATA_MCP__ADO_INSTALL_ALLOWED_GITHUB_REPOSITORIES.
No interactive session: each call runs a whole do-file, and graph export is not provided. stata_do refuses do-files outside the working directory (STATA_MCP__CWD, by default the directory the server starts in) and its .statamcp/stata-mcp-dofile folder, since v1.16.2. The help tool exists only on macOS and Linux, and get_data_info is off on Windows unless STATA_MCP__ENABLE_WINDOWS_DATA_INFO is set. The guard's macro check catches only single-word dangerous values; values built by concatenation or at run time get past it, as its security page says. The RAM limit (STATA_MCP__RAM_LIMIT) takes effect only when STATA_MCP__IS_MONITOR is true, which is off by default.
It suits economists and social scientists who already own a Stata licence and want an agent such as Claude Code or Codex to write, run and read do-files for them on their own machine. It is not useful without Stata, and Windows users get a reduced tool set. If you need a persistent Stata session that keeps data in memory between calls, or graph export, the README's comparison points to tmonk/mcp-stata (runs through pystata, Stata 17 or later) and haoyu-haoyu/stata-ai-fusion (interactive sessions and graph export).
3 only read, 2 change things. A ? marks an optional parameter.
stata_do changesdofile_path: stringlog_file_name?: stringread_log_when_error?: booleanis_replace_log?: booleanenable_smcl?: booleantimeout?: numberget_data_infodata_path: stringvars_list?: arrayencoding?: stringhead?: integerhelpcmd: stringreplace?: booleanread_logfile_path: stringencoding?: stringoutput_format?: enumlines?: integerado_package_install changespackage: stringsource?: stringis_replace?: booleanpackage_source_from?: string