Overview
Theexecute tool runs TypeScript code in a sandboxed execution environment with access to workspace tools via the tools object. Code is executed with configurable timeouts, and results are returned synchronously by default.
Endpoint
Authentication
- OAuth (Recommended)
- API Key
Use WorkOS OAuth tokens with the Requires
/mcp endpoint:MCP_AUTHORIZATION_SERVER to be configured on the server.MCP Tool Call
MCP Request
Parameters
TypeScript code to execute. Use
return to return a value. The code has access to a typed tools object for calling external services. Console output is not returned.Maximum execution time in milliseconds (1-600000). Default is 5 minutes.
Runtime environment identifier. Defaults to workspace default runtime. Common values:
cloudflare-worker- Cloudflare Worker sandboxlocal-bun- Local Bun runtime (self-hosted only)
Optional metadata to attach to the task for tracking and filtering.
Session identifier for grouping related tasks. Used for anonymous context initialization.
Whether to wait for task completion before returning. When
false, returns immediately with task ID.Maximum time to wait for results in milliseconds (100-900000). Defaults to
timeoutMs + 30000 with a minimum of 120 seconds.Response
Array of text content objects with the execution summary.
Structured execution details.
Indicates if the execution failed (status is not
completed)Examples
Runtime Environment
The execution sandbox provides:- TypeScript support - Full TypeScript syntax and type checking
- tools object - Typed methods for calling workspace-configured external services
- No filesystem access - Use
tools.*for all external interactions - No process/import access - Pure TypeScript execution only
- Approval gates - Tool calls may require approval based on workspace policies
Tool Discovery Pattern
Error Handling
- Timeout errors - Task status becomes
timed_outif execution exceedstimeoutMs - Runtime errors - Exceptions are captured in the
errorfield with statusfailed - Approval denials - Tool calls denied by policy result in status
denied - Exit codes - Non-zero exit codes indicate execution failures
Rate Limits
Rate limits are enforced per workspace:- Default: 100 requests per minute
- Configurable via workspace settings
- Returns 429 status when exceeded