LabscoMCP early access ↗
SepineTamMCP SERVER

Stata MCP for Agents

Let an agent run a Stata do-file on your own machine, read the log it produced, and look up the syntax of the command that failed.

by SepineTam ↗Physical Sciences & Scientific ComputingCommunity

LABSCO SUMMARY

Stata stays on your machine; the agent only gets do-files and logs.

Execution is subprocess-based rather than session-based, so each run is a do-file in and a log out — reproducible, and easy to inspect after the fact. The guard and the RAM ceiling exist because the caller is a model: shell escapes and file deletion are refused before Stata ever sees them.

What it is

An MCP server that hands a licensed local Stata install to an agent. The agent writes a do-file, the server runs it through the Stata CLI as a subprocess and returns the execution log; separate tools describe a data file before it is used and read back .log or .smcl output afterwards. A command guard sits in front of execution, and the same tools are also exposed as a standalone CLI toolkit.

What you get

  • A do-file executed through your configured Stata CLI, answered with the run's log — stata_do
  • Descriptive statistics and a preview for a data file before anything runs against it, covering .dta, .csv, .tsv, .psv, .xlsx and .xls — get_data_info
  • Stata's own documentation for a command, so syntax questions are answered from the install rather than from memory — help
  • A log file read back in full, core or dictionary form — read_log
  • A command guard that blocks shell-escape and destructive commands such as !, shell and erase before they reach Stata
  • RAM monitoring with configurable limits, so a runaway regression fails instead of taking the machine down
  • Layered TOML configuration — user, project, environment — with STATA_MCP__ environment variables overriding individual settings

Requirements

Your own Stata licence, installed at the default path, with the Stata CLI present on macOS and Linux. uv provides the runtime: uvx stata-mcp install --all writes the config for every supported client, or uvx stata-mcp install -c cc for one of them; the published package is stata-mcp 1.22.0 on PyPI and runs over stdio. uvx stata-mcp doctor reports whether the OS, Python, dependencies, Stata CLI and execution path all check out before you debug a client. Claude Science runs servers in a sandbox that blocks the home directory, so it needs the uv tool paths allowlisted in its own config. Licensed AGPL-3.0.

Setup effort

One command — uvx stata-mcp