Skip to main content
Glama

execute_code

Execute code snippets in a sandboxed environment, capturing stdout, stderr, exit codes, and resource usage with configurable limits.

Instructions

Execute code in language in a sandbox.

Returns stdout, stderr, exit_code, duration_ms, cpu_ms, peak_memory_kb, verdict (OK/TLE/MLE/OLE/RTE).

  • session_id: run inside a session workspace (see session_start); with a stateful session (python3/node) interpreter state persists across calls.

  • max_memory_mb / max_cpu: per-call resource ceilings.

  • max_output_kb: raise/lower the stdout cap (default 64 KiB).

  • no_net: block network egress (LD_PRELOAD shim; dynamic binaries only).

  • compact: return only verdict + stdout, drop the heavy fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
stdinNo
no_netNo
compactNo
max_cpuNo
timeoutNo
languageYes
session_idNo
max_memory_mbNo
max_output_kbNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

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 of behavioral disclosure. It thoroughly details return fields, verdict types, session persistence, resource ceilings, stdout cap, network egress blocking mechanism, and compact output behavior. This goes far beyond a minimal description and provides actionable insight into side effects and limits.

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 well-structured: a one-line purpose, a return-value summary, and a bulleted list of parameter semantics. Every sentence adds value without redundancy. The front-loading of purpose and returns makes it easy to scan, and the bullet format improves readability.

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?

The tool is complex (10 parameters, sandboxed execution, session state, resource limits), and the description covers most key aspects: return values, verdicts, session behavior, resource ceilings, stdout cap, network blocking, and compact mode. It cross-references session_start and lists limitations of no_net. It does not mention timeout or stdin, but these are implicitly understandable. Overall, it is nearly complete for the complexity involved.

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?

The input schema has 0% description coverage, so the description must compensate. It explains the meaning of 8 out of 10 parameters (code, language, session_id, max_memory_mb, max_cpu, max_output_kb, no_net, compact), leaving only stdin and timeout undocumented. Given the schema's bareness, this is a strong contribution, though a brief note on stdin/timeout would be ideal.

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 opens with a clear, specific verb+resource construction: 'Execute `code` in `language` in a sandbox.' It immediately clarifies what the tool does, and the mention of 'sandbox' distinguishes it from similar execution tools. This directly supports selection as a general code-execution tool.

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 context for when to use sessions ('run inside a session workspace... interpreter state persists across calls') and explains per-call resource controls. It does not explicitly name alternative tools for exclusion, but the guidance is sufficiently clear for an agent to know when to use this tool.

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/The-40-Thieves/codecalc'

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