Skip to main content
Glama

stata_run

Execute Stata code in a persistent session and get cleaned output plus return code. Supports synchronous or background runs for long commands.

Instructions

执行一段 Stata 代码(保持会话状态),返回清洗后的输出文本与 rc。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes要交给 Stata 执行的命令或代码块(多行可包含循环/临时变量,共享同一持久会话的内存状态)。
backgroundNotrue 时命令在后台执行、立即返回 job_id,用 stata_task_status 轮询结果、stata_break 打断;false(默认)同步执行。长命令(bootstrap/混合模型等)建议用 true。
restrictedNo受限模式:拦截 shell 逃逸(shell/winexec/!)、文件删除(erase)、越权文件路径。省略用 config[security].restricted_mode(默认 false)。
session_idNo会话标识;省略用 'default'。不同 session 相互隔离(各自独立 Stata)。

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.0.0

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden and reveals substantial behavior: session persistence across calls, cleaned output production, background execution returning job_id immediately, restricted mode intercepting shell escapes (shell/winexec/!), erase, and unauthorized paths, and session isolation via independent Stata instances. Error/exception behavior and the exact result shape are not disclosed, which keeps it from a 5.

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?

The main description is a single front-loaded sentence with zero filler, stating action, key behavior, and return value. The four parameter descriptions are thorough but each sentence earns its place by adding behavioral semantics, defaults, recommendations, or sibling routing.

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

Completeness4/5

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

For a moderately complex execution tool with no annotations and no output schema, the definition covers purpose, session-state semantics, async workflow, security interception, and session isolation. The main gap is the lack of a precise return-format/error-behavior description (what the cleaned output object looks like, what happens on a non-zero rc), which matters more because there is no output schema.

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

Parameters4/5

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

Schema description coverage is 100% with rich, behavior-oriented descriptions: code explains multi-line loops and shared memory state, background names the polling/interrupt siblings and suggests async for long commands, restricted details the security config fallback, and session_id explains isolation with independent Stata instances. The tool description adds the rc return concept, complementing the schema. This exceeds the baseline 3 for high coverage.

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?

The description uses a specific verb and resource — '执行一段 Stata 代码' (execute a block of Stata code) — and states the distinguishing traits: it maintains session state across calls and returns cleaned output text plus rc. This clearly differentiates it from the sibling tools (stata_break, stata_task_status, stata_get_help, etc.), which are all secondary or query operations.

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?

The main description implies this is the primary execution tool, and the background parameter gives clear operational guidance: use true for long commands (bootstrap/mixed models) and route to stata_task_status/stata_break for polling and interruption. There is no explicit 'when not to use' statement, but the context for choosing sync vs. async is clear.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/horizonial/stata-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server