Crawl4ai Local
Summary: A local stdio MCP server that crawls web pages with Crawl4ai and returns Markdown, structured JSON, or full-page screenshots.
crawl_markdown(url, wait_seconds=0, wait_selector="")— Crawl a URL and get its content as Markdown.crawl_structured(url, selector, fields, wait_seconds=0, wait_selector="")— Extract repeated elements into JSON via CSS selectors, with per-field specs for text (td/td:text), child attributes (a@href), base-element attributes (@data-value), and nth-element selection (td:nth-of-type(1);:eq()unsupported).crawl_screenshot(url, output_path)— Capture a full-page screenshot to a file (parent dirs auto-created); Windows paths are converted to/mnt/<drive>/..., and system directories are blocked for safety.Dynamic page support — All crawl tools accept
wait_seconds(fixed delay) orwait_selector(wait for a CSS selector, takes precedence).Reliable browsing — A single Chromium instance is reused across calls, with automatic crash detection and retry (up to 2 recreations) and safe concurrent crawling.
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., "@Crawl4ai Local Extract book titles and prices from https://books.toscrape.com"
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.
Crawl4ai Local
Local MCP server for Crawl4ai on Linux.
🤖 Most of the code was generated with AI assistance.
See also:
Requirements
Linux
Python 3.14 (installing via uv is fine:
uv python install 3.14)
Related MCP server: agent-browser
Installation
uv sync
# Install Chromium for Playwright
uv run crawl4ai-setupIf the browser fails to launch because system libraries required by Chromium are missing, install them with the command below (requires sudo; apt-based distros such as Debian/Ubuntu only).
uv run playwright install-deps chromiumRunning
🚨 This server is a stdio server — no need to keep it running like a network server. When connected to an agent as MCP, the agent automatically spins up the server instance.
# Check for the "🚀 Crawl4ai MCP server started." message, then exit
uv run main✅ After confirming the welcome message, press Ctrl+C to exit, then add the MCP to your agent.
# Tip: debugging mode (MCP Inspector)
uv run mcp dev src/crawl4ai_local/server.pyAdding MCP to an Agent
Claude Code
claude mcp add --transport stdio --scope user crawl4ai -- uv run --directory <parent_location>/crawl4ai-local mainparent_location: An absolute path like/home/<user>/dev/repo(use~only where the shell expands it)e.g.
claude mcp add --transport stdio --scope user crawl4ai -- uv run --directory /home/me/dev/repo/crawl4ai-local main
# Check MCP installation
claude mcp list
claude mcp get crawl4aiHermes Agent
hermes mcp add crawl4ai --command "uv" --args "run" "--directory" "<parent_location>/crawl4ai-local" "main"parent_location: An absolute path like/home/<user>/dev/repo(use~only where the shell expands it)e.g.
/home/me/dev/repo/crawl4ai-local
# Check MCP installation
hermes mcp listTools
crawl_markdown(url, wait_seconds=0, wait_selector="")
Crawl a URL and return the content as Markdown.
crawl_structured(url, selector, fields, wait_seconds=0, wait_selector="")
Extract repeated elements as JSON using CSS selectors.
crawl_structured(
url="https://books.toscrape.com/",
selector="article.product_pod",
fields={"제목": "h3 a@title", "가격": ".price_color:text"},
)
# → [{"제목": "A Light in the Attic", "가격": "£51.77"}, ...]Field spec syntax:
Spec | Meaning |
| Text of the matched element |
| Attribute of a child element ( |
| Attribute of the base element itself |
| Nth element — use standard CSS ( |
Both tools share the waiting options (see below).
crawl_screenshot(url, output_path)
Capture a full-page screenshot and save it to a file. Parent directories are created automatically.
💡 If output_path is a Windows path (C:\Users\me\shot.png, D:/shots/a.png), it is converted to the mounted drive path (/mnt/c/Users/me/shot.png) before saving.
🛡️ output_path is checked against a blocklist of known system directories before the crawl even runs.
Linux:
/bin,/boot,/dev,/etc,/lib,/lib32,/lib64,/libx32,/proc,/run,/sbin,/snap,/sys,/usr,/varWindows (under
/mnt/<drive>/, case-insensitive):Windows,Program Files,Program Files (x86),ProgramData,System Volume Information,$Recycle.Bin,Users/All Users,Users/Default
A path that resolves into one of these (including via .. traversal or symlinks) is rejected with an error message, so an agent can't accidentally overwrite system files. This is a blocklist, not a full sandbox — it guards against mistakes, not a determined attacker. If Windows drives are mounted somewhere other than /mnt/, update _DRIVE_MOUNT_ROOT in server.py accordingly.
Browser Reuse & Crash Recovery
Instead of launching Chromium on every call (which is expensive), the server keeps one browser instance for the process lifetime. If the shared browser crashes mid-session, the server detects it and recovers automatically:
Crash detection matches Playwright collapse signatures only —
Target page, context or browser has been closed,browser has crashed,browsertype.launchfailures, etc. Network errors, anti-bot blocks, and timeouts are page-side causes and are never retried with a fresh browser.On crash: dispose the dead instance → launch a new one → retry, up to
_MAX_RECREATE_ATTEMPTS = 2attempts.Both failure paths are checked equally on every attempt: exceptions raised by
arun()andresult.success=False+ crash message inerror_message.On the last attempt, a crash is still reported as a failure, but the crawler is not reset again — that cleanup already happened on the prior attempt, and resetting a second time could tear down an instance a concurrent request just recreated.
Preventive recycling (e.g., refresh every N pages) is intentionally left to Crawl4ai's built-in browser recycling; the server only reacts to actual collapses.
Concurrency note: multiple simultaneous arun() calls on the shared crawler are safe — Crawl4ai serializes page creation internally (_page_lock, GH-1198 fix) and manages context lifecycle with refcounting + LRU. Verified with concurrent multi-site smoke tests.
Waiting Options (Dynamic Pages)
For dynamic pages that render content late using JS, use the waiting options of crawl_markdown / crawl_structured.
# Method 1: Wait for a fixed duration (seconds)
crawl_markdown(url="https://example.com", wait_seconds=5)
# Method 2: Wait until a CSS selector appears (takes precedence over wait_seconds when specified)
crawl_markdown(url="https://example.com", wait_selector="div.result-list")Verification Results (2026-08-25)
Comparison of 3 cases on a local test page that updates content via JS after 3 seconds:
Case | success | Captures Dynamic Content |
No waiting option | True | ❌ Returns only "Loading..." |
| True | ✅ Accurately captures final content |
| True | ❌ Passes immediately if the element already exists in the initial HTML |
Findings / Cautions
wait_selectoris only valid for "newly created elements." If the text of an element already present in the initial HTML (e.g.,<article id="dynamic">Loading...</article>) changes later, the selector matches immediately and passes without waiting. For pages that update text dynamically, usewait_seconds.Extreme pages trigger anti-bot heuristics. Pages with minimal content and many script tags are flagged by Crawl4ai's anti-bot detector as
Blocked by anti-bot protection: Structural: no_content_elements, script_heavy_shell, resulting insuccess=False. Although rare in production pages, testing should be done on pages containing basic static content (navigation bars, paragraphs, etc.).
Keeping Up with Upstream
This server depends on the official crawl4ai library, so upstream releases may require source changes. The project ships a Claude Code slash command that handles this: .claude/commands/sync-upstream.md.
Run it in Claude Code from this repository's root:
# Sync to the latest stable release
/sync-upstream
# Sync to a specific version (pre-releases only when named explicitly)
/sync-upstream 0.9.5What it does:
Compares the installed
crawl4aiversion with the latest GitHub release, and stops if already up to date.Reads the release notes and
CHANGELOG.mdsince the current version, keeping only changes that affect the crawl4ai APIs used insrc/.Raises the
crawl4ai>=lower bound withuv add, and runsuv run crawl4ai-setupwhen the browser version changed.Updates
server.py(and both READMEs when behavior changes) without changing MCP tool names, arguments, or return formats. If that becomes unavoidable, it asks first.Runs Ruff, Flake8, mypy, pytest, and a live smoke test of all three tools, then reports the results.
It does not commit. Review the diff and commit yourself.
Available Tools
3 toolscrawl_markdownB
주어진 URL을 크롤링해서 마크다운으로 반환한다.
Args: url: 크롤링할 URL. wait_seconds: HTML을 받기 전 대기 시간(초). JS 동적 로딩 페이지에 사용. wait_selector: 이 CSS 셀렉터가 나타날 때까지 대기. 지정 시 wait_seconds보다 우선.
Inputs: url (required), wait_seconds, wait_selector. Returns: result
crawl_screenshotB
스크린샷을 찍어 파일로 저장한다.
Args: url: 크롤링할 URL. output_path: 저장할 파일 경로. Windows 경로("C:\Users\me\x.png")는 /mnt/c/Users/me/x.png 로 변환해 저장한다.
Inputs: url (required), output_path (required). Returns: result
crawl_structuredA
CSS 셀렉터로 반복 요소를 잡아 지정한 필드만 JSON으로 추출한다.
Args: url: 크롤링할 URL. selector: 반복 요소를 잡는 CSS 셀렉터 (예: "table tr.item", "div.product-card"). fields: 추출할 필드. 키=필드명, 값=추출 지정 문자열. - 텍스트: "td" 또는 "td:text" - 속성: "a@href" (요소@속성명), 요소 자체 속성은 "@data-value" - N번째 요소는 CSS 문법 "td:nth-of-type(1)" 사용 (":eq()" 미지원) 예: {"이름": "td:nth-of-type(1):text", "링크": "a@href"} wait_seconds: HTML을 받기 전 대기 시간(초). JS 동적 로딩 페이지에 사용. wait_selector: 이 CSS 셀렉터가 나타날 때까지 대기. 지정 시 wait_seconds보다 우선.
Inputs: url (required), fields (required), selector (required), wait_seconds, +1 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool converts a URL into a different output format: markdown, screenshot, or structured JSON. The purposes are mutually exclusive and clearly distinguishable by the suffix in the tool name. No overlap or ambiguity exists.
All tools share the consistent 'crawl_' prefix followed by the output type (markdown, screenshot, structured). This follows a predictable verb_noun pattern, making it easy to infer tool behavior from the name alone.
Three tools is well-scoped for a focused crawling server that offers three distinct output modes. Each tool earns its place without redundancy or unnecessary bloat.
The set covers the core crawling needs: full content (markdown), visual capture (screenshot), and targeted extraction (structured). A minor gap is the lack of a raw HTML option, but the three provided modes handle most practical use cases without dead ends.
Maintenance
Related MCP Connectors
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
A real browser for your agent: screenshots, page checks, Markdown and PDFs.
domscout browser API as MCP tools: screenshots, Markdown, structured data, page automation, crawls.
Scrape, crawl and search the web for AI agents via MCP.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables AI assistants to crawl websites, extract dynamic content, navigate links, and save structured Markdown files via the MCP protocol, with support for anti-bot bypass, CSS selectors, and custom JavaScript execution.1177 PyPI45MIT
- AlicenseNot gradedqualityDmaintenanceProvides a headless Chromium browser through MCP, enabling AI agents to browse JavaScript-rendered pages, search the web, capture screenshots, extract tables and data, and run stateful multi-step interactions like clicking, typing, and form submission.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables MCP clients to perform keyless web searches, extract fully rendered pages into clean Markdown, and automate a shared Chrome browser through page navigation, clicking, typing, reading, screenshots, and backtracking—all without API keys.MIT
- AlicenseNot gradedqualityCmaintenanceEnables agents to scrape, crawl, map, search, and extract web pages as clean markdown or structured JSON directly through MCP tools.AGPL 3.0