by amotivv
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
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%\Claude\claude_desktop_config.json
Add the MCP server configuration:
*Configuration content*
Can you fetch and summarize the content from https://developers.cloudflare.com/browser-rendering/?
### search\_documentation
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".
### extract\_structured\_content
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.
### summarize\_content
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.
### take\_screenshot
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.
## Troubleshooting
### Logging
The MCP server uses comprehensive logging with the following prefixes:
- `[Setup]`: Initialization and configuration
- `[API]`: API requests and responses
- `[Error]`: Error handling and debugging
To view logs:
- **Claude Desktop**: Check the logs in `~/Library/Logs/Claude/mcp*.log` (macOS) or `%APPDATA%\Claude\Logs\mcp*.log` (Windows)
- **Cline**: Logs appear in the output console of the VSCode extension
### Common Issues
1. **"BROWSER\_RENDERING\_API environment variable is not set"**
- Make sure you've set the correct URL to your Cloudflare Worker in the MCP server configuration
1. **"Cloudflare worker API is unavailable or not configured"**
- Verify that your Cloudflare Worker is deployed and running
- Check that the URL is correct and accessible
1. **"Browser binding is not available"**
- Ensure that you've configured the Browser Rendering binding in your Cloudflare Worker
1. **"SCREENSHOTS KV binding is not available"**
- Ensure that you've configured the KV namespace binding in your Cloudflare Worker
## Development
### Project Structure
- `src/index.ts`: Main entry point
- `src/server.ts`: MCP server implementation
- `src/browser-client.ts`: Client for interacting with Cloudflare Browser Rendering
- `src/content-processor.ts`: Processes web content for LLM context
- `puppeteer-worker.js`: Cloudflare Worker implementation
### Building
```bash
npm run build
The project includes a comprehensive test script that verifies all MCP tools are working correctly:
npm test
This will:
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:
npm run build
BROWSER_RENDERING_API
environment variable to your Cloudflare Worker URLMIT
No version information available
0 contributors