Mcp E2b

managed-by-terraformtutorials03-mcpmcp-e2bgroq-api-cookbook

Groq + E2B MCP Gateway: Multiple MCP Servers in One Sandbox

This notebook demonstrates how to use E2B's MCP Gateway to run multiple Model Context Protocol servers together with Groq's ultra-fast inference.

What is E2B MCP Gateway?

E2B's MCP Gateway provides a unified interface to multiple MCP servers running inside an isolated sandbox. Instead of connecting to each MCP server separately, you get:

  • One endpoint for all your MCP tools (Exa, Browserbase, Notion, etc.)
  • Isolated environment where MCPs run securely
  • Seamless integration with Groq's Responses API
  • 200+ tools from the Docker MCP Catalog

What We'll Build

We'll create an AI research agent that:

  1. Searches for AI companies using Exa MCP's web search
  2. Visits their websites using Browserbase MCP's browser automation
  3. Extracts pricing and contact information
  4. Returns structured results—all through one E2B gateway

This showcases how E2B makes it trivial to combine multiple MCP capabilities in a single workflow.

Getting Started

You'll need API keys from four services:

  1. E2B (e2b.dev) - Provides the unified MCP gateway and sandbox
  2. Browserbase (browserbase.com) - Browser automation MCP
    • You'll need both an API key AND a Project ID
  3. Exa (dashboard.exa.ai) - Web search MCP
  4. Groq (console.groq.com) - Ultra-fast LLM inference

Set Environment Variables

After obtaining your API keys, set them as environment variables:

macOS/Linux:

export E2B_API_KEY='your_e2b_key'
export BROWSERBASE_API_KEY='your_browserbase_key'
export BROWSERBASE_PROJECT_ID='your_project_id'
export EXA_API_KEY='your_exa_key'
export GROQ_API_KEY='your_groq_key'

Windows (PowerShell):

$Env:E2B_API_KEY='your_e2b_key'
$Env:BROWSERBASE_API_KEY='your_browserbase_key'
$Env:BROWSERBASE_PROJECT_ID='your_project_id'
$Env:EXA_API_KEY='your_exa_key'
$Env:GROQ_API_KEY='your_groq_key'

Installation

Install the required packages:

[ ]

Setup: Import Libraries and Configure API Keys

[ ]

Step 1: Create E2B Sandbox with MCP Gateway

Here's where the magic happens. We create a single E2B sandbox that hosts both Exa and Browserbase MCP servers:

[ ]

Step 2: Setup Groq Client

Initialize the Groq client using OpenAI's SDK (Groq is OpenAI-compatible):

[ ]

Step 3: Configure MCP Tools for Groq

Tell Groq about the E2B MCP gateway. Notice we only need ONE tool configuration—E2B routes to all MCPs internally:

[ ]

Core Function: Research with Multiple MCPs

This function demonstrates the power of E2B's unified gateway:

[ ]

Demo 1: Research AI Inference Companies

Let's research AI companies that provide inference APIs and extract their pricing information.

Watch how the agent:

  1. Uses Exa to search for AI inference companies
  2. Uses Browserbase to visit their websites
  3. Extracts pricing and contact details

All of this happens through the single E2B gateway we configured:

[ ]

Display the response in markdown format:

[ ]

Demo 2: Custom Research Task

Now it's your turn! Replace the query below with your own research task.

Ideas to try:

  • "Find popular AI image generation tools and check their pricing"
  • "Research vector database companies and extract their key features"
  • "Find AI agent frameworks and get their documentation links"
  • "Research LLM observability tools and compare their features"
[ ]

Next Steps

Now that you've seen E2B's MCP gateway in action, here are some ideas to explore:

Add More MCP Servers

E2B supports 200+ MCP servers from the Docker MCP Catalog. Try adding:

  • Notion - Store research findings in a database
  • Airtable - Organize data in spreadsheets
  • GitHub - Search code repositories
  • Slack - Send notifications
  • Firecrawl - Advanced web scraping

Just add them to the mcp configuration:

sandbox = Sandbox.create(
    mcp={
        'browserbase': {...},
        'exa': {...},
        'notion': {
            'internalIntegrationToken': NOTION_API_KEY,
        },
        # Add more...
    }
)

Build Production Workflows

  • Create scheduled research jobs that run daily
  • Build a research API endpoint
  • Set up monitoring and alerting
  • Store results in a database

Scale with Multiple Sandboxes

  • Run parallel research tasks in separate sandboxes
  • Implement rate limiting and queuing
  • Add retry logic and error handling

Experiment with Different Models

Try different Groq models for different tasks:

  • llama-3.3-70b-versatile - Great for general tasks
  • qwen/qwen3-32b - Fast and efficient
  • openai/gpt-oss-120b - Powerful reasoning

Optimize for Speed

  • Use streaming responses for real-time updates
  • Batch similar requests together
  • Cache frequently accessed data

Resources

E2B MCP Gateway

MCP Servers Used

Groq

Model Context Protocol


Happy researching with E2B + Groq! 🚀