Skip to main content
Glama

execute_python

Run persistent Python code with state that survives across calls, supports top-level await, and uses the MCP bridge to call other tools in batch.

Instructions

Persistent Python REPL — use instead of python3 -c, heredocs or cmd | python3 via Bash. Also the way to BATCH MCP WORK: the injected mcp bridge reaches your project, global (user-scope) and plugin MCP servers, so one loop replaces N separate tool calls — for f in files: mcp.call('telegram-mcp', 'download_media', **f).

State (variables, imports, functions) survives across calls: a warm call takes ~0.1s vs ~3s for each fresh python3 Bash spawn. Full filesystem access — open(), absolute paths, and ~ all work. Top-level await is supported (e.g. await client.get(url) with httpx).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesPython code to execute
resetNoClear namespace (keeps sh/mcp helpers)
timeoutNoMax execution seconds (default 120). Enforced for real: runaway code is interrupted (KeyboardInterrupt) with namespace state preserved.
Behavior5/5

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

With no annotations provided, the description carries the full burden. It discloses state persistence across calls, filesystem access, top-level await support, timeout enforcement with KeyboardInterrupt and namespace preservation, and the behavior of the reset parameter. These go well beyond what the schema offers and provide critical safety/behavioral context.

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 description is front-loaded with the core purpose ('Persistent Python REPL') and then expands with necessary details. Every sentence earns its place: performance comparison, state persistence, filesystem access, await support, and timeout behavior. It is dense yet well-structured, with no fluff.

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?

Given the tool complexity (persistent REPL, filesystem access, MCP bridge) and lack of output schema, the description covers all essential invocation details: what it does, when to use it, persistent state, async support, timeout behavior, and reset semantics. It is sufficiently complete for an agent to invoke the tool correctly.

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

Parameters5/5

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

Although schema coverage is 100%, the description adds substantial meaning to the `code` parameter by explaining persistent state, await support, and the injected `mcp` bridge, which are not conveyed by the schema's generic 'Python code to execute'. This enriches the agent's understanding of how to write effective code for this tool.

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 clearly states the tool is a persistent Python REPL, distinguishing it from one-off bash execution via `python3 -c`. It uses a specific verb ('execute') and resource ('Python code') while also noting the persistent state and MCP bridge capabilities, which clearly differentiates it from sibling tools even though none are listed.

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?

It explicitly says to use this tool instead of `python3 -c`, heredocs, or `cmd | python3` via Bash, with a concrete performance justification (warm call ~0.1s vs ~3s). It also explains when it's beneficial for batch MCP work, providing clear usage context and alternatives.

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

Install Server

Other Tools

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/iota-uz/repl-mcp'

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