How to integrate Brightdata MCP with CrewAI

Connect CrewAI to Brightdata MCP. Download all product listings from this ecommerce site, check crawl status for your recent job, and more using natural language, with authentication handled for you.

Brightdata logoBrightdata
Api Key

Brightdata is a leading web data platform offering advanced scraping, SERP APIs, and anti-bot tools. It lets you collect public web data at scale, bypassing blocks and friction.

167 Tools

Introduction

This guide walks you through connecting Brightdata to CrewAI using the Composio tool router. By the end, you'll have a working Brightdata agent that can scrape e-commerce and social media sites, run SERP searches, crawl websites, unlock protected pages, and filter ready-made datasets through natural language commands.

This guide will help you understand how to give your CrewAI agent real control over a Brightdata account through Composio's Brightdata MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Brightdata with

TL;DR

Here's what you'll learn:
  • Get a Composio API key and configure your Brightdata connection
  • Set up CrewAI with an MCP enabled agent
  • Create a Tool Router session or standalone MCP server for Brightdata
  • Build a conversational loop where your agent can execute Brightdata operations

What is CrewAI?

CrewAI is a powerful framework for building multi-agent AI systems. It provides primitives for defining agents with specific roles, creating tasks, and orchestrating workflows through crews.

Key features include:

  • Agent Roles: Define specialized agents with specific goals and backstories
  • Task Management: Create tasks with clear descriptions and expected outputs
  • Crew Orchestration: Combine agents and tasks into collaborative workflows
  • MCP Integration: Connect to external tools through Model Context Protocol

What is the Brightdata MCP server, and what's possible with it?

The Brightdata MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Brightdata account. It provides structured and secure access to Brightdata’s web data platform, so your agent can trigger site crawls, run SERP searches, filter and download datasets, and manage proxy endpoints on your behalf.

  • Automated site crawling and extraction: Start large-scale crawl jobs across multiple web pages or entire domains, letting your agent collect structured data from the internet with just a prompt.
  • Access to pre-made marketplace scrapers: Browse and select from Brightdata’s collection of pre-built scrapers for popular websites, making it easy to gather structured data without building your own scrapers from scratch.
  • Filtered dataset generation and download: Apply custom filters to datasets, check crawl job status, and retrieve the exact data you need by downloading processed results once ready.
  • Powerful SERP and web unlocker tools: Perform real-time SERP searches across various engines and leverage web unlocker zones to bypass anti-bot protections and scrape challenging websites.
  • Proxy zone and location management: List available proxy zones, cities, and countries to configure how and where your data collection jobs run, optimizing for speed and success.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Step by step08 STEPS
1

Prerequisites

Before starting, make sure you have:
  • Python 3.9 or higher
  • A Composio account and API key
  • A Brightdata connection authorized in Composio
  • An OpenAI API key for the CrewAI LLM
  • Basic familiarity with Python
2

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.
3

Install dependencies

bash
pip install composio crewai crewai-tools[mcp] python-dotenv
What's happening:
  • composio connects your agent to Brightdata via MCP
  • crewai provides Agent, Task, Crew, and LLM primitives
  • crewai-tools[mcp] includes MCP helpers
  • python-dotenv loads environment variables from .env
4

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates with Composio
  • USER_ID scopes the session to your account
  • OPENAI_API_KEY lets CrewAI use your chosen OpenAI model
5

Import dependencies

python
import os
from composio import Composio
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
import dotenv

dotenv.load_dotenv()

COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set")
What's happening:
  • CrewAI classes define agents and tasks, and run the workflow
  • MCPServerHTTP connects the agent to an MCP endpoint
  • Composio will give you a short lived Brightdata MCP URL
6

Create a Composio Tool Router session for Brightdata

python
composio_client = Composio(api_key=COMPOSIO_API_KEY)
session = composio_client.create(user_id=COMPOSIO_USER_ID, toolkits=["brightdata"])

url = session.mcp.url
What's happening:
  • You create a Brightdata only session through Composio
  • Composio returns an MCP HTTP URL that exposes Brightdata tools
7

Initialize the MCP Server

python
server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users search the internet effectively",
        backstory="You are a helpful assistant with access to search tools.",
        tools=tools,
        verbose=False,
        max_iter=10,
    )
