Skip to main content
Glama
ampcome-mcps

Firecrawl MCP Server

by ampcome-mcps

firecrawl_extract

Extract structured data from web pages using LLM capabilities. Define specific information to retrieve with custom prompts and JSON schemas.

Instructions

Extract structured information from web pages using LLM capabilities. Supports both cloud AI and self-hosted LLM extraction.

Best for: Extracting specific structured data like prices, names, details from web pages. Not recommended for: When you need the full content of a page (use scrape); when you're not looking for specific structured data. Arguments:

  • urls: Array of URLs to extract information from

  • prompt: Custom prompt for the LLM extraction

  • systemPrompt: System prompt to guide the LLM

  • schema: JSON schema for structured data extraction

  • allowExternalLinks: Allow extraction from external links

  • enableWebSearch: Enable web search for additional context

  • includeSubdomains: Include subdomains in extraction Prompt Example: "Extract the product name, price, and description from these product pages." Usage Example:

{
  "name": "firecrawl_extract",
  "arguments": {
    "urls": ["https://example.com/page1", "https://example.com/page2"],
    "prompt": "Extract product information including name, price, and description",
    "systemPrompt": "You are a helpful assistant that extracts product information",
    "schema": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "price": { "type": "number" },
        "description": { "type": "string" }
      },
      "required": ["name", "price"]
    },
    "allowExternalLinks": false,
    "enableWebSearch": false,
    "includeSubdomains": false
  }
}

Returns: Extracted structured data as defined by your schema.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlsYesList of URLs to extract information from
promptNoPrompt for the LLM extraction
systemPromptNoSystem prompt for LLM extraction
schemaNoJSON schema for structured data extraction
allowExternalLinksNoAllow extraction from external links
enableWebSearchNoEnable web search for additional context
includeSubdomainsNoInclude subdomains in extraction

