Skip to main content
Glama

Browser-Based Multi-Provider MCP Server

A production-grade, local Model Context Protocol (MCP) server that connects AI clients (Claude Desktop, Cursor, Antigravity IDE, etc.) directly to live web instances of Google Search, Google Gemini, ChatGPT, Claude, and DeepSeek via an automated Chrome instance. No paid API keys required.


๐Ÿ“‘ Table of Contents

  1. Project Overview

  2. High-Level Architecture

  3. End-to-End Execution Flow

  4. Autonomous Vision CAPTCHA Solver

  5. Provider Implementation Matrix

  6. First-Time Setup Guide

  7. Running the MCP Server

  8. MCP Client Configuration

  9. Available MCP Tools Reference

  10. CLI Testing Suite

  11. Project Directory Structure

  12. Troubleshooting & FAQ


Related MCP server: browser-relay

๐ŸŒŸ Project Overview

API subscriptions for multiple AI providers (OpenAI, Anthropic, Google Cloud, DeepSeek) are expensive and carry strict rate limits. Meanwhile, individual users typically already have web subscriptions (or free accounts) on these platforms.

This project bridges that gap by running a FastMCP server that drives an authenticated Google Chrome browser over the Chrome DevTools Protocol (CDP) and Selenium WebDriver:

  • Zero API Costs: Uses your existing browser sessions and cookies stored in a persistent profile.

  • Unified Interface: Exposes 11 standard MCP tools covering conversational chat, real-time web search (with AI overviews and citations), and live image generation.

  • Autonomous CAPTCHA Bypassing: Integrates a two-tier challenge solver powered by browser-use and local/cloud Ollama Vision (gemma4:31b-cloud) to solve Cloudflare Turnstile verification challenges automatically without paid third-party solver extensions.

  • Strict Tab & Session Isolation: Emulates fresh chats on every query, preventing context contamination and history pollution.


๐Ÿ—๏ธ High-Level Architecture

 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚                       AI Clients & MCP Consumers                            โ”‚
 โ”‚          (Claude Desktop, Cursor, Antigravity IDE, CLI / test.py)           โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ”‚ (SSE on :8000 or stdio)
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚                      FastMCP Server (server.py)                             โ”‚
 โ”‚  - 11 Registered Tools                                                      โ”‚
 โ”‚  - Asynchronous Reentrancy Lock (`browser_lock`)                            โ”‚
 โ”‚  - Error Normalization & Structured JSON Output Formatting                  โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ”‚ Python WebDriver + CDP
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚               Browser Manager & Infrastructure (app/browser.py)             โ”‚
 โ”‚  - Chrome Auto-Launch on Port 9222 (Headless or Headed)                     โ”‚
 โ”‚  - Persistent Profile: C:\mcp-browser-profile                               โ”‚
 โ”‚  - Prototype Stealth Injections (Overrides `navigator.webdriver`)           โ”‚
 โ”‚  - SSL Intercept Bypass (`--ignore-certificate-errors`)                     โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ”‚
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ–ผ                            โ–ผ                            โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ Provider Engines  โ”‚        โ”‚ Direct Web Search โ”‚        โ”‚  CAPTCHA Defense  โ”‚
 โ”‚ (app/providers/)  โ”‚        โ”‚ (google.py)       โ”‚        โ”‚ (captcha_solver)  โ”‚
 โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
 โ”‚ โ€ข gemini.py       โ”‚        โ”‚ โ€ข Organic Scraper โ”‚        โ”‚ โ€ข Fast DOM Click  โ”‚
 โ”‚ โ€ข chatgpt.py      โ”‚        โ”‚ โ€ข AI Overview     โ”‚        โ”‚ โ€ข browser-use +   โ”‚
 โ”‚ โ€ข claude.py       โ”‚        โ”‚ โ€ข Query Citations โ”‚        โ”‚   Ollama Vision   โ”‚
 โ”‚ โ€ข deepseek.py     โ”‚        โ”‚                   โ”‚        โ”‚   (gemma4:31b)    โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”„ End-to-End Execution Flow

Every request dispatched to the server follows a strict, deterministic sequence:

[1. Request Arrives]  -->  MCP Tool invoked (e.g. ask_chatgpt, ask_claude)
         โ”‚
