scrapy-mcp
A headless web-scraping MCP server built on Scrapy, providing tools for polite fetching, CSS/XPath extraction, link/table extraction, sitemap and robots.txt reading, and bounded asynchronous crawls.
README
scrapy-mcp
A headless web-scraping MCP server built on Scrapy. It exposes Scrapy's scraping primitives — polite fetching, CSS/XPath extraction, link and table extraction, sitemap and robots.txt reading, and bounded asynchronous crawls — as MCP tools an agent can call over stdio.
- Headless, no rendering. Pages are fetched and parsed as HTML; no browser, no JavaScript execution. This keeps the footprint tiny — it runs comfortably on weak machines.
- Reactor-safe. Every operation runs in a short-lived Scrapy subprocess, so Twisted's
reactor never lives inside the asyncio MCP server (no
ReactorNotRestartable), and memory is reclaimed after each call. - Polite by default. Obeys
robots.txt, throttles with AutoThrottle, and enforces hard page/depth caps so a crawl can't run away.
Install / run
Run straight from PyPI with uv — no install step:
uvx scrapy-mcp
Or install it:
uv pip install scrapy-mcp
scrapy-mcp
The server speaks MCP over stdio. Point any MCP client at it. For Claude Desktop, add to
claude_desktop_config.json:
{
"mcpServers": {
"scrapy": {
"command": "uvx",
"args": ["scrapy-mcp"]
}
}
}
Tools
| Tool | What it does |
|---|---|
fetch_page(url, format, max_bytes, obey_robots) |
Fetch one page as markdown (default), text, or html. |
extract(url, selectors, obey_robots) |
Pull structured fields with CSS/XPath selectors. |
extract_tables(url, max_tables, obey_robots) |
Extract every HTML <table> as {headers, rows}. |
extract_links(url, same_domain, pattern, limit, obey_robots) |
List de-duplicated links on a page. |
get_sitemap(url, limit, obey_robots) |
Read a sitemap (gzip + sitemap-index aware). |
check_robots(url, user_agent) |
Is a URL crawlable? Returns the crawl-delay and sitemaps. |
start_crawl(start_url, allow_patterns, deny_patterns, max_pages, max_depth, same_domain, selectors, ...) |
Start a bounded BFS crawl; returns a job_id. |
crawl_status(job_id) |
State + pages scraped for a crawl. |
crawl_results(job_id, cursor, limit) |
Page through a crawl's scraped items. |
cancel_crawl(job_id) |
Stop a running crawl; keep results so far. |
Selector format (extract / start_crawl)
selectors maps an output field to a selector. Each value is either a CSS string (first
match) or an object for more control:
{
"title": "h1::text",
"price": "span.price::text",
"all_links": {"css": "a::attr(href)", "all": true},
"first_heading": {"xpath": "//h1/text()"}
}
"all": true returns every match as a list; otherwise the first match is returned.
Crawls are asynchronous
start_crawl returns immediately with a job_id. The crawl runs as a detached worker that
streams results to disk, so it survives a server restart. Poll crawl_status(job_id), then
read items with crawl_results(job_id) (safe to call mid-crawl for partial results). Jobs are
stored under the system temp dir and reclaimed after 7 days (configurable).
Configuration
All settings are optional environment variables (sensible, polite defaults tuned for a weak
host). They're how you tune a uvx scrapy-mcp deployment.
| Variable | Default | Meaning |
|---|---|---|
SCRAPY_MCP_USER_AGENT |
scrapy-mcp/<version> … |
User-Agent header. |
SCRAPY_MCP_OBEY_ROBOTS |
true |
Obey robots.txt. |
SCRAPY_MCP_DOWNLOAD_DELAY |
0.5 |
Seconds between requests to a host. |
SCRAPY_MCP_CONCURRENT_REQUESTS |
8 |
Global concurrency. |
SCRAPY_MCP_CONCURRENT_REQUESTS_PER_DOMAIN |
4 |
Per-host concurrency. |
SCRAPY_MCP_DOWNLOAD_TIMEOUT |
30 |
Per-request timeout (s). |
SCRAPY_MCP_RETRY_TIMES |
2 |
Retries on transient failures. |
SCRAPY_MCP_AUTOTHROTTLE |
true |
Adapt delay to server latency. |
SCRAPY_MCP_MAX_BYTES |
50000 |
Max characters returned per page (then truncated). |
SCRAPY_MCP_REQUEST_TIMEOUT |
60 |
Wall-clock cap for a blocking single fetch (s). |
SCRAPY_MCP_DEFAULT_MAX_PAGES / _MAX_PAGES_CAP |
50 / 1000 |
Crawl page default / hard cap. |
SCRAPY_MCP_DEFAULT_MAX_DEPTH / _MAX_DEPTH_CAP |
2 / 10 |
Crawl depth default / hard cap. |
SCRAPY_MCP_JOB_DIR |
<tmp>/scrapy_mcp_jobs |
Where crawl jobs are stored. |
SCRAPY_MCP_JOB_TTL_DAYS |
7 |
Delete crawl jobs older than this (0 disables). |
SCRAPY_MCP_LOG_LEVEL |
ERROR |
Scrapy log level (to stderr). |
Development
uv venv
uv pip install -e ".[dev]"
uv run pytest # unit tests (no network)
uv build # build wheel + sdist into dist/
License
MIT © Eitan Hadar
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。