What's Happening:
  • Server Configuration: The code sets up connection parameters including the MCP server URL, streamable HTTP transport, and Composio API key authentication.
  • MCP Adapter Bridge: MCPServerAdapter acts as a context manager that converts Composio MCP tools into a CrewAI-compatible format.
  • Agent Setup: Creates a CrewAI Agent with a defined role (Search Assistant), goal (help with internet searches), and access to the MCP tools.
  • Configuration Options: The agent includes settings like verbose=False for clean output and max_iter=10 to prevent infinite loops.
  • Dynamic Tool Usage: Once created, the agent automatically accesses all Composio Search tools and decides when to use them based on user queries.
8

Create a CLI Chatloop and define the Crew

python
print("Chat started! Type 'exit' or 'quit' to end.\n")

conversation_context = ""

while True:
    user_input = input("You: ").strip()

    if user_input.lower() in ["exit", "quit", "bye"]:
        print("\nGoodbye!")
        break

    if not user_input:
        continue

    conversation_context += f"\nUser: {user_input}\n"
    print("\nAgent is thinking...\n")

    task = Task(
        description=(
            f"Conversation history:\n{conversation_context}\n\n"
            f"Current request: {user_input}"
        ),
        expected_output="A helpful response addressing the user's request",
        agent=agent,
    )

    crew = Crew(agents=[agent], tasks=[task], verbose=False)
    result = crew.kickoff()
    response = str(result)

    conversation_context += f"Agent: {response}\n"
    print(f"Agent: {response}\n")
What's Happening:
  • Interactive CLI Setup: The code creates an infinite loop that continuously prompts for user input and maintains the entire conversation history in a string variable.
  • Input Validation: Empty inputs are ignored to prevent processing blank messages and keep the conversation clean.
  • Context Building: Each user message is appended to the conversation context, which preserves the full dialogue history for better agent responses.
  • Dynamic Task Creation: For every user input, a new Task is created that includes both the full conversation history and the current request as context.
  • Crew Execution: A Crew is instantiated with the agent and task, then kicked off to process the request and generate a response.
  • Response Management: The agent's response is converted to a string, added to the conversation context, and displayed to the user, maintaining conversational continuity.

Complete Code

Here's the complete code to get you started with Brightdata and CrewAI:

python
from crewai import Agent, Task, Crew, LLM
from crewai_tools import MCPServerAdapter
from composio import Composio
from dotenv import load_dotenv
import os

load_dotenv()

GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not GOOGLE_API_KEY:
    raise ValueError("GOOGLE_API_KEY is not set in the environment.")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment.")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment.")

# Initialize Composio and create a session
composio = Composio(api_key=COMPOSIO_API_KEY)
session = composio.create(
    user_id=COMPOSIO_USER_ID,
    toolkits=["brightdata"],
)
url = session.mcp.url

# Configure LLM
llm = LLM(
    model="gpt-5",
    api_key=os.getenv("OPENAI_API_KEY"),
)

server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users with internet searches",
        backstory="You are an expert assistant with access to Composio Search tools.",
        tools=tools,
        llm=llm,
        verbose=False,
        max_iter=10,
    )

    print("Chat started! Type 'exit' or 'quit' to end.\n")

    conversation_context = ""

    while True:
        user_input = input("You: ").strip()

        if user_input.lower() in ["exit", "quit", "bye"]:
            print("\nGoodbye!")
            break

        if not user_input:
            continue

        conversation_context += f"\nUser: {user_input}\n"
        print("\nAgent is thinking...\n")

        task = Task(
            description=(
                f"Conversation history:\n{conversation_context}\n\n"
                f"Current request: {user_input}"
            ),
            expected_output="A helpful response addressing the user's request",
            agent=agent,
        )

        crew = Crew(agents=[agent], tasks=[task], verbose=False)
        result = crew.kickoff()
        response = str(result)

        conversation_context += f"Agent: {response}\n"
        print(f"Agent: {response}\n")

Conclusion

You now have a CrewAI agent connected to Brightdata through Composio's Tool Router. The agent can perform Brightdata operations through natural language commands.

Next steps:

  • Add role-specific instructions to customize agent behavior
  • Plug in more toolkits for multi-app workflows
  • Chain tasks for complex multi-step operations
TOOLS

Supported Tools

Every Brightdata action and event your agent gets out of the box.

Start Site Crawl

Start an asynchronous dataset or site crawl.

Create Safe Zone

Create a durable SERP API or Scraping Browser zone using a fixed safe plan.

