Crawl4AI MCP

API Reference

Complete reference for the `crawl` tool parameters.

API Reference (MCP Tool)

The CRAWL4AI_MCP server exposes a single, powerful tool to your AI assistant: crawl.

Here is the complete list of parameters that your AI can use when calling this tool.

Core Parameters

ParameterTypeDefaultDescription
urlstring(Required)The fully qualified URL to crawl.
max_depthinteger2Maximum crawling depth. Defines how many links deep the crawler should go.
include_externalbooleanfalseWhether to include external links in the crawl.
return_contentbooleantrueIf true, returns the extracted content directly in the MCP response text.

Advanced & Stealth

ParameterTypeDefaultDescription
magicbooleanfalseEnable magic mode to bypass anti-bots (e.g., Cloudflare) and simulate a real browser.
wait_for_selectorstringnullCSS selector to wait for before extracting content. Crucial for SPA and React/Vue apps.
delay_before_return_htmlnumbernullDelay in seconds to wait before extracting HTML (useful for heavy JS pages with slow animations).

Targeted Extraction & JS

ParameterTypeDefaultDescription
css_selectorstringnullSpecific CSS selector to extract only targeted elements from the page (e.g., main .article).
js_codestringnullCustom JavaScript code to execute on the page before extraction. (Requires server env var CRAWL4AI_MCP_ALLOW_JS_ENV=true)

State Management

ParameterTypeDefaultDescription
session_idstringnullPersistent session identifier to keep cookies and browser state across multiple requests (great for authenticated sites).

Debugging

ParameterTypeDefaultDescription
verbosebooleantrueEnable verbose logging output on the server side.
output_filestringnullCustom path to the output Markdown file. If not provided, it generates a unique name in the crawl_results folder.

Example AI Request (Internal representation)

When Claude or Cline uses this tool, it sends a JSON payload similar to this:

{
  "url": "https://example.com/dashboard",
  "magic": true,
  "wait_for_selector": ".dashboard-loaded",
  "session_id": "auth-session-xyz123"
}

On this page