search
Search the web and extract content from multiple sources simultaneously to gather structured data for research and analysis.
Instructions
Search the web and scrape the results. Returns scraped content from multiple search results. Use this for finding and extracting data from multiple sources at once.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (e.g., "best AI tools 2025") | |
| limit | No | Maximum number of results to return. Default: 5 | |
| formats | No | Output formats for each result. Default: ["markdown"] |
Implementation Reference
- src/server.ts:183-210 (registration)Registers the 'search' tool in the MCP TOOLS array with name, description, and input schema definition.{ name: 'search', description: 'Search the web and scrape the results. Returns scraped content from multiple search results. Use this for finding and extracting data from multiple sources at once.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (e.g., "best AI tools 2025")', }, limit: { type: 'number', description: 'Maximum number of results to return. Default: 5', }, formats: { type: 'array', items: { type: 'string', enum: ['markdown', 'html', 'rawHtml', 'links'], }, description: 'Output formats for each result. Default: ["markdown"]', }, }, required: ['query'], }, }, ];
- src/server.ts:388-428 (handler)MCP CallTool handler for 'search': extracts parameters, invokes FirecrawlClient.search, handles success/error and returns formatted JSON response.case 'search': { const { query, limit, formats } = args as { query: string; limit?: number; formats?: ('markdown' | 'html' | 'rawHtml' | 'links')[]; }; const result = await firecrawl.search({ query, limit, formats, }); if (!result.success) { return { content: [ { type: 'text', text: `Error: ${result.error}`, }, ], isError: true, }; } return { content: [ { type: 'text', text: JSON.stringify( { success: true, data: result.data, }, null, 2 ), }, ], }; }
- FirecrawlClient.search method: performs HTTP POST to /v1/search API endpoint, handles response and errors.async search(request: FirecrawlSearchRequest): Promise<FirecrawlSearchResponse> { try { const response = await fetch(`${this.apiBase}/v1/search`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${this.apiKey}`, }, body: JSON.stringify(request), }); const data = await response.json() as any; if (!response.ok) { return { success: false, error: data.error || `HTTP ${response.status}: ${response.statusText}`, }; } return { success: true, data: data.data, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Unknown error', }; } }
- src/types/firecrawl.ts:54-71 (schema)TypeScript interfaces defining input (FirecrawlSearchRequest) and output (FirecrawlSearchResponse) types for the search functionality.export interface FirecrawlSearchRequest { query: string; limit?: number; formats?: ('markdown' | 'html' | 'rawHtml' | 'links')[]; } export interface FirecrawlSearchResponse { success: boolean; data?: Array<{ url: string; markdown?: string; html?: string; rawHtml?: string; links?: string[]; metadata?: Record<string, any>; }>; error?: string; }