cloudflare browser rendering mcp
This MCP server provides tools for interacting with Cloudflare Browser Rendering, allowing you to fetch and process web content for use as context in LLMs directly from Cline or Claude Desktop.
This MCP server provides tools for interacting with Cloudflare Browser Rendering, allowing you to fetch and process web content for use as context in LLMs directly from Cline or Claude Desktop.
This MCP (Model Context Protocol) server provides tools for fetching and processing web content using Cloudflare Browser Rendering for use as context in LLMs. It's designed to work with both Claude and Cline client environments.
puppeteer-worker.js
fileTo install Cloudflare Browser Rendering for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @amotivv/cloudflare-browser-rendering-mcp --client claude
Clone this repository:
git clone https://github.com/yourusername/cloudflare-browser-rendering.git
cd cloudflare-browser-rendering
Install dependencies:
npm install
Build the project:
npm run build
Deploy the puppeteer-worker.js
file to Cloudflare Workers using Wrangler:
npx wrangler deploy
Make sure to configure the following bindings in your Cloudflare Worker:
browser
KV namespace binding named SCREENSHOTS
Note the URL of your deployed worker (e.g., https://browser-rendering-api.yourusername.workers.dev
)
Open the Claude Desktop configuration file:
# macOS
code ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows
code %APPDATA%Claudeclaude_desktop_config.json
Add the MCP server configuration:
{
"mcpServers": {
"cloudflare-browser-rendering": {
"command": "node",
"args": ["/path/to/cloudflare-browser-rendering/dist/index.js"],
"env": {
"BROWSER_RENDERING_API": "https://your-worker-url.workers.dev"
},
"disabled": false,
"autoApprove": []
}
}
}
Restart Claude Desktop
Open the Cline MCP settings file:
# macOS
code ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
# Windows
code %APPDATA%CodeUserglobalStoragesaoudrizwan.claude-devsettingscline_mcp_settings.json
Add the MCP server configuration:
{
"mcpServers": {
"cloudflare-browser-rendering": {
"command": "node",
"args": ["/path/to/cloudflare-browser-rendering/dist/index.js"],
"env": {
"BROWSER_RENDERING_API": "https://your-worker-url.workers.dev"
},
"disabled": false,
"autoApprove": []
}
}
}
Once configured, the MCP server will be available to both Claude Desktop and Cline. You can use the following tools:
Fetches and processes a web page for LLM context.
Parameters:
- url
(required): URL to fetch
- maxContentLength
(optional): Maximum content length to return
Example:
Can you fetch and summarize the content from https://developers.cloudflare.com/browser-rendering/?
Searches Cloudflare documentation and returns relevant content.
Parameters:
- query
(required): Search query
- maxResults
(optional): Maximum number of results to return
Example:
Search the Cloudflare documentation for information about "browser rendering API".
Extracts structured content from a web page using CSS selectors.
Parameters:
- url
(required): URL to extract content from
- selectors
(required): CSS selectors to extract content
Example:
Extract the main heading and first paragraph from https://developers.cloudflare.com/browser-rendering/ using the selectors h1 and p.
Summarizes web content for more concise LLM context.
Parameters:
- url
(required): URL to summarize
- maxLength
(optional): Maximum length of the summary
Example:
Summarize the content from https://developers.cloudflare.com/browser-rendering/ in 300 words or less.
Takes a screenshot of a web page.
Parameters:
- url
(required): URL to take a screenshot of
- width
(optional): Width of the viewport in pixels (default: 1280)
- height
(optional): Height of the viewport in pixels (default: 800)
- fullPage
(optional): Whether to take a screenshot of the full page or just the viewport (default: false)
Example:
Take a screenshot of https://developers.cloudflare.com/browser-rendering/ with a width of 1024 pixels.
The MCP server uses comprehensive logging with the following prefixes:
[Setup]
: Initialization and configuration[API]
: API requests and responses[Error]
: Error handling and debuggingTo view logs:
~/Library/Logs/Claude/mcp*.log
(macOS) or %APPDATA%ClaudeLogsmcp*.log
(Windows)Make sure you've set the correct URL to your Cloudflare Worker in the MCP server configuration
"Cloudflare worker API is unavailable or not configured"
Check that the URL is correct and accessible
"Browser binding is not available"
Ensure that you've configured the Browser Rendering binding in your Cloudflare Worker
"SCREENSHOTS KV binding is not available"
src/index.ts
: Main entry pointsrc/server.ts
: MCP server implementationsrc/browser-client.ts
: Client for interacting with Cloudflare Browser Renderingsrc/content-processor.ts
: Processes web content for LLM contextpuppeteer-worker.js
: Cloudflare Worker implementationnpm run build
The project includes a comprehensive test script that verifies all MCP tools are working correctly:
npm test
This will: 1. Start the MCP server 2. Test each tool with sample requests 3. Verify the responses 4. Provide a summary of test results
You can also run individual tests for specific components:
# Test the Puppeteer integration
npm run test:puppeteer
For the tests to work properly, make sure you have:
1. Built the project with npm run build
2. Set the BROWSER_RENDERING_API
environment variable to your Cloudflare Worker URL
3. Deployed the Cloudflare Worker with the necessary bindings
MIT
[
{
"description": "Fetches and processes a web page for LLM context",
"inputSchema": {
"properties": {
"maxContentLength": {
"description": "Maximum content length to return",
"type": "number"
},
"url": {
"description": "URL to fetch",
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
},
"name": "fetch_page"
},
{
"description": "Searches Cloudflare documentation and returns relevant content",
"inputSchema": {
"properties": {
"maxResults": {
"description": "Maximum number of results to return",
"type": "number"
},
"query": {
"description": "Search query",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
},
"name": "search_documentation"
},
{
"description": "Extracts structured content from a web page using CSS selectors",
"inputSchema": {
"properties": {
"selectors": {
"additionalProperties": {
"type": "string"
},
"description": "CSS selectors to extract content",
"type": "object"
},
"url": {
"description": "URL to extract content from",
"type": "string"
}
},
"required": [
"url",
"selectors"
],
"type": "object"
},
"name": "extract_structured_content"
},
{
"description": "Summarizes web content for more concise LLM context",
"inputSchema": {
"properties": {
"maxLength": {
"description": "Maximum length of the summary",
"type": "number"
},
"url": {
"description": "URL to summarize",
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
},
"name": "summarize_content"
},
{
"description": "Takes a screenshot of a web page and returns it as an image",
"inputSchema": {
"properties": {
"fullPage": {
"description": "Whether to take a screenshot of the full page or just the viewport (default: false)",
"type": "boolean"
},
"height": {
"description": "Height of the viewport in pixels (default: 800)",
"type": "number"
},
"url": {
"description": "URL to take a screenshot of",
"type": "string"
},
"width": {
"description": "Width of the viewport in pixels (default: 1280)",
"type": "number"
}
},
"required": [
"url"
],
"type": "object"
},
"name": "take_screenshot"
}
]