Cloudflare Browser Rendering
STDIOMCP server using Cloudflare Browser Rendering to extract web content for LLM context.
MCP server using Cloudflare Browser Rendering to extract web content for LLM context.
This project demonstrates how to use Cloudflare Browser Rendering to extract web content for LLM context. It includes experiments with the REST API and Workers Binding API, as well as an MCP server implementation that can be used to provide web context to LLMs.
cloudflare-browser-rendering/
├── examples/ # Example implementations and utilities
│ ├── basic-worker-example.js # Basic Worker with Browser Rendering
│ ├── minimal-worker-example.js # Minimal implementation
│ ├── debugging-tools/ # Tools for debugging
│ │ └── debug-test.js # Debug test utility
│ └── testing/ # Testing utilities
│ └── content-test.js # Content testing utility
├── experiments/ # Educational experiments
│ ├── basic-rest-api/ # REST API tests
│ ├── puppeteer-binding/ # Workers Binding API tests
│ └── content-extraction/ # Content processing tests
├── src/ # MCP server source code
│ ├── index.ts # Main entry point
│ ├── server.ts # MCP server implementation
│ ├── browser-client.ts # Browser Rendering client
│ └── content-processor.ts # Content processing utilities
├── puppeteer-worker.js # Cloudflare Worker with Browser Rendering binding
├── test-puppeteer.js # Tests for the main implementation
├── wrangler.toml # Wrangler configuration for the Worker
├── cline_mcp_settings.json.example # Example MCP settings for Cline
├── .gitignore # Git ignore file
└── LICENSE # MIT License
git clone https://github.com/yourusername/cloudflare-browser-rendering.git cd cloudflare-browser-rendering
npm install
npm install @cloudflare/puppeteer
# wrangler.toml name = "browser-rendering-api" main = "puppeteer-worker.js" compatibility_date = "2023-10-30" compatibility_flags = ["nodejs_compat"] [browser] binding = "browser"
npx wrangler deploy
node test-puppeteer.js
This experiment demonstrates how to use the Cloudflare Browser Rendering REST API to fetch and process web content:
npm run experiment:rest
This experiment demonstrates how to use the Cloudflare Browser Rendering Workers Binding API with Puppeteer for more advanced browser automation:
npm run experiment:puppeteer
This experiment demonstrates how to extract and process web content specifically for use as context in LLMs:
npm run experiment:content
The MCP server provides tools for fetching and processing web content using Cloudflare Browser Rendering for use as context in LLMs.
npm run build
npm start
Or, for development:
npm run dev
The MCP server provides the following tools:
fetch_page
- Fetches and processes a web page for LLM contextsearch_documentation
- Searches Cloudflare documentation and returns relevant contentextract_structured_content
- Extracts structured content from a web page using CSS selectorssummarize_content
- Summarizes web content for more concise LLM contextTo use your Cloudflare Browser Rendering endpoint, set the BROWSER_RENDERING_API
environment variable:
export BROWSER_RENDERING_API=https://YOUR_WORKER_URL_HERE
Replace YOUR_WORKER_URL_HERE
with the URL of your deployed Cloudflare Worker. You'll need to replace this placeholder in several files:
test-puppeteer.js
, examples/debugging-tools/debug-test.js
, examples/testing/content-test.js
cline_mcp_settings.json.example
src/browser-client.ts
(as a fallback if the environment variable is not set)To integrate the MCP server with Cline, copy the cline_mcp_settings.json.example
file to the appropriate location:
cp cline_mcp_settings.json.example ~/Library/Application\ Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Or add the configuration to your existing cline_mcp_settings.json
file.
@cloudflare/puppeteer
package to interact with the browser binding.import puppeteer from '@cloudflare/puppeteer'; // Then in your handler: const browser = await puppeteer.launch(env.browser); const page = await browser.newPage();
nodejs_compat
compatibility flag.MIT