Get the FREE Ultimate OpenClaw Setup Guide →

mcp-stata

A lightweight Model Context Protocol (MCP) server for Stata. Execute commands, inspect data, retrieve stored results (r()/e()), and view graphs in your chat interface. Built for economists who want to integrate LLM assistance into their Stata workflow.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio tmonk-mcp-stata uvx --refresh --refresh-package mcp-stata --from mcp-stata@latest mcp-stata

How to use

This MCP server enables AI agents to interact with a local Stata installation via the Model Context Protocol. It exposes a stdio-based transport so clients launch the server process and communicate over standard input and output, allowing tools and IDEs to send Stata commands, fetch results, and stream outputs in real time. The server supports executing Stata code, inspecting datasets (summaries and codebooks), exporting graphics such as histograms and scatterplots, and caching graphs during command execution for quick exports. It also provides mechanisms to verify results by extracting outputs like r() and e() values from Stata sessions to ensure validity of the analysis.

To use it, install the MCP Stata server in your IDE or tool that supports MCP (Claude Desktop, Cursor, Windsurf, Google Antigravity, VS Code, etc.) via the published uvx tool. The usual setup involves launching the server through uvx with the latest package, then configuring your IDE to use the published tool as the mcp server. Once configured, you can send Stata syntax commands, request data summaries, and retrieve graphs and results directly through the MCP bridge.

How to install

Prerequisites

  • Stata 17+ (Stata MP, SE, or BE) installed locally with a valid license
  • Python 3.11+ installed
  • uv (preferred via uvx) for MCP tooling

Install steps

  1. Install the MCP-Stata server using uvx (the published tool):
uvx --refresh --refresh-package mcp-stata --from mcp-stata@latest mcp-stata
  1. Verify the installation and note that uvx will pull the latest mcp-stata package and make the server available via MCP channels.
  2. Configure your IDE or tooling to point at the MCP server named mcp-stata (see integration guides for Claude Desktop, Cursor, Windsurf, VS Code, etc.).
  3. Ensure your environment can locate Stata (see Optional ENV vars) if auto-discovery fails.

Optional: if you need to manually specify the Stata path or startup behavior, see environment variable guidance in the Configuration section of the README.

Additional notes

Environment variables you may need to configure (add to the MCP server's env settings if auto-discovery fails):

  • STATA_PATH: path to your Stata executable (e.g., /Applications/StataNow/StataMP.app/Contents/MacOS/stata-mp or C:\Program Files\Stata18\StataMP-64.exe)
  • MCP_STATA_TEMP: directory for temporary files (to resolve Windows write-permission issues)
  • MCP_STATA_STARTUP_DO_FILE: custom startup do files, separated by : (Unix) or ; (Windows)
  • MCP_STATA_NO_RELOAD_ON_CLEAR: set to 1 to disable automatic reloading when the Stata session is cleared

Notes:

  • The server uses the proprietary pystata module included with your Stata installation; do not install a separate pystata package from PyPI.
  • The server will auto-discover Stata via standard paths and StataNow; if discovery fails, environment variables provide a fallback.
  • The transport is stdio, so IDE integrations that support MCP (Claude Desktop, Cursor, Windsurf, VS Code, etc.) can load and refresh the MCP server configuration.

Related MCP Servers

Sponsor this space

Reach thousands of developers