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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"language": "<language>",
"code": "<code>"
},
"name": "execute_code"
}
}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) |