• MONITOR
  • CLEANUP
  • CONTROL
  • HUMAN

How to manage active code environments with your AI

Connect E2B to your agent to give it direct control over its execution environments. You can track what's running and kill stale instances.

Ask AI about this page

Short answer

How can my AI manage its own code sandboxes?

Your agent uses E2B tools to see a list of all currently active sandboxes and terminate any that are no longer needed. This prevents runaway resource consumption by cleaning up microVM instances. You get full visibility into the lifecycle of every environment your agent spins up.

Resource management outcomes

Where your resources land.

What happens when your agent manages its environments.

MONITOR

Active environment visibility

The AI checks which sandboxes are currently alive. You get a clear view of every running microVM instance.

CLEANUP

Stop resource leaks

Your agent identifies and shuts down idle environments. This keeps your usage low and prevents ghost processes.

CONTROL

Manual instance termination

You can tell your agent to kill a specific sandbox immediately. This is useful if a process hangs or goes rogue.

HUMAN

User-led intervention

The AI won't delete environments without your direction. You stay in the loop for any major cleanup tasks.

The workflow

What your AI does when sandboxes are running.

The agent handles the heavy lifting of tracking and pruning execution environments.

  1. Audit active instances

    The agent scans the E2B environment to find every running sandbox. It builds a list of IDs and statuses.

    list_sandboxes
  2. Identify stale environments

    The agent compares running sandboxes against its current task list. It flags any that are no longer serving a purpose.

    list_sandboxes
  3. Terminate specific sandboxes

    Once an environment is identified as unnecessary, the agent sends a command to shut it down.

    kill_sandbox
  4. Confirm cleanup

    The agent re-verifies the environment list to ensure the microVM was successfully removed.

    list_sandboxes

Try it

Copy these to start.

Use these prompts to begin managing your environments.

Starting points

These are starting points. Swap out the specific sandbox IDs or task names to match your current session.

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
  • List all my active sandboxes so I can see what's running.

  • Check for any idle sandboxes and kill the one with ID sb-12345.

  • Find all sandboxes that were created for the Python data analysis task and shut them down.

  • Are there any sandboxes still running from my previous coding session?

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

Start here

Connect E2B once, then ask.

Just link E2B to your preferred MCP-compatible client. Your credentials stay encrypted, and you can start managing sandboxes immediately.

Connect E2B to your AI

FAQ

How the E2B management works

  • 01

    Can the AI delete my local files?

    No. The AI only has control over the microVM sandboxes provided by E2B, not your local machine.

  • 02

    Will the AI kill a sandbox while I am still using it?

    The AI only kills sandboxes when you instruct it to do so or when it identifies them as idle based on your instructions.

  • 03

    How does the AI know which sandbox to kill?

    The AI uses the sandbox ID retrieved from the list of active environments to target a specific instance.

  • 04

    Can the AI create new sandboxes?

    No. This specific task focuses on monitoring and cleaning up existing sandboxes using the available tools.

  • 05

    Does the AI automatically clean up every time a task ends?

    The AI can do this, but it depends on how you prompt it to manage its resources.

  • More questions about E2B? See everything the E2B Connector can do

Connect E2B to Claude, Cursor, ChatGPT & more