Web Scraper MCP Server
The Web Scraper MCP Server is a comprehensive TypeScript web scraping tool that extracts, processes, and manages web content efficiently.
Core Scraping Capabilities:
Scrape single web pages or batch process multiple URLs simultaneously
Export content in multiple formats: Markdown, Text, HTML, or JSON
Handle dynamic Single Page Applications (SPAs) using Puppeteer headless browsing
Extract images and text content, saving them locally
Smart content extraction that automatically detects main page content
Advanced Features:
Define custom rule sets or use built-in ones (blog, news) to extract specific page elements using CSS selectors
Set custom domain-specific HTTP headers to bypass login restrictions or handle authentication
Monitor scraping operation status in real-time
Data Management:
List information about previously downloaded files (images and text)
Clean up and delete scraped files when needed
Organize and manage all scraped data efficiently
Leverages Git for version control, enabling users to clone and manage the web scraper codebase.
Enables export of web content as Markdown, converting HTML to a readable format with preserved headings, links, and images.
Uses npm for package management, allowing easy installation and dependency management for the web scraper.
Utilizes Puppeteer headless browser to render JavaScript-heavy websites and single-page applications (SPAs) for complete content extraction.
Built with TypeScript, providing type-safe web scraping capabilities with custom rule sets and domain-specific headers.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Web Scraper MCP Server scrape https://news.ycombinator.com with the news rule set"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Web Scraper MCP Server
基于 Model Context Protocol (MCP) 的 TypeScript 网页爬取服务器,内置多种常用爬取与命令工具。
使用npx配置MCP(无需clone代码)
"web-scraper-puppeteer": {
"command": "npx",
"args": [
"-y",
"web-scraper-mcp-puppeteer",
"mcpserver-puppeteer-nakiwang"
]
}
Related MCP server: ScrapeGraph MCP Server
功能特性
🚀 多种导出格式: 支持将爬取内容导出为 Markdown、Text、HTML 和 JSON 格式
🎭 Puppeteer 无头浏览器: 解决未实现静态化的 SPA 单页应用渲染问题
📋 规则集支持: 支持设置规则集,实现抓取网页的特定部分内容
🔧 自定义域名 Headers: 支持设置自定义域名 Headers,绕过网站登录限制
📦 批量爬取: 支持同时爬取多个 URL
🎯 智能内容提取: 自动识别和提取网页主要内容
安装
# 克隆项目
git clone <repository-url>
cd web-scraper-mcp
# 安装依赖
npm install
# 构建项目
npm run build使用方法
启动服务器
npm start可用工具
1. scrape_url - 爬取单个网页
{
"name": "scrape_url",
"arguments": {
"url": "https://example.com",
"format": "markdown",
"usePuppeteer": false,
"ruleSet": "blog",
"customHeaders": {
"Authorization": "Bearer token"
}
}
}参数说明:
url(必需): 要爬取的网页 URLformat(可选): 导出格式,支持markdown、text、html、json,默认为markdownusePuppeteer(可选): 是否使用 Puppeteer 无头浏览器,默认为falseruleSet(可选): 规则集名称,用于提取特定内容customHeaders(可选): 自定义请求头
2. create_rule_set - 创建内容提取规则集
{
"name": "create_rule_set",
"arguments": {
"name": "my_blog_rule",
"rules": {
"title": "h1, .post-title",
"content": ".post-content, article",
"links": ".post-content a",
"images": ".post-content img",
"exclude": ["nav", "footer", ".sidebar"]
}
}
}参数说明:
name(必需): 规则集名称rules(必需): 提取规则配置title: 标题选择器content: 内容选择器links: 链接选择器images: 图片选择器exclude: 要排除的选择器列表
3. set_domain_headers - 设置域名请求头
{
"name": "set_domain_headers",
"arguments": {
"domain": "example.com",
"headers": {
"Authorization": "Bearer your-token",
"X-Custom-Header": "custom-value"
}
}
}4. batch_scrape - 批量爬取
{
"name": "batch_scrape",
"arguments": {
"urls": [
"https://example1.com",
"https://example2.com",
"https://example3.com"
],
"format": "markdown",
"usePuppeteer": false,
"ruleSet": "blog"
}
}预定义规则集
系统内置了以下规则集:
blog: 适用于大多数博客文章页面
news: 适用于新闻网站文章
product: 适用于电商产品页面
documentation: 适用于技术文档页面
forum: 适用于论坛帖子页面
导出格式
Markdown
将网页内容转换为 Markdown 格式,包含标题、内容、链接和图片。
Text
纯文本格式,去除所有 HTML 标签。
HTML
清理后的 HTML 格式,移除脚本和样式。
JSON
完整的结构化数据,包含所有提取的信息。
开发
项目结构
src/
├── index.ts # 主服务器文件
├── scraper/
│ └── webScraper.ts # 网页爬取器
├── export/
│ └── exportManager.ts # 导出管理器
├── rules/
│ └── ruleEngine.ts # 规则引擎
├── headers/
│ └── headerManager.ts # 请求头管理器
└── utils/
└── logger.ts # 日志工具开发模式
# 监听文件变化并自动重新构建
npm run dev测试
npm test配置
环境变量
LOG_LEVEL: 日志级别 (debug, info, warn, error)PUPPETEER_TIMEOUT: Puppeteer 超时时间(毫秒)REQUEST_TIMEOUT: HTTP 请求超时时间(毫秒)
自定义配置
可以通过修改源代码来自定义:
默认请求头: 编辑
src/headers/headerManager.ts预定义规则集: 编辑
src/rules/ruleEngine.ts导出格式: 编辑
src/export/exportManager.ts
常见问题
Q: 为什么某些网站爬取失败?
A: 可能是因为网站有反爬虫机制。尝试:
使用
usePuppeteer: true启用无头浏览器设置合适的自定义请求头
使用预定义的反检测请求头
Q: 如何处理需要登录的网站?
A: 使用 set_domain_headers 工具设置包含认证信息的请求头,如 Cookie 或 Authorization。
Q: SPA 应用内容为空怎么办?
A: 设置 usePuppeteer: true 使用 Puppeteer 渲染动态内容。
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
Available Tools
7 toolscleanup_imagesC
清理所有下载的图片文件
Inputs: outputDir.
cleanup_textsC
清理所有提取的文本文件
Inputs: outputDir.
get_scraping_statusC
获取爬虫状态信息
Inputs: outputDir.
list_imagesC
列出所有已下载的图片信息
Inputs: outputDir.
list_textsC
列出所有已提取的文本文件
Inputs: outputDir.
scrape_imagesC
从指定URL爬取网站上的所有图片并保存到本地
Inputs: url (required), outputDir, maxConcurrent.
scrape_textC
从指定URL爬取网站的文本内容并保存为Markdown文件
Inputs: url (required), outputDir.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Every tool has a clearly distinct purpose with no ambiguity. The tools are cleanly divided between scraping operations (scrape_images, scrape_text), listing operations (list_images, list_texts), cleanup operations (cleanup_images, cleanup_texts), and status monitoring (get_scraping_status). There is no overlap in functionality.
The naming follows a perfectly consistent verb_noun pattern throughout. All tools use snake_case with clear action prefixes (scrape_, list_, cleanup_, get_) followed by specific resource nouns (images, texts, scraping_status). There are no deviations in naming conventions.
The 7 tools are well-scoped for a web scraping server. Each tool earns its place by covering distinct aspects of the scraping workflow: initiating scrapes, listing results, cleaning up files, and checking status. This is an appropriate number for the domain without being too thin or bloated.
The tool surface provides excellent coverage for core web scraping operations with clear CRUD-like patterns (create via scrape, read via list, delete via cleanup). The only minor gap is the lack of update operations for existing scraped content, but agents can work around this by re-scraping. Status monitoring is included, which is valuable for workflow management.
Related MCP Connectors
Web scraping MCP server — scrape, extract structured data, screenshot any site with anti-bot bypass.
Web scraping MCP server: any URL to Markdown or JSON, with JavaScript rendering and batch jobs.
Cloud scraping & crawling API for AI agents. Turn any URL into clean, LLM-ready markdown.
Web scraping, extraction and search for AI agents. Hosted MCP with workspace API keys.
Related MCP Servers
- AlicenseBqualityDmaintenanceA TypeScript-based MCP server utilizing the UseScraper API to provide web scraping capabilities, allowing users to extract content from webpages in various formats.14MIT
- AlicenseAqualityDmaintenanceA production-ready Model Context Protocol server that enables language models to leverage AI-powered web scraping capabilities, offering tools for transforming webpages to markdown, extracting structured data, and executing AI-powered web searches.898 PyPI121MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows LLMs to interact with web content through standardized tools, currently supporting web scraping functionality.1MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server that enables web scraping, crawling, and content extraction capabilities through integration with Firecrawl.8181,541 npm2MIT