StatsPAI: causal inference and econometrics for agents
StatsPAI
The MCP server and skill of the StatsPAI library: the agent runs DiD, RD, IV and synthetic control on your data
- 367 ★ on the repository
- Last commit
- MIT
Extended access
Why this level
- The tools read data files from the given path and run computations on your machine
Install
- Works in
Manual install
pip install statspai && claude mcp add statspai -- statspai-mcpInstalls the library and registers the stdio server. Mirrors Stata and R commands: regress, ivregress, reghdfe, csdid, rdrobust, synth, psmatch2, lm, fixest, did, MatchIt, modelsummary. Reads CSV, dta and other pandas formats. The function list: statspai list.
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- The tools read data files from the given path and run computations on your machine
This is third-party code. Review the repository files before installing.
What it does
StatsPAI is a Python library for applied econometrics and causal inference. It mirrors familiar Stata and R routines, from regress, reghdfe and rdrobust to fixest, MatchIt and modelsummary. An estimation result has shared methods: a summary, a table and a plot. It can also be exported to LaTeX and Word or turned into a short description for an agent. Every public function carries a machine-readable schema, so it can be found and described from code or the console. The statspai-mcp server runs over stdio and connects to Claude Code, Claude Desktop and Cursor. By default it lists curated estimators and workflows plus three meta-tools, search_functions, describe_function and call_function, which reach any registered function. The agent passes data by path in data_path: CSV, Stata .dta files and other pandas formats work. The answer comes as structured JSON with data provenance and warnings raised during computation. The statspai skill install command copies the statspai-analysis skill into ~/.claude/skills. It guides the agent through workflows in economics, epidemiology and causal machine learning, all the way to paper-ready tables and figures. statspai skill validate checks the skill's claims about functions.
Who it is for. For economists, epidemiologists and data analysts who move computations from Stata and R to Python and want an agent to estimate effects and prepare tables.
Good fit when
- You need to estimate staggered difference-in-differences with the Callaway and Sant'Anna method on panel data
- You need to check a regression discontinuity or an instrumental variable and export tables to Word, Excel or LaTeX
- You have Stata commands to translate into Python and cross-check results
- An agent must pick a fitting estimator from a data description through search_functions and a step-by-step route
- You want a replication appendix assembled in one Word, Excel or LaTeX file
Not a fit when
- You work on Windows: the documentation states Linux and macOS and Python 3.10 to 3.13
- A publication needs numbers with verified parity: for part of the functions it is confirmed only by simulations, so read the validation_status field
- The data must not be given to an agent: the tools read files from your disk
Example request
Estimate the program effect with Callaway and Sant'Anna on panel.csv, draw the event-study plot and export the table to Word.MCP
- Transport
- stdio, http
- Authentication
- not required
Environment variables
STATSPAI_MCP_HTTP_TOKENsecret- Token for HTTP mode when the server is bound to anything other than 127.0.0.1.
Limitations
The library needs Python 3.10 to 3.13 on Linux or macOS. Optional extras pull in extra plotting packages, PyMC, PyTorch and spatial data libraries.
The author warns about accuracy: StatsPAI does not promise that every number matches Stata and R. Each function has a validation_status field. Some estimators are checked against R or Stata on identical data, others only against simulations with known truth, and others so far have only a stable interface. Check the numbers before publication.
In HTTP mode the server listens on 127.0.0.1:8765, and any other address needs the STATSPAI_MCP_HTTP_TOKEN variable. An installed skill stays a copy and does not update with the package; statspai skill status reports its state.
How to disable. Remove the server with claude mcp remove statspai, the skill from ~/.claude/skills/statspai-analysis and the package with pip uninstall statspai.
FAQ
How do I connect StatsPAI to Claude Code?
Run pip install statspai, then claude mcp add statspai -- statspai-mcp. For Claude Desktop and Cursor add a statspai server with the command statspai-mcp and empty arguments to the configuration.
Does StatsPAI replace Stata and R?
For new Python work largely yes, but the author does not promise bit-for-bit parity. Check important numbers before publication.
Which methods does the library support?
They include difference-in-differences, regression discontinuity, instrumental variables and synthetic control. There are also double machine learning, matching, causal forest and decompositions such as Oaxaca-Blinder. The statspai list and statspai search commands return the full list.
Can I run a computation from the terminal without an agent?
Yes. The statspai run command, for example with callaway_santanna, takes data and arguments the same way an MCP client does. The documentation lists shortcuts such as statspai did.
What does the statspai-analysis skill do?
It guides the agent through ready workflows: an applied economics paper, an epidemiology pipeline, causal machine learning and gap decomposition, including table export to Word, Excel and LaTeX. It installs with statspai skill install.
Discussion
No questions or reviews yet.
Related
MCP serversAn MCP server that lets an agent run local Stata: regressions, econometrics, replicating computations from papers
17 skills for economists: research ideas, literature review, Stata and R, LaTeX models, tables and Beamer slides
Official Data Commons MCP server: an agent finds statistical indicators and pulls observations for countries, regions and cities.
Auto-Empirical Research Skills
Auto-Empirical Research Skills (AERS)
A plugin marketplace for empirical social science research: causal inference, econometrics and manuscript prep for top journals
MCP server that connects Claude Code and Codex to an open R or Python session in RStudio and Positron, where your data lives
Around 200 skills for Claude Code on bioinformatics, chemistry and biostatistics, from RNA-seq analysis to molecular docking
README in short
The documentation maps Stata and R commands to library functions, gives six beginner examples with results and a section on what has been checked and what has not. Notes on working through an agent form a separate section.