Skip to main content
Glama

run_python_code

Execute Python code in a temp file with automatic cleanup and security checks. Control working directory, environment variables, and timeout for safe, automated scripting.

Instructions

Execute inline Python code. Creates temp file, runs it, cleans up. Includes basic security checks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNoWorking directory (default: temp directory)
envNoAdditional environment variables
codeYesPython code to execute
timeout_msNoTimeout in milliseconds (default: 30000, max: 300000)

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.0.0

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations, the description carries the behavioral disclosure burden. It usefully mentions temp file creation, execution, cleanup, and 'basic security checks,' but the security checks are vague and there is no disclosure about side effects, sandboxing, or behavior on errors.

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, front-loaded with the core action, followed by process and safety notes. No filler or redundant restatement of the schema.

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

Completeness2/5

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

There is no output schema and the description does not mention what the tool returns—stdout, stderr, exit code, or result object. For an arbitrary code execution tool, missing output semantics and vague security behavior leave an agent without enough context to reliably interpret results.

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 100%, so the schema already documents code, cwd, env, and timeout_ms. The description adds no additional parameter-level meaning beyond labeling the code as 'inline' and describing the temp file workflow.

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 description states a specific verb and resource: 'Execute inline Python code.' It also adds clarifying behavior (temp file, run, cleanup) that distinguishes it from file-based tools, though it does not explicitly name siblings like run_python_script.

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?

The word 'inline' implies this is for code snippets rather than script files, which weakly distinguishes it from run_python_script. However, there is no explicit when-to-use or when-not-to-use guidance, and no alternatives are named.

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

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/For-Sunny/darkside-mcp'

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