SepineTam/mcp-for-stata / plugins/stata-toolbox/skills/stata-skill
stata-skill
FlaggedA packaged Stata Runner skill via official MCP-for-Stata server including stata_do, ado_package_install, help, read_log and get_data_info tools. Use it when (1) need to execute Stata do-file; (2) missing ado-packages; (3) find code error caused by syntax in Stata; (4) want to read smcl and text format log file with rich text output; (5) first encounter a data file and want to understand its structure and content.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.6 KB |
| examples/esttab-senior-guidance.md | markdown | 3.6 KB |
| examples/graph-export-guidance.md | markdown | 1.9 KB |
| references/ado_package_install.md | markdown | 4.2 KB |
| references/get_data_info.md | markdown | 4.0 KB |
| references/help.md | markdown | 2.4 KB |
| references/installation.md | markdown | 2.5 KB |
| references/read_log.md | markdown | 2.4 KB |
| references/stata_do.md | markdown | 2.6 KB |
references/stata_do.md
View on GitHub# `stata_do`
Execute a Stata do-file and return the log file paths and optionally the log content.
## Parameters
| Parameter | Type | Required | Default | Description |
|:---|:---|:---|:---|:---|
| `dofile_path` | `str` | Yes | — | Absolute path to the `.do` file to execute |
| `log_file_name` | `str` | No | auto-generated | Custom log filename without timestamp |
| `read_log_when_error` | `bool` | No | `false` | Only return log content when a Stata return-code error is detected |
| `is_replace_log` | `bool` | No | `true` | Overwrite existing log files |
| `enable_smcl` | `bool` | No | `true` | Also generate `.smcl` log (Unix only) |
## Returns
```json
{
"log_file_path": {
"text": "/path/to/logfile.log",
"smcl": "/path/to/logfile.smcl"
},
"log_content": {
"text": "...",
"smcl": "..."
}
}
```
`log_content` is only present when `read_log_when_error=true` **and** a Stata error is detected.
## When to Use
- Running Stata commands, performing regression or statistical analysis
- Executing any pre-written do-file
- Re-running a do-file after fixing errors
## Security Boundary
The do-file **must** be within one of the following directories:
- `<WORKING_DIR>/.statamcp/stata-mcp-dofile/`
- `<WORKING_DIR>` (the configured working directory)
Files outside these directories are rejected.
## Security Guard
Enabled by default (`STATA_MCP__IS_GUARD=true`). The guard scans the do-file before execution and blocks dangerous commands including:
- `shell` / `sh`, `xshell`, `winexec`, `unixcmd`
- `erase` / `era`, `rm`, `rmdir`
- `!` (system command prefix)
- `copy`, `run`, `do`, `include` (when used to execute external files)
The guard also detects macro expansion bypasses where dangerous commands are hidden inside local macros.
## SMCL Log
When `enable_smcl=true` (default) on Unix systems, a `.smcl` log is generated alongside the `.log` file. SMCL preserves hyperlinks from commands like `findsj` and `getiref`. On Windows, SMCL generation is silently skipped.
## Example
```python
# Step 1: Write the do-file
stata_code = """
use "data.dta", clear
regress y x1 x2 x3
esttab using "results.csv", replace
"""
# Use Write tool to save to /path/to/project/stata-mcp-dofile/analysis.do
# Step 2: Execute
stata_do(dofile_path="/path/to/project/stata-mcp-dofile/analysis.do")
```
## Environment Variables
| Variable | Default | Description |
|:---|:---|:---|
| `STATA_MCP__IS_GUARD` | `true` | Enable security guard validation |
| `STATA_MCP__IS_MONITOR` | `false` | Enable RAM monitoring |
| `STATA_MCP__RAM_LIMIT` | `-1` | Maximum RAM in MB (`-1` = no limit) |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |