Skip to main content

Mastra

Wire Firecrawl into Mastra tools so your agents and workflows can search and scrape live web data.
1 min read

Prerequisites#

Install the SDK#

Set your API key#

Add your API key to .env:

Build the Firecrawl tools#

Create src/mastra/tools/firecrawl.ts to expose search and scrape as Mastra tools:

Create the agent#

Create src/mastra/agents/web-agent.ts and give it the Firecrawl tools:

Register the agent#

Register the agent on your Mastra instance in src/mastra/index.ts:

Test in Studio#

Run the dev server and open Mastra Studio:

Open the Web Agent and try prompts like:

  • "Find the latest Firecrawl changelog and summarize the last release."
  • "Search for Firecrawl pricing and extract the plan tiers."

Self-hosted Firecrawl#

If you run Firecrawl locally, set FIRECRAWL_API_URL and pass apiUrl to the client:

Next steps#