Files
e2b-dev--e2b/packages/python-sdk
Jonas Scholz 1a51777cc0 Fix mcp gateway race condition (#971)
Previously the gateway was just fire and forget which lead to a race
condition when you immediately tried to access the mcp server, changed
the template to launch a daemon with healthcheck.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Start MCP gateway synchronously with error checks and bump default MCP
template to `mcp-gateway-v0-2` across JS and Python SDKs.
> 
> - **MCP Gateway startup**:
> - JS (`packages/js-sdk/src/sandbox/index.ts`): Start `mcp-gateway`
without background mode; validate exit code and throw on failure.
> - Python Async (`packages/python-sdk/e2b/sandbox_async/main.py`):
Await `mcp-gateway` start, remove background/timeout flags; raise on
non-zero exit.
> - Python Sync (`packages/python-sdk/e2b/sandbox_sync/main.py`): Run
`mcp-gateway` synchronously; check exit code and raise on failure.
> - **Defaults**:
> - Update `default_mcp_template` from `mcp-gateway-v0-1` to
`mcp-gateway-v0-2` in JS and Python SDKs.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
79e431c78bf384c970a5b1fede55071116a089c5. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-17 16:21:32 -07:00
..
2025-10-17 16:21:32 -07:00
2025-10-17 12:31:32 -07:00
2025-08-21 08:45:25 -07:00
2025-06-05 07:10:07 -07:00
2025-10-16 23:25:59 +00:00
2025-10-17 12:31:32 -07:00
2025-10-16 23:25:59 +00:00

e2b logo

Last 1 month downloads for the Python SDK

What is E2B?

E2B is an open-source infrastructure that allows you to run AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our JavaScript SDK or Python SDK.

Run your first Sandbox

1. Install SDK

pip install e2b-code-interpreter

2. Get your E2B API key

  1. Sign up to E2B here.
  2. Get your API key here.
  3. Set environment variable with your API key
E2B_API_KEY=e2b_***

3. Execute code with code interpreter inside Sandbox

from e2b_code_interpreter import Sandbox

with Sandbox.create() as sandbox:
    sandbox.run_code("x = 1")
    execution = sandbox.run_code("x+=1; x")
    print(execution.text)  # outputs 2

4. Check docs

Visit E2B documentation.

5. E2B cookbook

Visit our Cookbook to get inspired by examples with different LLMs and AI frameworks.