[2. Concurrency Lock] -->  Acquire `browser_lock` (ensures single-tab execution safety)
         โ”‚
[3. Browser Health]   -->  Ensure Chrome is alive on 127.0.0.1:9222; auto-start if down
         โ”‚
[4. Tab Isolation]    -->  Provider activates or opens its designated tab (e.g. chatgpt.com)
         โ”‚
[5. Anti-Bot Gate]    -->  `VisionCaptchaSolver.is_captcha_present()` runs:
         โ”‚                 โ”œโ”€โ”€ Not Present: Continue instantly (< 1ms latency)
         โ”‚                 โ””โ”€โ”€ Present:
         โ”‚                      โ”œโ”€โ”€ Tier 1: Instant JavaScript DOM click (1-2s)
         โ”‚                      โ””โ”€โ”€ Tier 2: Escalate to browser-use + Ollama Vision
         โ”‚
[6. DOM Input]        -->  Inject prompt using provider-specific rich-text strategy:
         โ”‚                 โ€ข Gemini: Quill `document.execCommand('insertText')`
         โ”‚                 โ€ข ChatGPT: TipTap contenteditable innerHTML dispatch
         โ”‚                 โ€ข Claude: ProseMirror event synthesizer
         โ”‚                 โ€ข DeepSeek: Native JavaScript HTMLTextAreaElement prototype
         โ”‚
[7. Generation Wait]  -->  Poll generation indicator (stop button, pulse animation, or shimmer)
         โ”‚
[8. Extraction]       -->  Extract sanitized Markdown text, search citations, or full-res PNG
         โ”‚
[9. Return & Release] -->  Format standardized JSON envelope, release `browser_lock`

๐Ÿ›ก๏ธ Autonomous Vision CAPTCHA Solver

Security verification challenges (such as Cloudflare Turnstile's "Verify you are human") can block automated browsers. Instead of relying on paid, third-party browser extensions (NopeCHA, Buster, 2Captcha), this server incorporates an autonomous vision solver:

                  Challenge Detected on Page
                              โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ                               โ–ผ
       [Tier 1: Fast DOM]            [Challenge Persists?]
   Direct click on Turnstile iframe           โ”‚ Yes
   or verify button via JavaScript            โ–ผ
              โ”‚                     [Tier 2: Vision Escalation]
          Cleared?               Attach browser-use via CDP
         /        \              Snapshot DOM & Viewport
      Yes          No            Pass screenshot to Ollama (gemma4:31b)
      โ”‚             โ”‚                         โ”‚
   Resume       Escalate                      โ–ผ
                           Model spots checkbox -> outputs click action
                                              โ”‚
                                              โ–ผ
                           Action Schema Normalizer:
                           {"click": 35} -> {"click": {"index": 35}}
                                              โ”‚
                                              โ–ผ
                           browser-use clicks checkbox -> Verifies "Success"
                                              โ”‚
                                              โ–ผ
                           Challenge Cleared -> Control returns to Provider

Why Normalization Matters

Local and lightweight vision models (like gemma4:31b-cloud) often output shorthand actions (e.g., {"click": 35}) rather than the deeply nested Pydantic schemas required by browser-use. The integration in browser_use.llm.ollama.chat includes an automatic action schema normalizer (_normalize_ollama_actions) that translates shorthand instructions into valid action models on the fly.


๐Ÿงฉ Provider Implementation Matrix

Provider

Base URL

Input Automation Strategy

Streaming & Completion Detection

Special Capabilities

Google Gemini

gemini.google.com/app

Quill editor via execCommand('insertText')

Monitors .stop-button and mat-icon[fonticon='stop']

Imagen diffusion image generation, high-res HTML5 Canvas extraction

ChatGPT

chatgpt.com

TipTap contenteditable composer with synthetic input events

Detects stop button presence (avoids false-positive dormant pulse classes)

Native Web Search (search_chatgpt), DALL-E 3 image generation

Claude

claude.ai/new

ProseMirror input area with session isolation

Observes streaming cursor and response container mutations

Strict /new chat isolation, Claude Sonnet formatting

DeepSeek

chat.deepseek.com

Native HTMLTextAreaElement.prototype value setter

Detects completion of reasoning blocks and stop button clearance

DeepThink reasoning mode, DeepSeek Web Search

Google Search

google.com

Direct URL navigation (/search?q=...)

Fast page load and DOM readiness detection

Scrapes organic search results (clean URLs, snippets) + Google AI Overviews


๐Ÿ› ๏ธ First-Time Setup Guide

1. Install System Prerequisites

  • Python 3.10+ (Anaconda or standard virtualenv)

  • Google Chrome installed in standard Windows location

  • Ollama installed and running (for autonomous CAPTCHA solving):

    ollama serve
    ollama pull gemma4:31b-cloud

2. Install Python Dependencies

cd BrowserApi
pip install -r requirements.txt
playwright install chromium

3. One-Time Login (Profile Initialization)

To allow Chrome to save your session cookies permanently:

  1. Run the helper script:

    start_chrome.bat
  2. A visible Chrome window will open using the profile directory at C:\mcp-browser-profile.

  3. Log in to each provider:

  4. Once you are logged in and can see the chat interface on each, close the Chrome window.


๐Ÿš€ Running the MCP Server

Mode 1: Server-Sent Events (SSE) โ€” Default

Runs a persistent HTTP/SSE server accessible by network or multi-client setups:

python server.py
  • Starts the SSE server on http://127.0.0.1:8000/sse.

  • Automatically launches Chrome in the background on port 9222.

Mode 2: Standard I/O (Stdio) โ€” For AI Desktop Clients

Runs directly via process stdin/stdout:

python server.py --stdio

๐Ÿ’ป MCP Client Configuration

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "browser-agent": {
      "command": "python",
      "args": [
        "C:\\Users\\CT_USER\\Desktop\\BrowserApi\\server.py",
        "--stdio"
      ]
    }
  }
}

