Back to blog
·7 min read·by Panikkos Panayiotou

Build a web-native AI agent with the MCP Browser Server

Give Claude, GPT, or any MCP-compatible LLM a real Chrome it can drive. Step-by-step setup with code samples.

ai-agentsmcpclaude

What MCP gives you

The Model Context Protocol is Anthropic's open standard for letting an LLM call tools. Once an LLM can call MCP tools, *anything* you wrap as a tool becomes part of the model's "abilities".

A browser is the most powerful single tool you can give an LLM, because the web is the largest software interface ever built.

The setup

Install the MCP browser server:

bash
npm install -g @browserforhire/mcp

Add it to your Claude Desktop config:

json
{
  "mcpServers": {
    "browserforhire": {
      "command": "npx",
      "args": ["-y", "@browserforhire/mcp"],
      "env": { "BFH_API_KEY": "bf_live_..." }
    }
  }
}

Restart Claude Desktop. You now have these tools available:

  • browser.goto({ url })
  • browser.click({ selector })
  • browser.fill({ selector, value })
  • browser.screenshot({ fullPage })
  • browser.scrape({ selector, attribute })
  • browser.run_js({ code })

A first agent

Ask Claude:

> *Go to https://news.ycombinator.com, get the top 5 stories with their points, and screenshot the page.*

Claude will:

  1. Call browser.goto({ url: 'https://news.ycombinator.com' }).
  2. Call browser.scrape({ selector: '.athing', limit: 5 }).
  3. Call browser.screenshot({ fullPage: false }).
  4. Render the result back to you.

Behind the scenes, the MCP server opens a session against wss://cloud.browserforhire.com, runs the commands on a real headless Chrome, captures the result, and streams it back. The browser is ephemeral — it dies when the session closes.

Long-running agents

For multi-step agents that need persistent state (cookies, logged-in sessions), pass session to every tool call:

json
{ "session": "agent-42" }

The gateway will reuse the same browser context across calls within the session window.

Stagehand compatibility

If you already use Browserbase's Stagehand SDK, our gateway accepts the same connect URL shape. Drop in:

js
import { Stagehand } from '@browserbase/stagehand'
const sh = new Stagehand({ env: 'CUSTOM', browserWSEndpoint: 'wss://cloud.browserforhire.com?token=' + BFH })

What this unlocks

  • AI sales prospecting agents that browse LinkedIn, Crunchbase, news sites.
  • QA agents that drive your staging environment, take screenshots, file bugs.
  • Customer support agents that pull order history off a vendor portal.
  • Research agents that read papers, fetch supplementary data, write summaries.

The interesting work is no longer building the browser plumbing — it's writing the prompts.

Ship Chrome to production today.

Free 1,000 credits, no credit card. Drop-in replacement for Browserless.