Prerequisites
- Node.js 22.13+
- A Firecrawl API key — get one free
- An API key from a supported Mastra model provider
- An existing Mastra project — follow the Mastra quickstart to set one up
Install the SDK
Set your API key
Add your API key to.env:
Build the Firecrawl tools
Createsrc/mastra/tools/firecrawl.ts to expose search and scrape as Mastra tools:
Create the agent
Createsrc/mastra/agents/web-agent.ts and give it the Firecrawl tools:
Register the agent
Register the agent on your Mastra instance insrc/mastra/index.ts:
Test in Studio
Run the dev server and open Mastra Studio athttp://localhost:4111:
- “Find the latest Firecrawl changelog and summarize the last release.”
- “Search for Firecrawl pricing and extract the plan tiers.”
Give the agent a hosted browser
For pages that need clicks, typing, or scrolling, Mastra’s@mastra/browser-firecrawl package runs the agent’s browser tools in a Firecrawl browser session, so you don’t need a local Chromium install.
Pin
agent-browser to 0.19.0. Later releases ship only the CLI, so @mastra/browser-firecrawl fails to import with Cannot find package .../agent-browser/index.js.src/mastra/agents/browser-agent.ts, then register browserAgent on your Mastra instance the same way as webAgent:
Self-hosted Firecrawl
If you run Firecrawl yourself, addFIRECRAWL_API_URL to .env. The SDK reads it from the environment, so the tools above need no changes:
Next steps
Scrape docs
All scrape options including formats, actions, and proxies
Search docs
Search the web and get full page content
Agent docs
Let an agent drive Firecrawl end to end
Node SDK reference
Full SDK reference with crawl, map, batch scrape, and more