Cursor / Antigravity IDE

Add the server under MCP Settings:

  • Name: browser-agent

  • Transport: stdio

  • Command: python C:\Users\CT_USER\Desktop\BrowserApi\server.py --stdio

(Alternatively, connect via SSE to http://127.0.0.1:8000/sse)


๐Ÿงฐ Available MCP Tools Reference

Tool

Parameters

Description

health_check

None

Returns the real-time health of the server, Chrome port 9222, login status for all 4 providers, and Ollama status.

search_google

query: strnum_results: int = 10timeout: int = 60

Direct Google Search; returns organic search results (titles, links, snippets) and Google AI Overview synthesis.

search_web

query: strprovider: str = "google"timeout: int = 120

Unified web search router. Options for provider: 'google', 'chatgpt', 'deepseek', 'gemini'.

ask_gemini

prompt: strtimeout: int = 120

Queries Google Gemini in a clean session. Automatically detects image generation requests.

generate_image_gemini

prompt: stroutput_name: str = ""

Generates an image using Gemini Imagen diffusion and downloads high-res PNG to data/outputs/.

ask_chatgpt

prompt: strtimeout: int = 120web_search: bool = False

Queries ChatGPT Free / Plus in an isolated session with optional web search synthesis.

search_chatgpt

query: strtimeout: int = 120

Searches the web using ChatGPT's built-in search engine; returns answer with citations.

generate_image_chatgpt

prompt: stroutput_name: str = ""

Generates an image via ChatGPT DALL-E 3 and saves it to data/outputs/.

ask_claude

prompt: strtimeout: int = 120

Queries Anthropic Claude in a fresh /new chat session.

ask_deepseek

prompt: strtimeout: int = 120web_search: bool = Falsedeepthink: bool = False

Queries DeepSeek with optional live Web Search or DeepThink reasoning mode.

search_deepseek

query: strtimeout: int = 120

Searches the live web using DeepSeek's search pipeline.


๐Ÿงช CLI Testing Suite

The project includes test and diagnostic scripts:

1. Provider & Search Tests (test.py)

# Health check across all providers
python test.py

# Chat with individual providers
python test.py --provider=gemini "Explain quantum entanglement in 2 sentences"
python test.py --provider=chatgpt "Summarize the history of space flight"
python test.py --provider=claude "Write a haiku about autumn"
python test.py --provider=deepseek "Write an async queue in Python"

# Web search tests
python test.py --search "Latest Mars rover discoveries"
python test.py --provider=deepseek --search "Quantum computing breakthroughs"

# Image generation tests
python test.py --image "A photorealistic red fox in a snowy forest"
python test.py --provider=chatgpt --image "A futuristic cyberpunk city at dusk"

2. Autonomous CAPTCHA Solver Diagnostic (test_vision_solver.py)

# Verify Ollama endpoint connectivity and model tags
python test_vision_solver.py --check-only

# Run live end-to-end CAPTCHA test against Cloudflare Turnstile demo
python test_vision_solver.py

๐Ÿ“ Project Directory Structure

BrowserApi/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ browser.py               # Chrome lifecycle manager, Selenium attachment, CDP stealth
โ”‚   โ”œโ”€โ”€ captcha_solver.py        # 2-Tier Vision CAPTCHA solver (Fast DOM + browser-use Ollama)
โ”‚   โ”œโ”€โ”€ config.py                # Environment variables, timeouts, ports, model names
โ”‚   โ”œโ”€โ”€ parsers.py               # Standardized JSON response envelope helpers
โ”‚   โ””โ”€โ”€ providers/
โ”‚       โ”œโ”€โ”€ __init__.py          # Provider factory and registry
โ”‚       โ”œโ”€โ”€ base.py              # Base abstract BrowserProvider class
โ”‚       โ”œโ”€โ”€ chatgpt.py           # ChatGPT automation (TipTap, Search, DALL-E 3)
โ”‚       โ”œโ”€โ”€ claude.py            # Claude automation (ProseMirror, Turnstile defense)
โ”‚       โ”œโ”€โ”€ deepseek.py          # DeepSeek automation (DOM prototype, DeepThink, Search)
โ”‚       โ”œโ”€โ”€ gemini.py            # Google Gemini automation (Quill, Imagen diffusion)
โ”‚       โ””โ”€โ”€ google.py            # Direct Google Search & AI Overview scraper
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ logs/                    # Runtime application logs (browser_mcp.log)
โ”‚   โ”œโ”€โ”€ outputs/                 # Generated full-resolution images (.png)
โ”‚   โ””โ”€โ”€ screenshots/             # Diagnostic screenshots (ignored in git)
โ”œโ”€โ”€ server.py                    # Main FastMCP server (exposes 11 tools via SSE / stdio)
โ”œโ”€โ”€ start_chrome.bat             # Helper script to launch Chrome headed for one-time login
โ”œโ”€โ”€ test.py                      # Multi-provider CLI verification client
โ”œโ”€โ”€ test_vision_solver.py        # Standalone vision CAPTCHA solver test script
โ”œโ”€โ”€ requirements.txt             # Python dependencies
โ”œโ”€โ”€ .gitignore                   # Ignores temp caches, profiles, logs, and generated images
โ””โ”€โ”€ README.md                    # Comprehensive documentation and flow definition

๐Ÿ”ง Troubleshooting & FAQ

Q: How does Chrome stay logged in?

Chrome uses the persistent directory C:\mcp-browser-profile. All cookies, localStorage, and authentication tokens persist across reboots.

Q: A provider logged me out. What do I do?

  1. Close any running python server.py.

  2. Run start_chrome.bat.

  3. Log in again in the Chrome window that opens.

  4. Close Chrome and restart python server.py.

Q: Can I run Chrome in visible (headed) mode for debugging?

Yes. In app/config.py, set:

chrome_headless: bool = False

Chrome will run in a visible window so you can watch actions occur in real time.

Q: Does CAPTCHA solving slow down normal requests?

No. is_captcha_present() runs lightweight DOM checks that execute in under a millisecond. The vision agent is only activated on-demand when a challenge is verified to be blocking the page.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    An extension-based MCP server that enables AI assistants to control your existing Chrome browser, leveraging your active login states and settings for automation. It provides over 20 tools for tasks like semantic tab search, screen capture, network monitoring, and direct element interaction.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server that drives a user's real Chrome browser via a WebSocket-connected MV3 extension, enabling tab management, navigation, page interaction, screenshots, and script evaluation through natural language.
    8 npm
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables any MCP-compatible AI agent to drive your own Chrome browser with your existing login state, filling forms, clicking elements, fetching data, and handling captchas without API keys or re-authentication.
    609 npm
    255
    MIT