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

By S.Tam (individual) Python Local · stdio Data and analytics

56 popularity score ★ 275 ↓ 9.6k/mo

Connect your client

Local (PyPI)

Add in one click

Opens the app, which asks before it adds the server.

Or add it by command or config

Claude CodeTerminal
claude mcp add for-stata-stata -- uvx stata-mcp
Claude Desktopclaude_desktop_config.json
{
  "mcpServers": {
    "for-stata-stata": {
      "command": "uvx",
      "args": [
        "stata-mcp"
      ]
    }
  }
}
Cursor~/.cursor/mcp.json
{
  "mcpServers": {
    "for-stata-stata": {
      "command": "uvx",
      "args": [
        "stata-mcp"
      ]
    }
  }
}
VS Code.vscode/mcp.json
{
  "servers": {
    "for-stata-stata": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "stata-mcp"
      ]
    }
  }
}
Codex~/.codex/config.toml
[mcp_servers.for-stata-stata]
command = "uvx"
args = ["stata-mcp"]
Gemini CLITerminal
gemini mcp add --scope user for-stata-stata uvx -- stata-mcp

Settings 10

STATA_MCP__CWD Optional: Working directory for do-files, logs and the .statamcp folder. Default the directory the server starts in.
STATA_MCP__IS_GUARD Optional: Set to false to turn off the do-file command guard; the makers advise against it. Default true.
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. Default false. For stata_do.
STATA_MCP__ENABLE_WINDOWS_DATA_INFO Optional: Beta: registers get_data_info on Windows, where it is hidden by default. Default false. For get_data_info.
STATA_MCP__ADO_INSTALL_ALLOWED_GITHUB_REPOSITORIES Optional: GitHub repositories (owner/repo) ado_package_install may install from. For ado_package_install.
Set together: ram monitor
STATA_MCP__IS_MONITOR Optional: Turns on RAM monitoring of Stata runs. Default false.
STATA_MCP__RAM_LIMIT Optional: RAM limit in MB for a stata_do run; applies only when STATA_MCP__IS_MONITOR is true. Default -1 (no limit).
Set together: async
STATA_MCP__IS_ASYNC_DO Optional: Beta: runs stata_do asynchronously so several calls can run at once. Default false. For stata_do.
STATA_MCP__MAX_ASYNC_DO Optional: How many stata_do runs may run at once when async mode is on. Default 3. For stata_do.

What it does

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.

What it needs

RuntimePython
Runs onmacOS, Windows, Linux
StataPaid planA licensed local Stata install; on macOS and Linux its command-line executable (such as stata-mp) must exist.
Also
  • uv, for the uvx command
  • Stata installed locally (default path assumed by the standard config)

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.

Limits

  • Not covered No interactive Stata session: each call runs a whole do-file, and there is no graph export tool.
  • Not covered stata_do refuses do-files outside the working directory (STATA_MCP__CWD, by default where the server starts) and its .statamcp/stata-mcp-dofile folder, since v1.16.2.
  • Platform help is registered only on macOS and Linux; get_data_info is off on Windows unless STATA_MCP__ENABLE_WINDOWS_DATA_INFO is set (beta).
  • Not covered read_log is part of the default `all` profile only; starting with --core leaves it out.
  • Limit The guard's macro check catches only single-word dangerous values; values built by concatenation or at run time get past it, per its security page.
  • Limit STATA_MCP__RAM_LIMIT takes effect only when STATA_MCP__IS_MONITOR is true, which is off by default.
  • Limit Docs say each ado_package_install call asks the user to confirm, but the confirmation prompt is commented out in mcp_servers.py of the current release.
  • Early release STATA_MCP__IS_ASYNC_DO (parallel stata_do runs, up to 3 by default) is marked beta.
  • Size cap With the URL guard on, data downloads follow at most 6 redirects by default, set by [BETA] max_data_redirects in config.toml (0 turns redirects off).

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.

Who it suits

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).

Tools 5

3 only read, 2 change things. A ? marks an optional parameter.

stata_do changes
Runs a do-file through the local Stata executable after the guard checks it, and returns the log paths and, optionally, the log text.dofile_path: stringlog_file_name?: stringread_log_when_error?: booleanis_replace_log?: booleanenable_smcl?: booleantimeout?: number
get_data_info
Summarises a .dta, CSV/TSV, Excel or SPSS file, local or from a URL: variables, statistics and optional first rows.data_path: stringvars_list?: arrayencoding?: stringhead?: integer
help
Returns Stata's help text for a command, cached after the first call; macOS and Linux only.cmd: stringreplace?: boolean
read_log
Reads a Stata .log or .smcl file in the server's .statamcp folder, whole, trimmed or as command/result pairs, optionally first or last N lines.file_path: stringencoding?: stringoutput_format?: enumlines?: integer
ado_package_install changes
Installs an ado package from SSC, an allow-listed GitHub repository or an HTTPS net URL; only with --unsafe.package: stringsource?: stringis_replace?: booleanpackage_source_from?: string

Similar servers