Skip to main content
Glama
mcma123

Firecrawl MCP Server

by mcma123

firecrawl_batch_scrape

Scrape multiple URLs simultaneously to extract content in various formats like markdown, HTML, or screenshots, returning a job ID for status tracking.

Instructions

Scrape multiple URLs in batch mode. Returns a job ID that can be used to check status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlsYesList of URLs to scrape
optionsNo

Implementation Reference

  • Defines the tool metadata, description, and input schema for validating batch scrape requests.
    const BATCH_SCRAPE_TOOL: Tool = {
      name: 'firecrawl_batch_scrape',
      description:
        'Scrape multiple URLs in batch mode. Returns a job ID that can be used to check status.',
      inputSchema: {
        type: 'object',
        properties: {
          urls: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of URLs to scrape',
          },
          options: {
            type: 'object',
            properties: {
              formats: {
                type: 'array',
                items: {
                  type: 'string',
                  enum: [
                    'markdown',
                    'html',
                    'rawHtml',
                    'screenshot',
                    'links',
                    'screenshot@fullPage',
                    'extract',
                  ],
                },
              },
              onlyMainContent: {
                type: 'boolean',
              },
              includeTags: {
                type: 'array',
                items: { type: 'string' },
              },
              excludeTags: {
                type: 'array',
                items: { type: 'string' },
              },
              waitFor: {
                type: 'number',
              },
            },
          },
        },
        required: ['urls'],
      },
    };
  • src/index.ts:862-874 (registration)
    Registers the firecrawl_batch_scrape tool (as BATCH_SCRAPE_TOOL) in the MCP server's listTools handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        SCRAPE_TOOL,
        MAP_TOOL,
        CRAWL_TOOL,
        BATCH_SCRAPE_TOOL,
        CHECK_BATCH_STATUS_TOOL,
        CHECK_CRAWL_STATUS_TOOL,
        SEARCH_TOOL,
        EXTRACT_TOOL,
        DEEP_RESEARCH_TOOL,
      ],
    }));
  • Primary tool handler in the CallToolRequestSchema switch statement. Validates input using isBatchScrapeOptions, creates a queued batch operation ID, adds to PQueue for asynchronous processing via processBatchOperation, and returns the job ID immediately.
    case 'firecrawl_batch_scrape': {
      if (!isBatchScrapeOptions(args)) {
        throw new Error('Invalid arguments for firecrawl_batch_scrape');
      }
    
      try {
        const operationId = `batch_${++operationCounter}`;
        const operation: QueuedBatchOperation = {
          id: operationId,
          urls: args.urls,
          options: args.options,
          status: 'pending',
          progress: {
            completed: 0,
            total: args.urls.length,
          },
        };
    
        batchOperations.set(operationId, operation);
    
        // Queue the operation
        batchQueue.add(() => processBatchOperation(operation));
    
        server.sendLoggingMessage({
          level: 'info',
          data: `Queued batch operation ${operationId} with ${args.urls.length} URLs`,
        });
    
        return {
          content: [
            {
              type: 'text',
              text: `Batch operation queued with ID: ${operationId}. Use firecrawl_check_batch_status to check progress.`,
            },
          ],
          isError: false,
        };
      } catch (error) {
        const errorMessage =
          error instanceof Error
            ? error.message
            : `Batch operation failed: ${JSON.stringify(error)}`;
        return {
          content: [{ type: 'text', text: errorMessage }],
          isError: true,
        };
      }
    }
  • Asynchronous processor for batch operations, invoked by the PQueue. Calls Firecrawl client's asyncBatchScrapeUrls with retry logic, handles credit tracking, updates operation status/result/error in the shared batchOperations map.
    async function processBatchOperation(
      operation: QueuedBatchOperation
    ): Promise<void> {
      try {
        operation.status = 'processing';
        let totalCreditsUsed = 0;
    
        // Use library's built-in batch processing
        const response = await withRetry(
          async () =>
            client.asyncBatchScrapeUrls(operation.urls, operation.options),
          `batch ${operation.id} processing`
        );
    
        if (!response.success) {
          throw new Error(response.error || 'Batch operation failed');
        }
    
        // Track credits if using cloud API
        if (!FIRECRAWL_API_URL && hasCredits(response)) {
          totalCreditsUsed += response.creditsUsed;
          await updateCreditUsage(response.creditsUsed);
        }
    
        operation.status = 'completed';
        operation.result = response;
    
        // Log final credit usage for the batch
        if (!FIRECRAWL_API_URL) {
          server.sendLoggingMessage({
            level: 'info',
            data: `Batch ${operation.id} completed. Total credits used: ${totalCreditsUsed}`,
          });
        }
      } catch (error) {
        operation.status = 'failed';
        operation.error = error instanceof Error ? error.message : String(error);
    
        server.sendLoggingMessage({
          level: 'error',
          data: `Batch ${operation.id} failed: ${operation.error}`,
        });
      }
    }
  • Type guard function used in the handler to validate that arguments contain a valid 'urls' array of strings.
    function isBatchScrapeOptions(args: unknown): args is BatchScrapeOptions {
      return (
        typeof args === 'object' &&
        args !== null &&
        'urls' in args &&
        Array.isArray((args as { urls: unknown }).urls) &&
        (args as { urls: unknown[] }).urls.every((url) => typeof url === 'string')
      );
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool returns a job ID for status checking, which is useful context about the asynchronous nature. However, it lacks details on permissions, rate limits, error handling, or what the scraping entails (e.g., whether it's destructive or read-only). More behavioral traits are needed for a mutation tool.

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

Conciseness4/5

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

The description is concise with two sentences that front-load the main action and outcome. There's no wasted text, but it could be slightly more informative without losing efficiency. It effectively communicates the core functionality in a structured manner.

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

Completeness2/5

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

Given the complexity (batch scraping with multiple parameters, no output schema, and no annotations), the description is incomplete. It doesn't cover parameter details, behavioral aspects like rate limits or errors, or how to interpret results beyond the job ID. For a tool with undocumented parameters and no structured output, more context is needed.

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

Parameters3/5

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

Schema description coverage is 50% (only 'urls' has a description), so the description must compensate. It implies 'urls' parameter usage but doesn't explain 'options' or its nested properties. The description adds minimal value beyond the schema, as it doesn't clarify parameter meanings or usage, leaving gaps for undocumented parameters.

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

Purpose4/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: 'Scrape multiple URLs in batch mode.' It specifies the verb (scrape) and resource (URLs) with the batch mode distinction. However, it doesn't explicitly differentiate from sibling tools like 'firecrawl_scrape' or 'firecrawl_crawl,' which likely handle single URLs or different scraping modes.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions batch mode but doesn't specify scenarios where batch is preferred over single URL scraping or other siblings like 'firecrawl_search' or 'firecrawl_deep_research.' No exclusions or prerequisites are stated.

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/mcma123/firecrawl-mcp-server'

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