• EXECUTION
  • CLEANUP
  • SECURITY
  • HUMAN

How to run code in isolated sandboxes with your AI

Connect E2B to your agent to give it a safe place to run scripts. Once connected, the agent handles the environment setup and cleanup for you.

Ask AI about this page

Short answer

Can my AI run code safely?

Yes. Your agent uses E2B to spin up ephemeral Linux sandboxes where it can execute code without touching your local files. This setup provides a clean, isolated environment for every task.

The outcomes.

Where your code execution lands.

The agent manages the lifecycle of every execution environment.

EXECUTION

Isolated runtimes

The agent creates a fresh Linux environment for your script. This keeps the code away from your personal files and OS.

CLEANUP

Automatic disposal

Once the task finishes, the agent destroys the environment. You don't have to worry about leftover processes or messy files.

SECURITY

Protected system

Because the code runs in a sandbox, it cannot access your local machine. Your data stays private and untouched.

HUMAN

Manual review

You decide which scripts are safe to run. The agent waits for your permission before executing sensitive logic.

The workflow

What your AI does when code execution is requested.

The agent handles the heavy lifting of environment management.

  1. Provisioning

    The agent requests a fresh, isolated Linux environment to host the upcoming code execution.

    create_sandbox
  2. Execution

    The agent runs the requested Python or JavaScript code within the active sandbox.

    create_sandbox
  3. Verification

    The agent checks the output or logs from the sandbox to ensure the code worked as intended.

    create_sandbox
  4. Destruction

    The agent wipes the environment completely once the work is done to prevent resource leaks.

    kill_sandbox

Try it

Copy these to start.

Use these prompts to trigger code execution in a sandbox.

Starting points

Replace the bracketed text with your specific data or script requirements.

E2B Connector

You're all set. Choose your MCP client and follow the setup instructions.

Connector linkhttps://edge.vinkius.com/vk_preview_3CRPqmTDsCByQOyZDcriXUCwkogoOvQeH8PdgsKD/mcp

Claude Desktop

Follow the steps below to connect in seconds.

  1. 1In Claude Desktop, open Settings → Connectors.
  2. 2Click “Add custom connector” and paste the connector link above as the remote MCP server URL.
  3. 3Click Add and start a new chat — E2B capabilities are ready to use.
Configuration · claude_desktop_config.jsonCopy
{
  "mcpServers": {
    "e2b-mcp": {
      "url": "https://edge.vinkius.com/vk_preview_3CRPqmTDsCByQOyZDcriXUCwkogoOvQeH8PdgsKD/mcp"
    }
  }
}
Copy into chat04
  • Create a sandbox and run a Python script to calculate the Fibonacci sequence up to 100.

  • Spin up an environment to analyze the data in this CSV file using pandas.

  • Run a quick bash command in a sandbox to check the version of installed packages.

  • Set up a sandbox to execute this JavaScript snippet and return the result.

  • Claude
  • ChatGPT
  • Cursor
  • VS Code
  • Windsurf
  • Claude Code
  • JetBrains
  • Cline

Start here

Connect E2B once, then ask.

One click connects the MCP to your client. Your credentials stay encrypted, and you can find the full tool list on the Connector page.

Connect E2B to your AI

FAQ

How the sandbox behaves

  • 01

    Can the AI access my local files?

    No. The code runs in an isolated sandbox that has no access to your local machine or files.

  • 02

    Does the sandbox stay active forever?

    No. The agent uses the kill tool to destroy the environment once the task is finished.

  • 03

    Can the AI install new libraries?

    Yes, the agent can install necessary packages within the sandbox during the session.

  • 04

    Can the AI delete files on my computer?

    No. The agent is physically restricted to the sandbox environment.

  • 05

    What happens if the code crashes?

    The sandbox captures the error logs, and the AI can then decide whether to fix the code or kill the environment.

  • More questions about E2B? The Connector page answers them. See everything the E2B Connector can do

Connect E2B to Claude, Cursor, ChatGPT & more