Skip to main content
Glama
blurxy
by blurxy

run_python

Run Python code directly via stdin and get stdout, stderr, and exit code. Preserves quotes, f-strings, and backslashes exactly, ideal for executing scripts with complex syntax.

Instructions

Execute Python code and return its stdout, stderr and exit code.

The code is fed to the interpreter over STDIN, so it is never parsed by a shell or split into argv. Write it exactly as it would appear in a .py file: f-strings, nested quotes and backslashes all survive verbatim.

Runs in the working directory (PY_EXEC_CWD or cwd), which is also prepended to PYTHONPATH so the project's own packages import. timeout_s is clamped to [1, PY_EXEC_MAX_TIMEOUT]; on timeout, whatever was produced is still returned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
timeout_sNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/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 return values, input delivery mechanism, absence of shell parsing, working directory, PYTHONPATH prepending, timeout clamping, and partial output on timeout. This is substantial, though it does not mention broader execution sandbox limits or side-effect risks.

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 information-dense sentences with no filler. The core purpose is front-loaded, followed by necessary execution details. Every sentence earns its place.

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 2-parameter execution tool, the description covers return values, input handling, working directory, import path, and timeout behavior. It is mostly complete, though details like available packages or Python version are left to the environment. The output schema also exists to document return format.

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 0%, so the description must compensate. It does: 'code' is clarified with verbatim escaping guidance, and 'timeout_s' is explained with clamping range and timeout behavior. It does not restate the default value, but that is already in the schema.

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 opening sentence states a specific verb and resource: 'Execute Python code and return its stdout, stderr and exit code.' This unambiguously identifies the tool's function. With no sibling tools, differentiation is unnecessary.

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 description gives clear practical guidance: code is fed via STDIN, not shell-parsed, so it should be written as in a .py file. It also explains the working directory and PYTHONPATH behavior. There are no sibling alternatives to contrast against, but the usage context is explicit.

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

Deploy Server

Other Tools