Implementation Reference

  • The handler for the 'firecrawl_extract' tool. Validates arguments using isExtractOptions, calls the Firecrawl client's extract method with parameters like urls, prompt, schema, etc., handles response, logs performance, and returns formatted content or error.
    case 'firecrawl_extract': {
      if (!isExtractOptions(args)) {
        throw new Error('Invalid arguments for firecrawl_extract');
      }
    
      try {
        const extractStartTime = Date.now();
    
        safeLog(
          'info',
          `Starting extraction for URLs: ${args.urls.join(', ')}`
        );
    
        // Log if using self-hosted instance
        if (FIRECRAWL_API_URL) {
          safeLog('info', 'Using self-hosted instance for extraction');
        }
    
        const extractResponse = await withRetry(
          async () =>
            client.extract(args.urls, {
              prompt: args.prompt,
              systemPrompt: args.systemPrompt,
              schema: args.schema,
              allowExternalLinks: args.allowExternalLinks,
              enableWebSearch: args.enableWebSearch,
              includeSubdomains: args.includeSubdomains,
              origin: 'mcp-server',
            } as ExtractParams),
          'extract operation'
        );
    
        // Type guard for successful response
        if (!('success' in extractResponse) || !extractResponse.success) {
          throw new Error(extractResponse.error || 'Extraction failed');
        }
    
        const response = extractResponse as ExtractResponse;
    
        // Log performance metrics
        safeLog(
          'info',
          `Extraction completed in ${Date.now() - extractStartTime}ms`
        );
    
        // Add warning to response if present
        const result = {
          content: [
            {
              type: 'text',
              text: trimResponseText(JSON.stringify(response.data, null, 2)),
            },
          ],
          isError: false,
        };
    
        if (response.warning) {
          safeLog('warning', response.warning);
        }
    
        return result;
      } catch (error) {
        const errorMessage =
          error instanceof Error ? error.message : String(error);
    
        // Special handling for self-hosted instance errors
        if (
          FIRECRAWL_API_URL &&
          errorMessage.toLowerCase().includes('not supported')
        ) {
          safeLog(
            'error',
            'Extraction is not supported by this self-hosted instance'
          );
          return {
            content: [
              {
                type: 'text',
                text: trimResponseText(
                  'Extraction is not supported by this self-hosted instance. Please ensure LLM support is configured.'
                ),
              },
            ],
            isError: true,
          };
        }
    
        return {
          content: [{ type: 'text', text: trimResponseText(errorMessage) }],
          isError: true,
        };
      }
    }
  • Tool definition for 'firecrawl_extract' including name, detailed description, and inputSchema defining parameters like urls (required array of strings), prompt, systemPrompt, schema (object), booleans for links, search, subdomains.
    const EXTRACT_TOOL: Tool = {
      name: 'firecrawl_extract',
      description: `
    Extract structured information from web pages using LLM capabilities. Supports both cloud AI and self-hosted LLM extraction.
    
    **Best for:** Extracting specific structured data like prices, names, details from web pages.
    **Not recommended for:** When you need the full content of a page (use scrape); when you're not looking for specific structured data.
    **Arguments:**
    - urls: Array of URLs to extract information from
    - prompt: Custom prompt for the LLM extraction
    - systemPrompt: System prompt to guide the LLM
    - schema: JSON schema for structured data extraction
    - allowExternalLinks: Allow extraction from external links
    - enableWebSearch: Enable web search for additional context
    - includeSubdomains: Include subdomains in extraction
    **Prompt Example:** "Extract the product name, price, and description from these product pages."
    **Usage Example:**
    \`\`\`json
    {
      "name": "firecrawl_extract",
      "arguments": {
        "urls": ["https://example.com/page1", "https://example.com/page2"],
        "prompt": "Extract product information including name, price, and description",
        "systemPrompt": "You are a helpful assistant that extracts product information",
        "schema": {
          "type": "object",
          "properties": {
            "name": { "type": "string" },
            "price": { "type": "number" },
            "description": { "type": "string" }
          },
          "required": ["name", "price"]
        },
        "allowExternalLinks": false,
        "enableWebSearch": false,
        "includeSubdomains": false
      }
    }
    \`\`\`
    **Returns:** Extracted structured data as defined by your schema.
    `,
      inputSchema: {
        type: 'object',
        properties: {
          urls: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of URLs to extract information from',
          },
          prompt: {
            type: 'string',
            description: 'Prompt for the LLM extraction',
          },
          systemPrompt: {
            type: 'string',
            description: 'System prompt for LLM extraction',
          },
          schema: {
            type: 'object',
            description: 'JSON schema for structured data extraction',
          },
          allowExternalLinks: {
            type: 'boolean',
            description: 'Allow extraction from external links',
          },
          enableWebSearch: {
            type: 'boolean',
            description: 'Enable web search for additional context',
          },
          includeSubdomains: {
            type: 'boolean',
            description: 'Include subdomains in extraction',
          },
        },
        required: ['urls'],
      },
    };
  • src/index.ts:962-973 (registration)
    Registers the EXTRACT_TOOL (firecrawl_extract) in the list of tools provided by the ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        SCRAPE_TOOL,
        MAP_TOOL,
        CRAWL_TOOL,
        CHECK_CRAWL_STATUS_TOOL,
        SEARCH_TOOL,
        EXTRACT_TOOL,
        DEEP_RESEARCH_TOOL,
        GENERATE_LLMSTXT_TOOL,
      ],
    }));
  • Type guard function to validate that arguments for firecrawl_extract contain a valid 'urls' array of strings.
    function isExtractOptions(args: unknown): args is ExtractArgs {
      if (typeof args !== 'object' || args === null) return false;
      const { urls } = args as { urls?: unknown };
      return (
        Array.isArray(urls) &&
        urls.every((url): url is string => typeof url === 'string')
      );
    }
  • TypeScript interfaces defining parameters (ExtractParams), arguments (ExtractArgs), and response (ExtractResponse) for the firecrawl_extract tool.
    // Add after other interfaces
    interface ExtractParams<T = any> {
      prompt?: string;
      systemPrompt?: string;
      schema?: T | object;
      allowExternalLinks?: boolean;
      enableWebSearch?: boolean;
      includeSubdomains?: boolean;
      origin?: string;
    }
    
    interface ExtractArgs {
      urls: string[];
      prompt?: string;
      systemPrompt?: string;
      schema?: object;
      allowExternalLinks?: boolean;
      enableWebSearch?: boolean;
      includeSubdomains?: boolean;
      origin?: string;
    }
    
    interface ExtractResponse<T = any> {
      success: boolean;
      data: T;
      error?: string;
      warning?: string;
      creditsUsed?: number;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It describes the core behavior (LLM-based extraction) and mentions support for both cloud and self-hosted LLMs, but doesn't disclose important behavioral traits like rate limits, authentication requirements, error handling, or what happens when extraction fails. The description adds some context but leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (Best for, Not recommended for, Arguments, Prompt Example, Usage Example, Returns). Every sentence serves a purpose - no redundant information. The usage example is comprehensive but necessary for understanding this complex tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 7 parameters, no annotations, and no output schema, the description does well by providing clear purpose, usage guidelines, parameter examples, and return value information. However, it lacks details about error cases, rate limits, and authentication requirements that would be helpful for a tool of this complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds value by providing a detailed usage example with all parameters shown in context, plus a prompt example that illustrates how the 'prompt' parameter should be structured. This gives practical guidance beyond the schema's basic descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Extract structured information from web pages using LLM capabilities' with specific examples like 'prices, names, details'. It explicitly distinguishes from sibling tools by stating 'Not recommended for: When you need the full content of a page (use scrape)', directly naming the alternative.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance with 'Best for:' and 'Not recommended for:' sections, clearly stating when to use this tool (extracting specific structured data) versus when to use the 'scrape' sibling tool (when needing full page content). This gives clear context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ampcome-mcps/firecrawl-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server