Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.brightdata.com/llms.txt

Use this file to discover all available pages before exploring further.

Building an AI startup?

You might be eligible for our Startup Program. Get fully funded access to the infrastructure you’re reading about right now (up to $20K value).

Hosted MCP

1

Get your API token

  1. Go to Bright Data user settings
  2. Copy your API token (it looks like: 2dceb1aa0***************************)
2

Set up your Cloudflare environment

Make sure you have Node.js 20+ installed, then log in to Cloudflare:
npx wrangler login
3

Install the Agents Starter template

npx create-cloudflare@latest mcp-demo --template cloudflare/agents-starter
cd mcp-example
npm install
4

Configure environment variables

Copy the example env file and add your OpenAI API key:
cp .dev.vars.example .dev.vars
Edit .dev.vars:
OPENAI_API_KEY=sk-...
5

Connect Bright Data MCP in your agent

In src/server.ts, find the default commented-out MCP connection inside onChatMessage:
// const mcpConnection = await this.mcp.connect(
//   "https://path-to-mcp-server/sse"
// );
Replace it with the Bright Data MCP connection:
// Connect to Bright Data MCP server
const mcpConnection = await this.mcp.connect(
  "https://mcp.brightdata.com/mcp?token=<API_TOKEN>"
);

// Merge MCP tools with local tools
const allTools = {
  ...tools,
  ...this.mcp.getAITools()
};
Make sure mcp.connect() is called before this.mcp.getAITools() to avoid jsonSchema not initialized errors.
6

Test it works

  1. Replace <API_TOKEN> with your actual Bright Data API token
  2. Start the development server:
npm start
  1. Open the app in your browser and ask the agent a question, for example:
Find the latest 3 news items about Cloudflare Agents and summarize them in bullets with links.
You should see the agent use Bright Data’s web scraping tools to fetch and summarize live results:Hosted MCP
7

Monitor usage

  1. View your API usage at My Zones in your Bright Data dashboard
  2. Your free tier includes 5,000 requests per month