Use in OpenClaw 🦞
Since OpenClaw does not natively support the MCP tool protocol, Stata-MCP provides standalone CLI tool commands that OpenClaw can use through terminal tool invocation.
Install instruction OpenClaw
Tell your OpenClaw with the following message:
Install Stata-MCP Skills from https://docs.statamcp.com/skills/openclaw
If you are OpenClaw, go to Stata-MCP Skill for OpenClaw.
Installation Manually
# Run directly with uvx (recommended)
uvx stata-mcp tool --help
# Or install and use
uv pip install stata-mcp
stata-mcp tool --help
Available Commands
ado-install - Install Stata Packages
Install ado packages from SSC, GitHub, or network sources.
# Install from SSC (default)
stata-mcp tool ado-install outreg2
# Install from GitHub
stata-mcp tool ado-install SepineTam/TexIV --source github
# Install from network
stata-mcp tool ado-install custompkg --source net --package-source-from "https://example.com/stata/"
# Don't replace existing package (useful for checking installation status)
stata-mcp tool ado-install estout --is-replace false
Parameters:
| Parameter | Description | Default |
|---|---|---|
package_name |
Package name (required) | - |
--source |
Installation source: ssc / net / github | ssc |
--package-source-from |
Source URL for net installations | - |
--is-replace |
Replace existing package files | true |
do - Execute Do-files
Execute Stata do-files and retrieve logs.
# Execute a do-file
stata-mcp tool do /path/to/analysis.do
# Specify log file name
stata-mcp tool do /path/to/analysis.do --log-file-name my_results
# Skip reading log content
stata-mcp tool do /path/to/analysis.do --is-read-log false
# Disable SMCL format logging
stata-mcp tool do /path/to/analysis.do --enable-smcl false
Parameters:
| Parameter | Description | Default |
|---|---|---|
dofile_path |
Path to do-file (required) | - |
--log-file-name |
Log filename without extension | auto-generated |
--is-read-log |
Read log content after execution | true |
--is-replace-log |
Replace existing log file | true |
--enable-smcl |
Generate SMCL format log | true |
help - Get Stata Command Help
macOS and Linux only
# Get command help
stata-mcp tool help regress
# Get panel data command help
stata-mcp tool help xtreg
stata-mcp tool help xtset
Parameters:
| Parameter | Description | Default |
|---|---|---|
stata_command |
Stata command name (required) | - |
--is-read-log |
Read output content | true |
--enable-smcl |
Generate SMCL format output | true |
data-info - Get Data Information
Analyze data files and return statistical summaries.
# Analyze a data file
stata-mcp tool data-info /path/to/data.dta
# Specify variable subset
stata-mcp tool data-info /path/to/data.csv --vars-list gdp inflation unemployment
# Specify encoding
stata-mcp tool data-info /path/to/legacy.csv --encoding latin1
Supported Formats:
- Stata: .dta
- CSV/Text: .csv, .tsv, .psv
- Excel: .xlsx, .xls
- SPSS: .sav, .zsav
Parameters:
| Parameter | Description | Default |
|---|---|---|
data_path |
Path to data file (required) | - |
--encoding |
Text encoding | utf-8 |
--vars-list |
Variable names to analyze | all variables |
read-log - Read Log Files
Read Stata log files (.log or .smcl).
# Read log (core content)
stata-mcp tool read-log /path/to/output.log
# Read full log
stata-mcp tool read-log /path/to/output.log --output-format full
# Read as structured format
stata-mcp tool read-log /path/to/output.log --output-format dict
# Specify encoding
stata-mcp tool read-log /path/to/output.log --encoding utf-8
Parameters:
| Parameter | Description | Default |
|---|---|---|
file_path |
Path to log file (required) | - |
--encoding |
File encoding | utf-8 |
--output-format |
Output format: full / core / dict | core |
Output Format Descriptions:
- full: Raw log content
- core: Cleaned content without framework lines (headers, footers, log commands)
- dict: Structured command-result pairs
Typical Workflow
# 1. Inspect data structure
stata-mcp tool data-info /project/data/raw/survey.dta
# 2. Get command help
stata-mcp tool help regress
# 3. Install required packages
stata-mcp tool ado-install outreg2
# 4. Execute analysis script
stata-mcp tool do /project/stata-mcp-dofile/analysis.do
# 5. View execution log
stata-mcp tool read-log /project/stata-mcp-log/analysis.log --output-format core
Notes
- Stata License: Requires a valid Stata installation and license
- Path Format: Absolute paths are recommended
- help Command: Only supported on macOS and Linux
- Log Location: Defaults to
<cwd>/stata-mcp-folder/stata-mcp-log/