Skip to main content
Glama

EQVPS — VPS and code sandboxes for AI agents

Run code in a sandbox

run_code
Destructive

Run a code snippet inside a sandbox and return {exit_code, stdout, stderr, timed_out, truncated, duration_ms}. language: python (Python 3.12), node (Node.js 22) or bash. Install packages first with exec_command (pip install … / npm i …). The code is passed to the interpreter on stdin, so it cannot read stdin itself. timeout seconds (default 30, max 55 per call). LONGER JOBS: set background: true — returns a task_id immediately (timeout then defaults to the sandbox's remaining lifetime); poll get_task with the returned offsets to read new output and the exit code, kill_task to stop it. The sandbox keeps billing while a task runs and is not idle-deleted. Output is capped at 1 MiB per stream for synchronous calls. Files and installed state persist between calls in the same sandbox. Requires: token + live sandbox_id. Typical: timed_out after 55 s → repeat with background: true.

Input Schema

NameRequiredDescriptionDefault
envNoOptional. Environment variables for this run only (override the ones set at create_sandbox). Example: {"DEBUG": "1"}.
codeYesRequired. Source code to run, passed to the interpreter on stdin, e.g. "print(2+2)".
timeoutNoOptional. Seconds. Synchronous: max 55. With background: true: up to the sandbox's remaining lifetime (default).
languageYesRequired. Interpreter: "python" (Python 3.12), "node" (Node.js 22) or "bash".
backgroundNoOptional. True = run as a background task and return `task_id` at once (poll get_task). Default false (wait up to `timeout`, max 55 s).
sandbox_idYesRequired. Sandbox id as returned by create_sandbox / list_sandboxes, e.g. "sb_3f2a…".

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changed
    • addedInput schema / properties / background / description
      Added value: +"Optional. True = run as a background task and return `task_id` at once (poll get_task). Default false (wait up to `timeout`, max 55 s)."
    • addedInput schema / properties / code / description
      Added value: +"Required. Source code to run, passed to the interpreter on stdin, e.g. \"print(2+2)\"."
    • changedInput schema / properties / env / description
      Previous value: -"Environment variables for this run only (override the ones set at create_sandbox)."New value: +"Optional. Environment variables for this run only (override the ones set at create_sandbox). Example: {\"DEBUG\": \"1\"}."
    • addedInput schema / properties / language / description
      Added value: +"Required. Interpreter: \"python\" (Python 3.12), \"node\" (Node.js 22) or \"bash\"."
    • changedInput schema / properties / sandbox_id / description
      Previous value: -"Sandbox id as returned by create_sandbox / list_sandboxes, e.g. \"sb_3f2a…\"."New value: +"Required. Sandbox id as returned by create_sandbox / list_sandboxes, e.g. \"sb_3f2a…\"."
    • changedInput schema / properties / timeout / description
      Previous value: -"Seconds. Synchronous: max 55. With background: true: up to the sandbox's remaining lifetime (default)."New value: +"Optional. Seconds. Synchronous: max 55. With background: true: up to the sandbox's remaining lifetime (default)."
  2. Changed1 schema field changed
    • addedInput schema / properties / env
      Added value: +{
      +  "additionalProperties": {
      +    "maxLength": 32768,
      +    "type": "string"
      +  },
      +  "description": "Environment variables for this run only (override the ones set at create_sandbox).",
      +  "propertyNames": {
      +    "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,127}$"
      +  },
      +  "type": "object"
      +}
  3. Changed4 schema fields changed
    • addedInput schema / properties / background
      Added value: +{
      +  "type": "boolean"
      +}
    • changedInput schema / properties / language / enum
      Previous value: -[
      -  "python",
      -  "bash"
      -]New value: +[
      +  "python",
      +  "node",
      +  "bash"
      +]
    • addedInput schema / properties / timeout / description
      Added value: +"Seconds. Synchronous: max 55. With background: true: up to the sandbox's remaining lifetime (default)."
    • removedInput schema / properties / timeout / maximum
      Removed value: -55
  4. Added

TDQS

A4.7/5.0
Behavior4/5

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

Annotations already declare destructive/openWorld/non-idempotent, so the bar is lower, yet the description adds genuinely new behavioral facts: code is delivered on stdin so the program cannot read stdin, 1 MiB per-stream output cap for synchronous calls, sandbox keeps billing and is not idle-deleted while a task runs, and files/installed state persist across calls. It could still note whether concurrent runs in one sandbox are allowed, but coverage is strong.

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?

Front-loads the return shape, then language, then the escalation path, then behavioral caveats. Despite its length, every clause carries an actionable fact (defaults, caps, persistence, quirks) and none restates the schema verbatim.

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?

With no output schema, the description compensates by enumerating the exact return fields and the alternate task_id return path. Combined with requirements ('token + live sandbox_id'), timeout limits, and the background polling workflow, an agent has everything needed to call this correctly on the first attempt.

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?

Schema description coverage is 100%, so baseline is 3, but the description adds semantics the schema lacks: timeout defaults to 30 (schema states no default), background changes the timeout ceiling to the sandbox's remaining lifetime, env overrides apply to this run only, and the stdin constraint bounds how `code` may be written.

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?

Opens with a specific verb+resource ('Run a code snippet inside a sandbox') and immediately names the return shape and supported languages, which distinguishes it from the many sandbox-management siblings. An agent can tell this is the execution tool, not a lifecycle tool like create_sandbox or kill_sandbox.

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?

Explicitly routes installs to exec_command, explains when to escalate to background: true, and gives a concrete failure-recovery rule ('timed_out after 55 s → repeat with background: true'). It also names the follow-up tools (get_task, kill_task) needed to consume a background job, leaving no routing decision to inference.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.