home / mcp / stata mcp server

Stata MCP Server

Provides an MCP server to enable AI-assisted Stata development with editor integrations.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "hanlulong-stata-mcp": {
      "url": "http://localhost:4000/mcp"
    }
  }
}

You run the Stata MCP Server to enable AI-assisted Stata development across editor integrations. By exposing a Model Context Protocol (MCP) endpoint, you can connect supported clients to run Stata commands, see real-time output, and leverage AI tools to assist with coding, data exploration, and reporting.

How to use

Connect a compatible MCP client to the Stata MCP Server at the provided endpoint. The server exposes an MCP interface over HTTP, allowing editors like VS Code, Cursor, and Antigravity to send Stata commands, receive results, and integrate AI-assisted features.

How to install

Prerequisites: install Stata 17 or higher on your machine. Ensure you have a capable editor environment and a working internet connection for initial setup.

Install the MCP client support for your editor. If you already have the Stata MCP extension installed in VS Code, Cursor, or Antigravity, you can proceed to configure the MCP connection. The server endpoint to connect to is http://localhost:4000/mcp.

Configure your editor or Copilot-related tools to connect to the Stata MCP Server using the following explicit MCP configuration. The server URL must point to the MCP endpoint and use a SSE transport.

Optional helper tools and installers described in the source (such as the UV Python package installer) help manage dependencies and runtime environments for Stata-related tooling. Follow those steps if you encounter environment or dependency issues.

Additional content

MCP connection options for editors and assistants are described below. If you want to connect to Copilot, Claude Code, Claude Desktop, Codex, or Cline, you configure an MCP server entry that points to the Stata MCP endpoint at http://localhost:4000/mcp with a transport type of SSE. Each integration may require adding the server configuration to their own settings or project configuration files.

Server connection examples and configuration

{
  "servers": {
    "stata-mcp": {
      "type": "http",
      "url": "http://localhost:4000/mcp",
      "args": []
    }
  }
}

Available tools

stata_run_selection

Run the selected Stata code from the editor and retrieve results in the editor output panel.

stata_run_file

Execute an entire Stata do-file from the editor and capture all outputs, logs, and results.