Skip to main content
Glama

run_python

Execute Python code in a subprocess, capture stdout/stderr and generated files, and enforce a timeout for bounded, reproducible runs.

Instructions

Execute Python code in a subprocess and return captured output plus produced files.

Resource controls: code is limited to 100,000 characters; stdout and stderr
are each truncated to 20,000 characters.  On timeout the whole process tree
is terminated (Windows: ``taskkill /F /T``) and the error result carries the
output captured so far plus ``elapsed_seconds`` and changed ``files``.

On Windows the child (and its descendants) is assigned to a Job Object with
a per-process memory cap: 2048 MiB by default, overridable with the
environment variable ``SCI_MCP_SANDBOX_MEMORY_MB`` (16..65536).  Exceeding
the cap surfaces as ``MemoryError`` in ``stderr``.  If the Job Object cannot
be created or assigned, execution continues without a hard memory cap.  On
non-Windows platforms no hard memory cap is applied (the standard library
``resource`` module is not available on Windows and no portable equivalent
is used); rely on ``timeout_seconds`` and the caller's own limits there.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
timeout_secondsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so richly: 100k character code limit, 20k stdout/stderr truncation, process-tree termination on timeout, the shape of the error result (partial output plus elapsed_seconds and changed files), the Windows Job Object memory cap, the SCI_MCP_SANDBOX_MEMORY_MB override and its range, the MemoryError failure mode, the silent fallback if the Job Object cannot be created, and the explicit absence of a hard cap on non-Windows. That is exceptional disclosure of limits, failure modes, and platform differences.

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

Conciseness4/5

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

The purpose is front-loaded in the first sentence, followed by clearly delineated paragraphs on resource controls and platform-specific memory behavior. It is long, but given the absence of annotations and output schema, nearly every sentence carries necessary behavioral detail rather than filler.

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

Completeness5/5

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

For a tool with no annotations and no output schema, the description covers the return payload, truncation behavior, timeout semantics, memory-limit behavior per platform, and failure modes. An agent has enough to invoke it correctly and interpret results without further documentation.

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 coverage is 0%, so the description must compensate, and it largely does: it explains the code length ceiling (100,000 characters) and the semantics of timeout_seconds (what happens on timeout, process-tree kill, error payload). It stops short of stating the default or units explicitly beyond the schema's own default of 30.

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

Purpose4/5

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

The opening sentence gives a specific verb and resource: 'Execute Python code in a subprocess and return captured output plus produced files.' An agent immediately understands this is a general-purpose code execution tool. It does not, however, explicitly differentiate itself from the many specialized numeric siblings (fft_analysis, curve_fit, etc.), so it falls short of a 5.

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

Usage Guidelines2/5

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

The description never says when to reach for run_python versus the dozens of specialized sibling tools, nor does it name any alternative. The only guidance is implicit ('rely on timeout_seconds and the caller's own limits'), which is operational rather than a when-to-use/when-not-to-use rule.

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