About Stata
Stata is an MCP server published by tmonk in the AI category: 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. Conduid read 20 tools from its source: stata_compare_specs, stata_control, stata_discover_tests, stata_doctor, stata_estimation_plan, stata_get_help and 14 more. It is published to PyPI as mcp-stata and runs with uvx.
The repository has 92 stars and 21 forks, is licensed AGPL-3.0, and its last commit was on 12 May 2026. The latest release is v3.3.0 (10 May 2026): Bug Fixes mcp: Omit duplicate structured tool JSON by default (#55, e8e1a53) Chores Sync toolkit_catalog_data and lockfile to 3.2.8 (7b8fedd) Features… It follows v3.2.9 (10 May 2026), and the 5 most recent releases go back to v3.2.6 (10 May 2026). It passes 4 of the 6 static checks Conduid ran on the repository; it does not pass No dynamic code execution and Scoped permissions. Its topics include econometrics, stata and economics.
Install
claude mcp add stata -- uvx --refresh --refresh-package mcp-stata --from mcp-stata@latest mcp-statauvx --refresh --refresh-package mcp-stata --from mcp-stata@latest mcp-statauvx mcp-statapip install mcp-statagit clone https://github.com/tmonk/mcp-stataTools (20)
stata_compare_specsRun multiple estimation commands and compare their stored result summaries.| Parameter | Type | Description |
|---|---|---|
| alternative_commands * | array | |
| as_json | boolean | |
| base_command * | string | |
| session_id | string |
stata_controlInterrupt a session or cancel a background task.| Parameter | Type | Description |
|---|---|---|
| action * | string | The control action to perform: - "break": Sends a BREAK signal to the specified Stata session. - "cancel": Terminates the execution of a background task. |
| as_json | boolean | |
| id * | string | Either the `session_id` (for "break") or the `task_id` (for "cancel"). |
stata_discover_testsList all discoverable test files under path without running them.| Parameter | Type | Description |
|---|---|---|
| path * | string |
stata_doctorRun a deterministic environment and smoke-test diagnostic for mcp-stata.| Parameter | Type | Description |
|---|---|---|
| as_json | boolean | |
| session_id | string |
stata_estimation_planBuild a structured estimation plan and recommended Stata command.| Parameter | Type | Description |
|---|---|---|
| as_json | boolean | |
| cluster_var | string | |
| controls | array | |
| dependent_var * | string | |
| estimator | string | |
| fixed_effects | array | |
| independent_vars * | array | |
| session_id | string |
stata_get_helpReturns help for a Stata command.| Parameter | Type | Description |
|---|---|---|
| as_json | boolean | |
| format | string | |
| legacy_text | boolean | |
| merge_paragraphs | boolean | If True, merges fixed-width split paragraphs. |
| plain_text | boolean | If True, returns plain text instead of Markdown. |
| session_id | string | The ID of the Stata session. |
| topic * | string | The command or topic to get help for. |
stata_get_resultsReturns coherent structured result state across r()/e()/s(), with optional MATA snapshot.| Parameter | Type | Description |
|---|---|---|
| as_json | boolean | |
| include_formatting | boolean | |
| include_mata | boolean | |
| include_matrices | boolean | |
| matrix_max_cols | integer | |
| matrix_max_rows | integer | |
| session_id | string |
stata_get_test_resultsReturn full structured results from the last test run for a session.| Parameter | Type | Description |
|---|---|---|
| session_id | string |
stata_inspect_dataInspect the active dataset (describe, codebook, summarize, search, get data) or code (lint).| Parameter | Type | Description |
|---|---|---|
| action * | string | The inspection action to perform: - "describe": Returns dataset structure and variable types. - "codebook": Detailed description of a specific variable's contents. - "summary": Descriptive statistics (mean, sd, etc.) for variables. - "search": Finds variables matching a name or label pattern. - "list": Returns a structured list of all variables in the dataset. - "get": Retrieves raw data observations from the dataset. - "lint": Performs static analysis on a .do or .ado file. |
| as_json | boolean | |
| compress_numeric | boolean | |
| count | integer | Number of observations to retrieve for the "get" action. |
| include_missing | boolean | |
| indent | integer | (For "lint") Required indentation size (default 4). |
| legacy_text | boolean | |
| linemax | integer | (For "lint") Maximum line length (default 80). |
| path | string | (For "lint") Absolute path to the file to check. |
| query | string | Search term for the "search" action or variable name for "codebook". |
| session_id | string | The ID of the Stata session to inspect. |
| start | integer | 0-indexed starting observation for the "get" action. |
| strip_smcl | boolean | If True, removes Stata SMCL tags from text-like outputs. |
| variables | array | Optional list of variables to include in the "summary" action. |
stata_load_dataLoads a dataset into a Stata session.| Parameter | Type | Description |
|---|---|---|
| allow_unsafe_paths | boolean | |
| as_json | boolean | If True, returns a structured JSON response envelope. |
| clear | boolean | If True (default), clears any existing data in memory before loading. |
| max_output_lines | integer | Optional limit on the number of output lines to return. |
| raw | boolean | If True, returns only the raw Stata output or error message. |
| session_id | string | The ID of the Stata session to load data into. |
| source * | string | Path to the dataset file or a valid Stata sysuse/webuse name. |
| strip_smcl | boolean | If True, removes Stata SMCL tags from the output for readability. |
stata_manage_graphsManage Stata graphs (list, export).| Parameter | Type | Description |
|---|---|---|
| action * | string | The graph management action: - "list": Returns a JSON list of all graphs currently in memory. - "export": Saves a specific graph to a file. - "export_all": Exports all graphs in memory to files. |
| as_json | boolean | |
| format | string | The file format for export (svg, pdf, png). Defaults to "svg". |
| graph_name | string | The name of the specific graph to export (used with "export"). |
| session_id | string | The ID of the Stata session to manage graphs from. |
stata_manage_sessionManage Stata sessions (create, stop, list, profile, UI channel, detect).| Parameter | Type | Description |
|---|---|---|
| action * | string | The management action to perform: - "create": Initializes a new Stata session. - "stop": Terminates an existing Stata session. - "list": Returns a JSON list of all active sessions. - "set_profile": Executes initialization code for a session. - "history_diff": Returns tracked session state changes. - "history_stats": Returns retained history window metadata. - "get_ui_channel": Retrieves connection details for the UI proxy. - "detect": Returns metadata about the Stata installation and environment. |
| as_json | boolean | |
| code | string | Stata code to execute when using the "set_profile" action. |
| include_packages | boolean | If True (for "detect"), lists all user-installed packages. |
| session_id | string | Unique identifier for the Stata session (defaults to "default"). |
| since_command | integer | Optional command index for "history_diff". If omitted, compares to the last diff checkpoint for this session. |
stata_project_reproducibility_reportSummarize project reproducibility signals, environment state, and recent task history.| Parameter | Type | Description |
|---|---|---|
| as_json | boolean | |
| project_root | string | |
| session_id | string |
stata_publication_checkReview active estimation results and graphs for publication readiness.| Parameter | Type | Description |
|---|---|---|
| as_json | boolean | |
| graph_names | array | |
| session_id | string |
stata_read_logRead or search Stata log files.| Parameter | Type | Description |
|---|---|---|
| after | integer | Number of lines after a match to include as context. |
| as_json | boolean | |
| before | integer | Number of lines before a match to include as context. |
| case_sensitive | boolean | If True, performs a case-sensitive search. |
| max_bytes | integer | Maximum number of bytes to read from the log (defaults to 256kb). |
| max_matches | integer | Limit on the number of search results returned. |
| offset | integer | Starting byte position for the read operation. |
| path | string | Optional absolute path to the log file on disk. |
| query | string | Search string or regular expression to find within the log file. |
| regex | boolean | If True, treats the `query` as a regular expression. |
| tail_lines | integer | If > 0, returns the last N lines of the log, overriding offset. |
| task_id | string | Optional ID of a background task to read the log for (alternative to path). |
stata_research_auditRun a compact structured dataset audit for empirical research workflows.| Parameter | Type | Description |
|---|---|---|
| as_json | boolean | |
| candidate_id_vars | array | |
| include_publication_checks | boolean | |
| key_variables | array | |
| session_id | string |
stata_runExecutes Stata code or a .do file.| Parameter | Type | Description |
|---|---|---|
| allow_unsafe_paths | boolean | |
| as_json | boolean | If True, returns a structured JSON response envelope. |
| background | boolean | If True, runs the operation in the background. Requires immediate follow-up with stata_task_status(wait=True). |
| code * | string | The Stata command string or the absolute path to a .do file. |
| cwd | string | Optional working directory for the Stata process during execution. |
| echo | boolean | If True, includes the original command in the captured output. |
| exclude_pattern | string | Optional regex to omit matching lines from the output. |
| filter_pattern | string | Optional regex to include only matching lines in the output. |
| is_file | boolean | If True, the `code` parameter is treated as a path to a script file. |
| max_output_lines | integer | Optional limit for the number of lines returned in synchronous mode. |
| raw | boolean | If True, returns only the raw text output or error message. |
| read_only | boolean | |
| session_id | string | The ID of the Stata session to use (defaults to "default"). |
| strip_smcl | boolean | If True, removes Stata SMCL tags from the output for readability. |
| trace | boolean | If True, enables Stata trace mode for debugging. |
stata_run_testRun a single test_*.do file.| Parameter | Type | Description |
|---|---|---|
| path * | string | Path to the test file. |
| session_id | string | Optional ID of an existing session to run the test in. If omitted, a fresh session is used. |
stata_run_testsDiscover and run all test_*.do files under path.| Parameter | Type | Description |
|---|---|---|
| junit_xml_path | string | Optional path to save results in JUnit XML format. |
| max_workers | integer | Maximum number of parallel workers (default 4). |
| parallel | boolean | If True, run tests in parallel using multiple sessions. |
| path * | string | Directory path to search for tests. |
| session_id | string | Optional ID of an existing session to run tests in. If omitted, fresh sessions are used for each test. |
stata_task_statusReturn task status for background executions.| Parameter | Type | Description |
|---|---|---|
| as_json | boolean | |
| poll_interval | number | Delay between checks (in seconds) when waiting for completion. |
| tail_lines | integer | Lines of log to include in the response. Set based on how much output you expect: 0 if you plan to call stata_read_log separately, 20-50 for quick spot-checks, 100+ for verbose scripts where you want the full tail inline. |
| task_id * | string | The unique identifier of the background task to query. |
| timeout | number | Maximum seconds to wait. Set based on expected runtime: short commands ~30s, typical do-files ~120s, large dataset jobs ~600s. If uncertain, use a moderate value and loop on status='timeout' rather than setting an artificially high ceiling. |
| wait | boolean | If True, the call will block until the task finishes or the timeout is reached. |
Security checks
Static checks derived from the repository 10 days ago. Heuristics on the source, not an audit.
- ✓README presentThe repository's README runs to about 2.7K words.
- ✓License declaredThe repository declares the AGPL-3.0 license.
- ✓Tests presentA test suite exists in the repository.
- ✓Dependencies pinnedDependency versions are pinned by uv.lock.
- !No dynamic code executionScanned 28 source files and found 4 calls to eval or shell execution, in src/mcp_stata/stata_client.py:4602, src/mcp_stata/stata_client.py:686 and src/mcp_stata/stata_client.py:1029 among others. Review how tool inputs reach them before granting credentials.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
What the source scan found
- Transport
- stdiosrc/mcp_stata/server.py:2697
- Starts other programs
- 5 callssrc/mcp_stata/discovery.py:709, src/mcp_stata/stata_client.py:686, src/mcp_stata/stata_client.py:1029
- Outbound network calls
- 4 callsworker/dashboard/server.py:99, worker/dashboard/server.py:127, worker/src/index.js:58
- Writes or deletes files
- 15 callssrc/mcp_stata/discovery.py:580, src/mcp_stata/stata_client.py:383, src/mcp_stata/stata_client.py:3071
- Lockfile
- uv.lock
Pattern matches on the source text of 28 files: places to read, not proof of what the code does at run time.
Releases
README
The repository's README runs to about 2.7K words, fetched a month ago. The original in the repository is authoritative.
Read full README