Web Content Scraper MCP Worker

Web Content Scraper MCP Worker

Scrapes dynamic web pages via headless Chrome, stripping clutter and ads, and returns clean Markdown or JSON content. It integrates with Cloudflare Workflows and monetizes each extraction through the x402 protocol.

Category
访问服务器

README

Web Content Scraper MCP Worker

A high-performance Cloudflare Worker project that presents an agent-ready Model Context Protocol (MCP) Tool and REST API endpoint for dynamic web content extraction. Built with TypeScript, Cloudflare Workflows, Cloudflare Browser Rendering (@cloudflare/puppeteer), and the MCP SDK (@modelcontextprotocol/sdk), monetized with the x402 payment protocol ($0.005 USDC per call on Base).


🌟 Key Features

  1. Dynamic Page Scraping & Headless Chrome:
    • Uses Cloudflare Browser Rendering (@cloudflare/puppeteer) to execute dynamic JavaScript, handle client-side rendering (SPAs/React/Vue/Next.js), and bypass anti-bot layout hurdles.
  2. Boilerplate & Ad Stripping:
    • In-browser DOM parsing automatically strips scripts, stylesheets, navigation bars, headers, footers, sidebars, cookie banners, popups, and advertisement blocks.
  3. Structured Content Output:
    • Markdown Format (default): Converts page hierarchy into clean structured Markdown (# Headings, paragraphs, lists, blockquotes, code blocks, links, and images).
    • JSON Format: Extracts metadata (title, author, siteName, description), text content, headings array, link objects, and image objects.
  4. Cloudflare Workflows Integration:
    • Includes ScraperWorkflow for step-by-step asynchronous processing, step retries, and error isolation.
  5. x402 Protocol Monetization:
    • Protected endpoints require $0.005 USDC payment per execution on the Base network via the x402 microtransaction standard.

🚀 MCP Tool Specification

Tool Name: scrape_web_content

Description:

"Scrapes a dynamic web page, bypasses client-side rendering, removes clutter/ads, and extracts core content as clean Markdown or structured JSON. Use this tool when you need to read web articles, documentation, or extract main body text from any URL."

Parameters:

  • url (string, required): The HTTP/HTTPS web page URL to scrape.
  • format (string, optional): "markdown" or "json" (default: "markdown").

Response Schema:

{
  "title": "Article Title",
  "sourceUrl": "https://example.com/article",
  "extractedContent": "# Article Title\n\nCore content formatted in clean markdown...",
  "wordCount": 482
}

📡 REST API Endpoints

1. Health Diagnostics

GET /health

Response:

{
  "status": "ok",
  "service": "web-scraper-mcp-worker",
  "timestamp": "2026-08-05T16:00:00.000Z",
  "browserConfigured": true,
  "workflowConfigured": true,
  "monetization": {
    "protocol": "x402",
    "price_usdc": "0.005",
    "network": "base",
    "payee_address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e"
  }
}

2. Scraping Endpoint (x402 Protected)

POST /api/scrape
Content-Type: application/json

{
  "url": "https://example.com/blog/dynamic-article",
  "format": "markdown"
}

3. Workflow Trigger Endpoint

POST /api/workflow/scrape
Content-Type: application/json

{
  "url": "https://example.com/docs/api",
  "format": "json"
}

4. MCP JSON-RPC Protocol Endpoint (x402 Protected)

POST /mcp
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "scrape_web_content",
    "arguments": {
      "url": "https://news.ycombinator.com",
      "format": "markdown"
    }
  }
}

💳 x402 Monetization Flow

Unauthenticated requests to protected endpoints return an HTTP 402 Payment Required status code with x402 headers:

HTTP/1.1 402 Payment Required
WWW-Authenticate: X-402 payee="0x742d35Cc6634C0532925a3b844Bc454e4438f44e" asset="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" amount="5000" network="eip155:8453"
Content-Type: application/json

{
  "x402Version": 1,
  "error": "Payment Required",
  "payment": {
    "scheme": "exact",
    "network": "eip155:8453",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "amount": "5000",
    "human_amount": "$0.005 USDC",
    "payee": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "resource": "/api/scrape",
    "description": "Dynamic Web Scraper & Content Extractor ($0.005 USDC per execution)"
  }
}

Include payment authorization proof in the X-PAYMENT header to execute requests.


🛠 Local Development & Deployment

Prerequisites

  • Node.js 18+
  • Cloudflare Workers Paid account (for Browser Rendering in production)

Commands

# Install dependencies
npm install

# Type Check
npm run type-check

# Local Development Server
npm run dev

# Deploy to Cloudflare Workers
npm run deploy

📄 License

MIT License.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选