# Stata MCP Server [Health: Active]

**Category:** 🧮 Data Science Tools  
**Repository:** https://github.com/aliveranme/stata-mcp  
**GitHub Stars:** 0  
**npm Downloads (last month):** 305  
**Views:** 17  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/stata-mcp-server

## Description
通过 pystata 驱动真实 Stata 的 MCP 服务器：数据加载/清洗/建模/诊断/图形导出，75 个工具覆盖完整计量工作流。

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "stata-mcp-server": {
    "command": "npx",
    "args": ["-y","@aliveranme/stata-mcp"],
    "env": {
      "STATA_HOME": "",
      "STATA_EDITION": ""
    }
  }
}
```

**Requires environment variables:** `STATA_HOME`, `STATA_EDITION` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What Stata MCP Server MCP server does

Stata MCP Server MCP server gives an MCP client access to a locally installed Stata runtime through Python's `pystata` interface. It supports workflows that begin with loading a dataset and continue through cleaning, exploration, estimation, post-estimation checks, graph creation, and file export. The server includes 75 tools, combining structured wrappers for common operations with general command execution through `stata_run`.

The server is intended for agents that need to perform actual Stata analysis rather than only generate Stata syntax. A client can load `.dta` files, import several other formats, declare panel data, fit regression and limited dependent-variable models, inspect results, create predictions, and return exported files as MCP resources.

## How it works

Stata is initialized in the server process through `pystata`, which uses ctypes to load the Stata runtime. The same session is reused across tool calls, so datasets in memory, estimation results, and local macros remain available as an analysis progresses. This supports sequences such as loading data, cleaning variables, estimating a model, running a diagnostic, and exporting a graph without reloading the dataset.

`stata_run` accepts arbitrary Stata commands, while `stata_help` provides help for built-in or installed commands. Specialized tools add structured parameters and validation around frequently used operations. Command output is read from Stata's output buffer; large results can be paged with `stata_more`, and output is subject to a 120,000-character limit. Long-running commands have a 60-second watchdog unless the timeout is explicitly increased.

## Setup and configuration

The server requires StataNow 19 or Stata 18 or later with `utilities/pystata`, plus Python 3.10 or newer. Supported operating systems listed by the project are Windows and macOS. The repository setup script can detect Stata, create a virtual environment, install `fastmcp`, generate `.mcp.json`, and check that the server starts.

Set `STATA_HOME` when Stata is installed outside a path the setup script can detect. Set `STATA_EDITION` to `mp`, `se`, or `be`. The project also publishes an npm launcher, `@aliveranme/stata-mcp`, which can be run with `npx`; this path requires Node.js 18 or newer and `uv`, or an environment with Python and the required FastMCP package.

## Tools and capabilities

Stata MCP Server MCP server groups its tools across these areas:

- Data loading and management, including `.dta`, Excel, CSV, SAS, SPSS, dBase, and Parquet imports.
- Reshaping, merging, appending, collapsing, frames, variable changes, recoding, and validation.
- Descriptive analysis such as summaries, tabulations, correlations, codebooks, and data listing.
- Estimation including OLS, logistic, probit, Poisson, panel, IV, multinomial, negative-binomial, quantile, and mixed models.
- Post-estimation operations including margins, tests, predictions, model storage, Hausman comparisons, and returned results.
- Graph, Excel, delimited-text, and regression-table exports, with exported files registered as readable resources.
- Package management, help lookup, snapshots, session status, log reading, paging, and background task control.

## Limitations and notes

A working Stata installation and a license capable of running the requested commands are required; the server does not provide Stata itself. The documented operating-system support is limited to Windows and macOS. Some operations have prerequisites: for example, panel estimation requires `xtset`, and post-estimation tools require a preceding estimation command. `stata_etable` requires Stata 17 or newer.

The server can run arbitrary commands, but `stata_run` includes interception for dangerous command prefixes. Long tasks have a maximum background block duration of 3,600 seconds, and normal output can be truncated by the stated character limit. Export success is checked by confirming that the output file was written, while binary files are retrieved through MCP resource operations.

_Full upstream README: https://allmcps.com/mcp/stata-mcp-server/readme_