List Marketplace Datasets

List pre-built datasets in Bright Data's marketplace for structured scraping.

Filter Dataset

Create a billable filtered marketplace-dataset snapshot.

Get Customer Balance

Get current and pending Bright Data account balances.

Get Dataset Metadata

Retrieve field definitions for a Bright Data marketplace dataset.

Get Deep Lookup Results

Retrieve enriched records plus available progress, cost, and provider metadata for a completed Deep Lookup request.

Get Deep Lookup Status

Check a Deep Lookup request's status, progress, cost, and provider metadata.

Get Destination Type Schema

Retrieve the fields required to configure a Bright Data delivery destination.

List Available Cities

List static-network cities available for a country and proxy pool type.

List Available Countries

List country codes available for each static proxy zone type.

Get SERP Results

Retrieve JSON or raw results for an asynchronous BRIGHTDATA_SERP_SEARCH request.

Download Snapshot Results

Download a completed dataset snapshot.

Check Snapshot Status

Check whether a dataset snapshot is running, ready, or failed before downloading it.

Get Web Archive Search

Get a Web Archive search's status and its matching-file, dump-size-in-bytes, and dump-cost-in-USD estimates.

Get Zone Bandwidth

Get uploaded, downloaded, and total byte usage for one zone and date range.

Get Zone Cost

Get invoice-aligned billed cost and bandwidth for one zone and date range.

Get Country Cities

List cities in a country for account-level geographic selection.

Get Dataset Delivery Options

List settings supported when configuring Bright Data dataset delivery.

List Scraper Studio Scrapers

List account-owned Scraper Studio scrapers and discover collector IDs.

List Unlocker Zones

List configured Web Unlocker zones and their types for protected-URL scraping.

Scrape AE.com - Complete Products

Collect AE.

Scrape Agoda Listings Search

Collect Agoda Listings Search.

Scrape Agoda Properties Listings

Collect Agoda Properties Listings.

Scrape Agoda Properties Listings with Pricing

Collect Agoda Properties Listings with Pricing.

Scrape Agoda Reviews

Collect Agoda Reviews.

Amazon products

Collect Amazon products by URL with optional ASIN metadata, or discover them by best-seller/category URL, keyword, or UPC, returning product and price data.

Amazon products search

Collect structured Amazon products search data from amazon.

Amazon products global dataset

Collect global Amazon products by URL or discover them by best-seller, brand, category, keyword/domain, or seller, returning product and price data.

Amazon Reviews

Collect structured Amazon Reviews data from amazon.

Amazon sellers info

Collect structured Amazon sellers info data from amazon.

American Eagle Products - Unified Schema

Collect American Eagle.

Scrape Apple App Store

Collect Apple App Store.

Scrape Apple App Store reviews

Collect Apple App Store reviews .

Ashley Furniture Products

Collect Ashleyfurniture - Products.

Ashley Furniture Products - Unified Schema

Collect Ashley Furniture.

Scrape Best Buy products

Collect Best Buy products.

Scrape Best Buy Reviews

Collect Best Buy Reviews.

Scrape Booking Hotel Listings

Collect Booking Hotel Listings .

Scrape Booking Hotel Listings with Pricing

Collect Booking Hotel Listings with Pricing.

Scrape Booking Listings Search

Collect Booking Listings Search.

Scrape Booking Reviews

Collect Booking Reviews.

Scrape ChatGPT Search

Collect ChatGPT Search.

Scrape Costco products

Collect Costco products.

Scrape Costco Reviews

Collect Costco Reviews.

Crate & Barrel Products

Collect Crateandbarrel - Products.

Crate & Barrel Products - Unified Schema

Collect Crateandbarrel - Products.

Creative Commons 3D Models

Collect Creative Commons 3D Models.

Scrape Creative Commons Images

Collect Creative Commons Images.

Scrape Data Synchronously

Scrape up to 20 input objects synchronously.

Scrape Dior - Products

Collect Dior - Products.

Scrape Dior Products Unified Schema

Collect Dior Products Unified Schema.

Facebook - Comments

Collect structured Facebook - Comments data from facebook.

Scrape Facebook Company Reviews

Collect Facebook Company Reviews.

Scrape Facebook Events

Collect Facebook Events.

Facebook - Posts by group URL

Collect structured Facebook - Posts by group URL data from facebook.

Scrape Facebook Marketplace

Collect Facebook Marketplace.

