{"type":"mcp_client","name":"code-interpreter","description":"AI Code Execution SDK: Python & JS/TS libraries for integrating AI-generated code interpretation into applications.","category":"AI","language":"MDX","stars":2351,"forks":159,"owner":"e2b-dev","github_url":"https://github.com/e2b-dev/code-interpreter","homepage":"https://e2b.dev","setup":"## Setup\n\nTo start using E2B, follow these steps:\n\n### Prerequisites\n\n*   **JavaScript/TypeScript:** Node.js and npm (Node Package Manager) or yarn.\n*   **Python:** Python 3.7 or higher and pip (Python Package Installer).\n\n### 1. Install the E2B SDK\n\nChoose the SDK based on your preferred language:\n\n**JavaScript / TypeScript:**\n\n```bash\nnpm install @e2b/code-interpreter\n```\n\nor, if you prefer yarn:\n\n```bash\nyarn add @e2b/code-interpreter\n```\n\n**Python:**\n\n```bash\npip install e2b-code-interpreter\n```\n\n### 2. Obtain and Configure your E2B API Key\n\n1.  **Sign up:** Create an E2B account at [https://e2b.dev](https://e2b.dev).\n2.  **Get your API Key:**  Find your API key in the E2B dashboard under the \"Keys\" tab: [https://e2b.dev/dashboard?tab=keys](https://e2b.dev/dashboard?tab=keys).\n3.  **Set the Environment Variable:**  Set the `E2B_API_KEY` environment variable with your API key. This allows the SDK to authenticate with the E2B service.\n\n    **Example (Linux/macOS):**\n\n    ```bash\n    export E2B_API_KEY=\"e2b_YOUR_API_KEY\"\n    ```\n\n    **Example (Windows):**\n\n    ```bash\n    set E2B_API_KEY=e2b_YOUR_API_KEY\n    ```\n\n    Replace `e2b_YOUR_API_KEY` with your actual API key.  Make sure to set this environment variable before running your code.  Consider adding this to your shell's configuration file (e.g., `.bashrc`, `.zshrc`, `.bash_profile`) for persistence.","tools":"## Available Tools\n\nE2B provides the following tools and features for running AI-generated code in secure, isolated cloud sandboxes:\n\n*   **JavaScript/TypeScript SDK:** Allows you to start and control sandboxes from JavaScript or TypeScript environments.\n    *   Installation: `npm i @e2b/code-interpreter`\n    *   Usage Example:\n        ```ts\n        import { Sandbox } from '@e2b/code-interpreter'\n\n        const sbx = await Sandbox.create()\n        await sbx.runCode('x = 1')\n\n        const execution = await sbx.runCode('x+=1; x')\n        console.log(execution.text)\n        ```\n\n*   **Python SDK:** Enables starting and controlling sandboxes from Python environments.\n    *   Installation: `pip install e2b-code-interpreter`\n    *   Usage Example:\n        ```py\n        from e2b_code_interpreter import Sandbox\n\n        with Sandbox() as sandbox:\n            sandbox.run_code(\"x = 1\")\n            execution = sandbox.run_code(\"x+=1; x\")\n            print(execution.text)\n        ```\n\n*   **Secure Isolated Sandboxes:** Provides a secure environment for executing AI-generated code, preventing potential security risks.\n\n*   **Code Execution:** Allows you to execute arbitrary code within the sandbox environment.\n    *   Usage: The `runCode` function in both SDKs executes code within the sandbox.\n\n*   **API Key Authentication:** Secures access to E2B services using API keys.  You can obtain an API key after signing up on the E2B platform.\n\n*   **E2B Cookbook:** Offers a collection of examples and use cases demonstrating how to use E2B with various LLMs and AI frameworks.","faq":null,"created_at":"2024-03-11T22:08:25+00:00","updated_at":"2025-07-07T14:58:37+00:00","source_url":"https://model-context-protocol.com/clients/code-interpreter","related_articles":[]}