Skip to main content
Glama

run_code

Execute Python code interactively to get stdout, results, and PNG images for quick experiments. Use for short tasks, not long training runs.

Instructions

Execute Python on the runtime; returns stdout/results plus any PNG images.

For quick, interactive work. Do NOT run long training here — it will hit the timeout. Use launch_training for anything that takes minutes.

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": {
      "code": "<code>"
    },
    "name": "run_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
timeoutNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.0

TDQS

A4.1/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 and does disclose two important traits: execution returns stdout/results plus PNGs, and long jobs will hit a timeout and fail. However, it omits critical behavior for a code-execution tool — whether the runtime is stateful (do variables/files persist between calls?), what happens on non-zero exit or exception, and whether code runs sandboxed with network/filesystem access.

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 with the primary action and return value front-loaded, followed by the scoping constraint and the escape hatch. No filler, no restatement of the tool name.

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?

With no output schema and no annotations, the description does cover return shape (stdout/results/PNG) and the timeout failure mode, which is most of what an agent needs to call it safely. The remaining gap is runtime statefulness and error semantics, which matters given the interactive-use framing it promotes.

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

Parameters2/5

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

Schema description coverage is 0% and neither parameter is documented in the schema beyond bare titles, so the description must compensate. It only hints that timeouts exist as a concept; it never explains the `timeout` parameter, its units (seconds), its 120 default, or what `code` accepts (script vs. expression, top-level await).

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?

States a specific verb and resource ("Execute Python on the runtime") and also names the return payload (stdout/results plus PNG images), so an agent knows both what it does and roughly what it gets back. It explicitly separates itself from launch_training, making the boundary resolvable without opening the schema.

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

Usage Guidelines5/5

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

Gives an explicit when ("For quick, interactive work"), an explicit when-not ("Do NOT run long training here — it will hit the timeout"), and the concrete alternative ("Use launch_training for anything that takes minutes"), including the threshold that selects it. Nothing is left to inference.

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