execute_code
Run Python, JavaScript, or TypeScript code in a secure sandbox, optionally install packages, and get output, errors, and execution time for testing or data processing.
Instructions
Execute code in a secure isolated sandbox. Supports Python, JavaScript, and TypeScript.
The code will be executed in a temporary environment that is cleaned up after execution. You can optionally install packages before execution.
Use this when you need to:
Run code to get results or test functionality
Process data dynamically
Validate code behavior
Install and use external packages
Returns execution results including output, errors, and execution time.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The code to execute. Code has full read/write access to its workspace directory. | |
| timeout | No | Execution timeout in milliseconds (default: 30000ms, max: 300000ms) | |
| language | Yes | Programming language to execute | |
| packages | No | Optional packages to install before execution (must be whitelisted - use list_allowed_packages) | |
| useCache | No | Use persistent cache for identical code (default: true). Cached results are instant. | |
| description | No | Brief description of what the code does (e.g., "fetch GitHub API data"). Used for semantic caching - similar tasks may return cached results even if code differs. | |
| allowNetworking | No | Allow network access (default: true) |