Facebook - Pages Posts by Profile URL

Collect structured Facebook - Pages Posts by Profile URL data from facebook.

Facebook - Pages and Profiles

Collect Facebook pages and public profiles with the combined page/profile dataset, including entity type and page-oriented fields.

Scrape Facebook - Posts by post URL

Collect Facebook - Posts by post URL.

Scrape Facebook - Profiles

Collect Facebook profile URLs with the profile-only dataset.

Scrape Facebook - Reels by profile URL

Collect Facebook - Reels by profile URL.

Scrape Falabella.com - Reviews

Collect Falabella.

Scrape Falabella.com - Search

Collect Falabella.

Falabella Products

Collect Falabella.

Scrape Flipkart.com - Search

Collect Flipkart.

Flipkart Products

Collect Flipkart.

Scrape Flipkart Products unified schema

Collect Flipkart Products unified schema.

Scrape Flipkart - Reviews

Collect Flipkart - Reviews.

Scrape Glassdoor companies overview information

Collect Glassdoor companies overview information.

Scrape Glassdoor companies reviews

Collect Glassdoor companies reviews.

Glassdoor Jobs

Collect Glassdoor job listings information.

Scrape Google AI Mode Search

Collect Google AI Mode Search.

Scrape Google Flights

Collect Google Flights.

Scrape Google Hotels

Collect Google Hotels.

Scrape Google Images

Collect Google Images.

Scrape Google Maps Images

Collect Google Maps place images.

Google Maps Places

Collect Google Maps place URLs or discover places by keyword and location.

Scrape Google maps reviews

Collect Google Maps place reviews or discover reviews from place URLs.

Scrape Google Play Store

Collect Google Play Store.

Scrape Google Play Store reviews

Collect Google Play Store reviews.

Google SERP 100 Results

Collect Google SERP - 100 Results.

Scrape Google Shopping

Collect Google Shopping product pages or discover products by keyword with the general Google Shopping dataset.

Scrape Google Shopping products search US

Collect US Google Shopping search-result URLs with the US search schema.

H&M Products

Collect H&M - Products.

H&M Products - Unified Schema

Collect H&M products.

Scrape Ikea - Products

Collect Ikea - Products.

Scrape Ikea products unified schema

Collect Ikea products unified schema.

Scrape Indeed companies info

Collect Indeed companies info.

Indeed Jobs

Collect Indeed job listings information.

Scrape Instacart products

Collect Instacart products.

Scrape Instacart Products unified schema

Collect Instacart Products unified schema.

Scrape Instagram Comments

Collect Instagram comments with commenter, text, date, likes, replies, hashtags, tagged users, and source-post details.

Scrape Instagram Posts

Collect Instagram posts or discover posts from a profile, returning captions, hashtags, media, engagement, dates, location, and comments.

Scrape Instagram Profiles

Collect Instagram profiles by URL or discover them by username, returning biography, audience, verification, links, posts, and profile image.

Scrape Instagram Reels

Collect Instagram reels or discover reels from profiles, returning captions, hashtags, media, dates, engagement, play counts, and comments.

Scrape Kohls.com - Reviews

Collect Kohls.

Kohl's Products

Collect Kohls.

Scrape Kohl's Products unified schema

Collect Kohl's Products unified schema.

Scrape Kroger.com - Search

Collect Kroger.

Kroger Products

Collect Kroger.

Scrape LinkedIn Companies

Collect structured LinkedIn company details, including size, industry, locations, followers, specialties, and website.

Scrape LinkedIn Jobs

Collect LinkedIn job listings or discover jobs by keyword, location, and search URL, returning role, employer, location, summary, and pay data.

Scrape LinkedIn People Search

Search LinkedIn people and return matching profile URLs, names, subtitles, locations, experience, education, and avatars.

Scrape LinkedIn Posts

Collect LinkedIn posts directly or discover posts from company, profile, and article-feed URLs, returning text, media, dates, and engagement.

Scrape LinkedIn Profiles

Collect structured LinkedIn person profiles, including identity, location, company, follower, education, and public career data.

L.L.Bean Products

Collect llbean.

L.L.Bean Products - Unified Schema

Collect LLBean.

Scrape Macys.com - Reviews

Collect Macys.

Macy's Products

Collect Macys.

Scrape Macys Products unified schema

Collect Macys Products unified schema.

Scrape Massimo Dutti - Products

