firecrawl-tool
simple-ai/firecrawl-toolFreeUtility
A tool for searching and scraping the web using Firecrawl.
Live preview
live · rendered by the registry
Rendered by simple-ai on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://simple-ai.dev/r/firecrawl-tool.jsonSource
1import { FirecrawlAppV1 as FirecrawlApp } from "@mendable/firecrawl-js";2import { type InferUITool, tool } from "ai";3import { z } from "zod";45const firecrawlParamsSchema = z.object({6 mode: z7 .enum(["search", "scrape"])8 .describe(9 "The operation to perform: 'search' for general queries, 'scrape' for a specific URL",10 ),11 query: z12 .string()13 .describe("The search query or the specific URL to scrape"),14});1516export type FirecrawlParams = z.infer<typeof firecrawlParamsSchema>;1718const firecrawlResultSchema = z.union([19 z.object({20 success: z.literal(true),21 markdown: z.string(),22 }),23 z.object({24 success: z.literal(true),25 documents: z.array(z.any()),26 }),27 z.object({28 success: z.literal(false),29 error: z.string(),30 }),31]);3233export type FirecrawlResult = z.infer<typeof firecrawlResultSchema>;3435export const firecrawlTool = tool({36 name: "firecrawl",37 description:38 "Search the web or scrape a specific URL using Firecrawl. Use this to find live information.",39 inputSchema: firecrawlParamsSchema,40 outputSchema: firecrawlResultSchema,41 execute: async (params) => {42 const apiKey = process.env.FIRECRAWL_API_KEY;4344 if (!apiKey) {45 return { success: false, error: "FIRECRAWL_API_KEY is not set" };46 }4748 try {49 const app = new FirecrawlApp({ apiKey });5051 if (params.mode === "scrape") {52 const scrapeResult = await app.scrapeUrl(params.query, {53 formats: ["markdown"],54 });5556 if (!scrapeResult.success) {57 return {58 success: false,59 error: `Failed to scrape: ${scrapeResult.error || "Unknown error"}`,60 };61 }6263 return { success: true, markdown: scrapeResult.markdown };64 } else {65 const searchResult = await app.search(params.query, {66 limit: 3,67 scrapeOptions: {68 formats: ["markdown"],69 },70 });7172 if (!searchResult.success) {73 return {74 success: false,75 error: `Failed to search: ${searchResult.error || "Unknown error"}`,76 };77 }7879 return { success: true, documents: searchResult.data };80 }81 } catch (error) {82 return {83 success: false,84 error:85 error instanceof Error86 ? error.message87 : "Unknown error occurred",88 };89 }90 },91});9293export type FirecrawlTool = InferUITool<typeof firecrawlTool>;
What it pulls in
npm packages
Files it writes
More from simple-ai
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| agent-respondagent-respond | simple-ai | Utilities | Free | 1 dep | |
| agents-tools-registryagents-tools-registry | simple-ai | Utilities | Free | 1 dep · 2 files | |
| ai-utilsai-utils | simple-ai | Utilities | Free | 1 dep | |
| Exa Agentexa-agent | simple-ai | Utilities | Free | 1 dep | |
| exa-toolexa-tool | simple-ai | Utilities | Free | 3 deps | |
| Firecrawl Agentfirecrawl-agent | simple-ai | Utilities | Free | 1 dep | |
| get-weatherget-weather | simple-ai | Utilities | Free | 2 deps | |
| id-to-readable-textid-to-readable-text | simple-ai | Utilities | Free | no deps |
