Labsco
MCP SERVER

Stata MCP

by hanlulong

Run Stata do-files from your editor and let an AI assistant read the output and fix the errors.

Physical Sciences & Scientific Computing
Summary
The editor extension and the MCP endpoint are the same install — you do not wire up a server separately.

Because the server is already running once the status bar says Stata, connecting an assistant is just pointing it at localhost:4000. The practical payoff is the loop: the model writes a do-file, runs it, reads the actual Stata output, and corrects itself — which is the part that is tedious when you are pasting between windows.

What it is

An extension for VS Code, Cursor and Antigravity that adds Stata execution, syntax highlighting and a local MCP endpoint any AI client can connect to.

What you get
  • stata_run_selection — run the selected code and get the results back
  • stata_run_file — run an entire .do file
  • Real-time output in an editor panel, plus a data viewer for the loaded dataset
  • Syntax highlighting for .do, .ado, .mata and .doh files
  • Multiple Stata sessions running in parallel, and a restart that clears in-memory data, globals and programs
  • Keyboard shortcuts for run selection, run file and stop, plus an interactive browser mode for graphs
Requirements

Stata 17 or higher installed locally, and the uv package manager, which the extension installs for you if it is missing. Install the extension from the marketplace; it starts the server itself and listens on http://localhost:4000/mcp-streamable, with an SSE fallback at /mcp. First install sets up dependencies and can take a couple of minutes.

Setup effort

One command — code --install-extension DeepEcon.stata-mcp