Skip to main content
Glama
stata-copilot

stata-copilot

by Parado-D

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
STATA_COPILOT_LOGNoLog level for stderr output.info
STATA_COPILOT_MODENoSafety mode: open, guarded, or readonly.guarded
STATA_COPILOT_ROOTSNoPath-separator separated working-directory allow-list. No cwd restriction when unset.
STATA_COPILOT_DRIVERNoDriver selection: auto picks pystata when Stata and Python are found, else http.auto
STATA_COPILOT_PYTHONNoPython interpreter that can import pystata. Defaults to python on PATH.
STATA_COPILOT_EDITIONNoStata edition: mp, se, or be.mp
STATA_COPILOT_TIMEOUTNoPer-call timeout in seconds.120
STATA_COPILOT_ENDPOINTNoEndpoint for the optional HTTP driver.http://127.0.0.1:19522
STATA_COPILOT_NO_LEDGERNoDisable the run ledger. Ledger is on by default.
STATA_COPILOT_STATA_EXENoStata executable used by background jobs.D:\StataMP-64.exe
STATA_COPILOT_MAX_OUTPUTNoMaximum number of transcript characters returned.20000
STATA_COPILOT_STATA_HOMENoThe folder holding mp-64.dll (e.g. D:/). Auto-detected when not set.
STATA_COPILOT_JOB_TIMEOUTNoTimeout in seconds per background job.1800

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

Stata analysis over MCP.

  • Call stata_status first; it tells you whether Stata is reachable and ready.

  • Prefer stata_run_do over stata_run for anything longer than a couple of lines: write a numbered .do file, run it, keep it.

  • Use stata_model for regressions; it returns b/se/t/p per term instead of a transcript to read.

  • Use stata_profile_data before modelling to learn types, labels and missingness.

  • Call stata_graphs after a run that exported a PNG: the image comes back as an attachment.

  • Raise timeout for bootstrap/simulation loops; call stata_break if a run hangs.

  • Every run is appended to /.stata-copilot/runs.jsonl; stata_history reads it back.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}

Tools

Functions exposed to the LLM to take actions

NameDescription
stata_statusA

Report the Stata session state: service reachability, Stata path/version/edition, licence, whether a command is running, and the active policy mode. Call this first when a Stata tool fails.

stata_runA

Execute a block of Stata commands in the live session and return structured results: success, return code, output transcript (truncated), generated graphs, and policy warnings. Set cwd when the code uses relative paths, and raise timeout for bootstrap/simulation loops.

stata_run_doA

Execute an existing do-file. The file must already exist on disk (agents should write the file, not push a giant string through stata_run). cwd defaults to the do-file's folder. Set background:true to run it as a separate Stata process and get a job id back instead of waiting.

stata_resultsA

Return the macros left behind by the last command: r() from summarize/tabulate-style commands, e() from estimation, s() from sreturn. Use it to turn a transcript into numbers.

stata_profile_dataA

Describe the data the session is holding: source file, observations, variables, and for each variable its type, display format, variable label and number of missing values. Optionally load a dataset first (Stata sysuse name or a file path).

stata_modelA

Run one estimation command (e.g. "regress price mpg weight" or "xtreg y x, fe vce(cluster id)") and return a structured coefficient table — b, se, t/z, two-sided p per term — plus fit statistics. Use this instead of reading a regression table out of the transcript.

stata_graphsA

Return Stata graphs as images the agent can actually look at. Defaults to the graphs produced by the most recent run; pass explicit file paths to fetch older ones. PNG/JPEG are returned as image content; SVG-only output is reported by path.

stata_breakA

Send a break signal to Stata. Use after a timeout or runaway loop; then verify with stata_status that busy is false before running anything else.

stata_historyA

List commands executed through this server (newest last), with success, return code, duration and cwd. The same rows are appended to <cwd>/.stata-copilot/runs.jsonl — a reproducibility trail for the paper.

stata_lintA

Check Stata code for constructs that run without an error yet do the wrong thing: the if command (first observation only), _n without a sort, gen on an existing variable, undeclared locals, missing(a b c) as a varlist, variable abbreviation left on. Pass code or file. Errors block, warnings do not: the caller decides.

stata_signatureA

Read the datasignature fingerprint of the dataset currently in memory: observations, variables, two data hashes, and the sort order. Compare two fingerprints to prove whether a command or do-file changed the data. Optionally load a .dta first.

stata_job_submitA

Run a do-file as its own Stata process and return a job id immediately. Use this for analyses that take longer than a couple of minutes: the HTTP service is single-threaded (it answers 409 while busy) and caps each call, while a job has no ceiling and leaves the interactive session free. Poll with stata_job_status.

stata_job_statusA

Report one background Stata job: state (running/ok/failed/timedout/killed), elapsed time, return code, the first Stata error if the do-file aborted, and the tail of its log. Call it in a loop with a pause between calls instead of blocking on a long run.

stata_job_logA

Return the tail of the log a background job is writing (Stata batch writes .log next to the do-file). Use it to see progress —counts, the current table, a long imputation step —while the job is still running.

stata_job_killA

Terminate a background Stata job by its id and return the final state. Prefer this over guessing: a stuck imputation or an accidental while loop is one call away from being stopped, and the log written so far is kept.

stata_job_listA

List the background Stata jobs recorded under the given working directory, newest first, with their state and duration. Use it after a restart to find a job whose id you no longer have.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A4/5.0

Scored across 16 tools

Disambiguation4/5

Most tools have crisp, distinct roles (run code, fetch results, inspect graphs, break, lint, fingerprint), and descriptions explicitly steer away from each other. A few boundaries blur: stata_run_do with background:true overlaps stata_job_submit, and stata_job_status already returns the log tail that stata_job_log also returns; stata_results (e() macros) and stata_model (structured coefficient table) also partly overlap for estimation output.

Naming Consistency5/5

Every tool uses the same stata_ prefix followed by a snake_case noun or verb_noun form (stata_run_do, stata_job_status, stata_profile_data), with the job family nested consistently under stata_job_*. No casing or verb-style drift anywhere in the set.

Tool Count4/5

16 tools is at the upper edge but each earns its place: execution, introspection, diagnostics, and a coherent background-job lifecycle. The job family (list/submit/status/log/kill) accounts for five tools and is arguably a bit granular, but nothing is trivial or redundant enough to cut.

Completeness5/5

The domain is a live Stata session, and the surface covers it end to end: status/health, foreground and background execution, do-files, macro results, data profiling and fingerprinting, graphs as images, estimation tables, linting, history/reproducibility, interrupt, and job management. Only marginal gaps remain (e.g. explicit data load/clear or session restart helpers), which arbitrary code execution and stata_profile_data's optional load largely absorb.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues