Skip to main content
Glama

run_code

Execute ad-hoc Python in a Colab runtime through a temporary cell that is deleted after use, returning plots as images; optionally keep the cell or run in background.

Instructions

Run ad-hoc Python in the notebook's runtime via a temporary cell at the end.

The cell is deleted afterwards unless keep_cell=True. Images in the output (plots) are returned as image content. background=True returns a job id.

Input Schema

NameRequiredDescriptionDefault
codeYes
keep_cellNo
backgroundNo
max_output_charsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.1

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations, the description must carry the full load, and it does disclose meaningful behavior: the temporary cell is deleted unless keep_cell=True, plots come back as image content, and background=True returns a job id. However it omits truncation behavior implied by max_output_chars=8000, whether variables persist between calls, and any error/exception reporting.

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, each carrying distinct information: execution model, cell lifecycle, and output/async behavior. Front-loaded with the core action and no filler.

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 tool with no annotations and no output schema, it covers the essentials: where the code runs, the side effect on the notebook, what output comes back, and the async escape hatch. Only truncation semantics and state persistence across calls are missing.

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 0%, so the description must compensate. It explains keep_cell and background (including that it returns a job id), but max_output_chars is never mentioned and 'code' is left entirely self-evident, leaving one of four parameters undocumented anywhere.

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?

States a specific verb and resource ('Run ad-hoc Python in the notebook's runtime') plus a distinguishing implementation detail ('via a temporary cell at the end'). This implicitly separates it from run_cells and run_notebook, but it never names those siblings, so the agent must infer the boundary.

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

Usage Guidelines3/5

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

Usage is only implied by 'ad-hoc Python' – the reader can infer this is for exploratory snippets rather than executing existing notebook cells (run_cells) or the whole notebook (run_notebook), but no explicit when/when-not or alternative routing is given. Nothing states prerequisites such as an active runtime or connection.

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