Cloudflare Browser Rendering MCP server

Integrates with Cloudflare's Browser Rendering API to enable web scraping and screenshot capture using Puppeteer for dynamic content processing and automated visual testing.
Back to servers
Provider
Amotivv
Release date
Mar 01, 2025
Language
TypeScript
Stats
6 stars

This MCP server leverages Cloudflare Browser Rendering to extract web content for use as context in Large Language Models (LLMs). It provides tools to fetch, process, and optimize web pages for AI consumption through a standardized Model Context Protocol interface.

Prerequisites

  • Node.js (v16 or later)
  • A Cloudflare account with Browser Rendering enabled
  • TypeScript
  • Wrangler CLI (for deploying the Worker)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/cloudflare-browser-rendering.git
cd cloudflare-browser-rendering
  1. Install dependencies:
npm install

Cloudflare Worker Setup

  1. Install the Cloudflare Puppeteer package:
npm install @cloudflare/puppeteer
  1. Configure Wrangler by creating or updating your wrangler.toml file:
# wrangler.toml
name = "browser-rendering-api"
main = "puppeteer-worker.js"
compatibility_date = "2023-10-30"
compatibility_flags = ["nodejs_compat"]

[browser]
binding = "browser"
  1. Deploy the Worker:
npx wrangler deploy
  1. Test the Worker:
node test-puppeteer.js

MCP Server

Building the MCP Server

npm run build

Running the MCP Server

For production:

npm start

For development with automatic reloading:

npm run dev

MCP Server Tools

The server provides several tools for working with web content:

  1. fetch_page - Retrieves and processes a web page for LLM context
  2. search_documentation - Searches Cloudflare documentation and returns relevant content
  3. extract_structured_content - Pulls specific content from a web page using CSS selectors
  4. summarize_content - Creates condensed summaries of web content for more efficient LLM context

Configuration

To use your Cloudflare Browser Rendering endpoint, set the BROWSER_RENDERING_API environment variable:

export BROWSER_RENDERING_API=https://YOUR_WORKER_URL_HERE

You'll need to replace YOUR_WORKER_URL_HERE in several places:

  1. In test files: test-puppeteer.js, examples/debugging-tools/debug-test.js, examples/testing/content-test.js
  2. In the MCP server configuration: cline_mcp_settings.json.example
  3. In the browser client: src/browser-client.ts (as a fallback if the environment variable is not set)

Integrating with Cline

To integrate with Cline, copy the example configuration file:

cp cline_mcp_settings.json.example ~/Library/Application\ Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

Alternatively, add the configuration to your existing cline_mcp_settings.json file.

Usage Examples

Fetching Content from a Web Page

To retrieve content from a specific URL:

// Example request to the MCP server
const response = await fetch("http://localhost:3000/api/generate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    tool: "fetch_page",
    parameters: {
      url: "https://example.com/page",
      selectors: ".main-content, #article-body" // Optional CSS selectors
    }
  })
});

const result = await response.json();
console.log(result.content);

Searching Documentation

To search Cloudflare documentation:

const response = await fetch("http://localhost:3000/api/generate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    tool: "search_documentation",
    parameters: {
      query: "browser rendering api",
      limit: 5 // Optional limit for results
    }
  })
});

const result = await response.json();
console.log(result.content);

Extracting Structured Content

To extract specific elements from a page:

const response = await fetch("http://localhost:3000/api/generate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    tool: "extract_structured_content",
    parameters: {
      url: "https://example.com/products",
      selectors: {
        products: ".product-card",
        prices: ".product-price",
        descriptions: ".product-description"
      }
    }
  })
});

const result = await response.json();
console.log(result.structured_data);

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later