/ Directory / Playground / Stata MCP
● Community SepineTam 🔑 Needs your key

Stata MCP

by SepineTam · SepineTam/stata-mcp

Stata as an MCP — load .dta files, run regressions, interpret coefficients with Claude. Built for econometrics workflows that demand a real causal thinker.

stata-mcp shells out to a local Stata install and exposes data loading, regression, and result-parsing as MCP tools. Pairs well with Claude's economic reasoning to move from reg y x to actual identification arguments — fixed effects, IV, DiD, RDD. Requires Stata licensed locally.

Why use it

Key features

Live Demo

What it looks like in practice

stata-mcp.replay ▶ ready
0/0

Install

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "stata-mcp": {
      "command": "uvx",
      "args": [
        "stata-mcp"
      ],
      "env": {
        "STATA_MCP_CWD": "/path/to/your/project"
      }
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "stata-mcp": {
      "command": "uvx",
      "args": [
        "stata-mcp"
      ],
      "env": {
        "STATA_MCP_CWD": "/path/to/your/project"
      }
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "stata-mcp": {
      "command": "uvx",
      "args": [
        "stata-mcp"
      ],
      "env": {
        "STATA_MCP_CWD": "/path/to/your/project"
      }
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "stata-mcp": {
      "command": "uvx",
      "args": [
        "stata-mcp"
      ],
      "env": {
        "STATA_MCP_CWD": "/path/to/your/project"
      }
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "stata-mcp",
      "command": "uvx",
      "args": [
        "stata-mcp"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "stata-mcp": {
      "command": {
        "path": "uvx",
        "args": [
          "stata-mcp"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add stata-mcp -- uvx stata-mcp

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

Use Cases

Real-world ways to use Stata MCP

First-pass analysis on a panel dataset

👤 Applied econ / finance researchers ⏱ ~60 min intermediate

When to use: You got a new dataset; you want to see the basic patterns before designing identification.

Prerequisites
  • Stata 17+ licensed and on PATH — Stata's installer; verify with stata-mp -h
  • Data file accessible — Set STATA_MCP_CWD to the project root
Flow
  1. Inspect
    Use stata-mcp. Load panel.dta. Summarize all numeric variables and check for missingness.✓ Copied
    → Summary table; missing-pattern diagnosis
  2. Plot
    Plot the dependent variable over time, grouped by treatment status.✓ Copied
    → Twoway plot exported
  3. First model
    Run a fixed-effects regression: outcome on treatment, controls FE_unit FE_time. Cluster SEs by unit. Interpret.✓ Copied
    → Coefficient table + interpretation in plain language

Outcome: Defensible first-pass analysis in an hour instead of an afternoon.

Pitfalls
  • FE model identifies off within-unit variation only — Claude will flag this; consider DiD if treatment is staggered
Combine with: filesystem

Talk through which identification strategy fits your data

👤 Researchers stuck between OLS, DiD, RDD, IV ⏱ ~45 min advanced

When to use: You have observational data and want a causal claim.

Flow
  1. Describe
    Here's my setting (treatment, outcome, available variation). Which identification strategies are plausible? Trade-offs?✓ Copied
    → Comparative reasoning per strategy
  2. Test assumptions
    Run parallel-trends pre-trends test for DiD. Plot.✓ Copied
    → Pre-trend test result

Outcome: An identification strategy with explicitly tested assumptions.

Pitfalls
  • Claude will run the test even when assumption is dubious — Always ask 'is this assumption defensible?' separately

Render publication-ready coefficient tables

👤 Authors near submission ⏱ ~20 min intermediate

When to use: Tables need to be in LaTeX with stars, robust SEs, controls suppressed.

Flow
  1. Run all specs
    Run 5 specs (no controls, +basic, +full, +FE, +FE+cluster). Save each as e(b).✓ Copied
    → 5 stored estimates
  2. Render
    Use esttab to produce a LaTeX table. Stars at 1/5/10. Robust SEs in parentheses.✓ Copied
    → LaTeX table file written

Outcome: Drop-in table for your paper.

Pitfalls
  • esttab options inconsistent across journals — Ask for the journal's preferred format explicitly
Combine with: overleaf-mcp

Combinations

Pair with other MCPs for X10 leverage

stata-mcp + filesystem

Pull data files and save outputs

Load /data/panel.dta and save the regression table to /tables/reg1.tex.✓ Copied
stata-mcp + overleaf-mcp

Push generated tables straight into your paper

Generate the spec table and have Overleaf MCP commit it as tables/main.tex.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
load_data path Open a .dta free
summarize vars? First glance free
regress formula, options? Run a model free
stata_command command: str Anything not wrapped (esttab, twoway, etc.) free

Cost & Limits

What this costs to run

API quota
None — local Stata
Tokens per call
200–4000
Monetary
Free MCP; Stata license required
Tip
Use stata-mp if you have it — multi-core reg is much faster

Security

Permissions, secrets, blast radius

Minimum scopes: Local file read/write in project directory
Credential storage: None
Data egress: None — fully local
Never grant: Stata's `shell` access if you don't need it

Troubleshooting

Common errors and fixes

Stata not found

Ensure Stata is on PATH; set STATA_MCP_BIN if non-standard install

Verify: `stata-mp -h` from terminal
Multicollinearity warning ignored

Claude flags it; investigate VIF before trusting coefficients

Verify: `vif` after regression
License error

Stata license tied to user/host; check your install

Alternatives

Stata MCP vs others

AlternativeWhen to use it insteadTradeoff
R / tidyverse + fixestYou don't have a Stata licenseDifferent ecosystem; some Stata commands have no R analog
Python statsmodels / linearmodelsPandas-native workflowLess rich for econometrics-specific tests

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills