Skip to main content
Glama
stata-copilot

stata-copilot

by Parado-D

Run a .do file

stata_run_do

Execute an existing Stata do-file on disk to run analyses, with optional background jobs and working directory defaults.

Instructions

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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "file": "<file>"
    },
    "name": "stata_run_do"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNoWorking directory override (default: the do-file folder).
fileYesAbsolute path to the .do file.
modeNoTighten the policy for this call.
labelNoLabel for the background job.
verifyNoFingerprint the data before and after (datasignature) and report whether it changed. In-session runs only.
timeoutNoSeconds before Stata is interrupted (1-600, default 300). Ignored in background mode, which takes up to 86400.
backgroundNoRun as a background job; returns a job id instead of the transcript.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.1

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden; it discloses that background mode returns a job id instead of waiting and that cwd defaults to the do-file folder, which is genuinely useful async behavior. It omits what a synchronous call returns (transcript? errors?), what the mode policies open/guarded/readonly actually restrict, and that execution mutates Stata session state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences, front-loaded with the core action, then prerequisites, then the background flag. No filler or repetition of the title.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 7-parameter code-execution tool with no annotations and no output schema, the primary path and the async path are covered. However, the return shape of a normal run, failure behavior, and the semantics of the policy/verify parameters are left entirely to the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3; the description restates the cwd default and adds the meaningful behavioral note that background changes the return type. It says nothing extra about mode, verify, label, or the timeout/background interaction, which the schema already handles.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

"Execute an existing do-file" is a specific verb plus resource, and the parenthetical explicitly separates it from the sibling stata_run by warning agents not to push a giant code string through that tool. An agent can choose between the two without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives a real precondition (the file must already exist on disk) and a recommended workflow (write the file first, then run it), plus when to set background:true. It does not connect background mode to the stata_job_list/stata_job_status/stata_job_submit siblings that presumably inspect or manage those job ids, leaving one routing decision implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.