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.
git clone https://github.com/yourusername/cloudflare-browser-rendering.git
cd cloudflare-browser-rendering
npm install
npm install @cloudflare/puppeteer
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"
npx wrangler deploy
node test-puppeteer.js
npm run build
For production:
npm start
For development with automatic reloading:
npm run dev
The server provides several tools for working with web content:
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:
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 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.
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);
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);
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);
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.
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"
]
}
}
}
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.
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.