Firecrawl
FirecrawlToolkit gives an agent two related tools powered by Firecrawl: web search and single-page scrape. Search can also return each result page's markdown in the same call, so an agent finds and reads sources in one step.
Note
Requires the firecrawl-py package and an API key: pip install "firecrawl-py>=4.46,<5". You can create a key in the Firecrawl dashboard.
If api_key is omitted, the Firecrawl SDK reads the FIRECRAWL_API_KEY environment variable when a tool runs.
Tools#
| Tool | Description |
|---|---|
firecrawl_search | Search the web or news and return ranked results with URL, title, and description, optionally with each page's markdown |
firecrawl_scrape | Read one http or https URL and return its markdown, plus HTML and links when requested |
Shared defaults#
Constructor defaults are applied to the toolkit's default tools:
The constructor also accepts api_url (for a self-hosted Firecrawl), http_timeout (seconds, for each HTTP request) and max_retries.
Warning
firecrawl_scrape only checks that the URL is http or https; the model chooses the URL. Firecrawl's cloud API cannot reach your private network, but a self-hosted Firecrawl set through api_url fetches from wherever it runs, so the model could ask it for internal addresses. Restrict that deployment's network access if this matters.
Limiting result size#
A scraped page can be very long, and firecrawl_search with scrape_results=True returns one page per result. Set max_characters to cut each page's markdown (and HTML for firecrawl_scrape) to that many characters. For firecrawl_scrape, links are kept only while their combined length fits. Results that were cut have truncated=True, so the model knows the text is incomplete:
max_characters is off by default.
Picking a subset of tools#
Each tool is exposed as a factory method on the toolkit (toolkit.search(), toolkit.scrape()). Call the method to get a ready-to-use tool, then pass only the ones you need to the agent:
Search configuration#
firecrawl_search accepts a required query at execution time. Configure the other options on toolkit.search():
With scrape_results=True, every result also carries the main content of its page as markdown, so the agent does not need a separate scrape call for each result. Each result is then a full page, so keep limit low. scrape_only_main_content and scrape_max_age tune how those pages are read. Leave scrape_results off when titles and descriptions are enough.
Scrape configuration#
firecrawl_scrape accepts a single URL at execution time. Configure the output on toolkit.scrape():
toolkit.scrape() also accepts include_tags, headers, mobile, proxy, block_ads and store_in_cache.
The search and scrape options (everything except api_key, api_url, http_timeout and max_retries) accept a Variable for deferred context resolution.
Errors#
firecrawl_scrape returns {"error": ...} for a URL that is not http or https, so the model can try again with a valid one. Everything else is raised:
- invalid options, such as setting both
include_domainsandexclude_domains(raised bytoolkit.search()itself, or at call time when the values come fromVariables); - a missing or invalid API key;
- Firecrawl API errors, raised as
firecrawlSDK exceptions.
Errors raised while a tool runs reach the model as tool errors.
Result#
firecrawl_search returns a FirecrawlSearchResponse:
| Field | Description |
|---|---|
query | The search query |
web | List of FirecrawlSearchResult (url, title, description, position, markdown, truncated) |
news | List of FirecrawlNewsResult (url, title, snippet, date, position, markdown, truncated) |
markdown is set only when scrape_results=True. In that mode description and snippet come from the page metadata, and news results have no date.
firecrawl_scrape returns a FirecrawlScrapeResult:
| Field | Description |
|---|---|
url | Final URL of the page |
title, description, language | Page metadata |
status_code | HTTP status code of the page |
markdown, html, links | Page content in the requested formats |
truncated | True when max_characters cut the markdown, the HTML or the links |
Tip
Use firecrawl_search with scrape_results=True when the agent needs to read several sources for one question. Use firecrawl_scrape when the agent already knows the URL it wants to read.