Collect Massimo Dutti - Products .

Massimo Dutti Products - Unified Schema

Collect Massimodutti.

Scrape Meta - Ad Library

Collect Meta - Ad Library .

Scrape Overstock.com - Reviews

Collect Overstock.

Overstock Products

Collect Overstock.

Scrape Overstock Products unified schema

Collect Overstock Products unified schema.

Scrape Pinterest - Posts

Collect Pinterest - Posts .

Scrape Pinterest - Profiles

Collect Pinterest - Profiles.

Poshmark Products

Collect Poshmark.

Scrape Poshmark Products unified schema

Collect Poshmark Products unified schema.

Scrape Reddit - Comments

Collect Reddit - Comments.

Scrape Reddit- Posts

Collect Reddit- Posts.

Scrape Reddit - Profiles

Collect Reddit - Profiles.

Scrape Snapchat posts

Collect Snapchat posts.

Scrape Snapchat profile

Collect Snapchat profile.

Scrape Threads - Posts

Collect Threads - Posts.

Scrape Threads - Profiles

Collect Threads - Profiles.

Scrape TikTok Comments

Collect TikTok comments with text, dates, likes, replies, commenter identity, and source-post details.

Scrape TikTok Posts

Collect TikTok posts with the full post dataset.

TikTok - Posts by URL Fast API

Collect individual TikTok post URLs with the fast dataset.

Scrape TikTok Profile Posts Fast

Discover TikTok posts from profile URLs with the fast profile-post dataset.

TikTok - Profiles

Collect structured TikTok - Profiles data from tiktok.

Scrape TikTok Search Posts Fast

Discover TikTok posts from search or discovery URLs with the fast search-post dataset.

TikTok Shop

Collect structured TikTok Shop data from tiktok.

TikTok Shop Category Products

Collect structured TikTok Shop Category Products data from tiktok.

Scrape Trip.com - Flights (mobile-app)

Collect Trip.

Trip.com Hotel Listings

Collect Trip Hotel Listings.

Scrape Trip.com - Hotels (mobile-app)

Collect Trip.

Trip.com Listings Search

Collect Trip Listings Search.

Scrape Walmart - products

Collect Walmart - products .

Scrape Walmart products search

Collect Walmart products search.

Scrape Walmart - products zipcodes

Collect Walmart product URLs with zipcode-specific availability and pricing.

Scrape Walmart Reviews

Collect Walmart Reviews.

Scrape Walmart sellers info

Collect Walmart sellers info.

X Posts

Collect X (formerly Twitter) - Posts.

X Profiles

Collect X (formerly Twitter) - Profiles.

Scrape Yelp businesses overview

Collect Yelp businesses overview.

Scrape Yelp businesses reviews

Collect Yelp businesses reviews.

Scrape YouTube - Channels

Collect YouTube - Channels.

Scrape Youtube - Comments

Collect Youtube - Comments.

YouTube Videos

Collect Youtube - Videos posts.

Scrape Zara Home Products

Collect Zara Home Products.

Scrape Zara Home products

Collect Zara Home products.

Scrape Zara - Products

Collect Zara - Products .

Zara Products - Unified Schema

Collect Zara.

Zillow Properties

Collect full property details for Zillow property URLs.

Zillow Property Listings

Collect Zillow listing URLs or discover property listings from filters or search URLs.

Zillow Property Price History

Collect the price-history timeline for Zillow property URLs.

Zillow Property Search Results

Collect Zillow search-page URLs into search-result property records.

Search Business Records

Search public company or professional-profile records synchronously using structured queries in Ludicrous mode or natural language in Instant/Smart mode.

Search Dataset Synchronously

Search a supported LinkedIn profiles, contact-enriched profiles, or companies Marketplace dataset and return matching records synchronously.

Search SERP Synchronously

Search Google, Bing, DuckDuckGo or Yandex synchronously for standard text results.

Search Web Archive

Search Bright Data's Web Archive and estimate matching files, dump size in bytes, and dump cost in USD.

Search SERP

Submit an asynchronous SERP search and return its response_id.

Start Deep Lookup

Start an asynchronous Deep Lookup research request and return its request_id.

Scrape Protected URL

Scrape a public URL through Web Unlocker when ordinary requests are blocked or require JavaScript rendering.

FAQ

Frequently asked questions

Start with Brightdata.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Brightdata tool your agent needs.Free to start.

Start building