Skip to main content

Firecrawl MCP Adapter

The cortex-firecrawl-mcp service is a stateless Fastify 5 adapter that bridges AgentGateway to the Firecrawl web-intelligence API. It exposes the full Firecrawl capability surface as six MCP tools over a Streamable HTTP transport.


Integration Topology​

AgentGateway (port 8080)
└── mcp-firecrawl (port 8080, /mcp)
└── Firecrawl API (cloud: https://api.firecrawl.dev | self-hosted)

Agents never call this service directly. All requests are federated through AgentGateway, which applies ExtMCP guardrail policies before dispatching.


Configuration​

VariableRequiredDefaultDescription
FIRECRAWL_API_KEYYes—API key for authenticating with the Firecrawl service.
FIRECRAWL_API_URLNohttps://api.firecrawl.devBase URL for the Firecrawl API. Override to point at a self-hosted instance.
PORTNo8080HTTP port the Fastify server listens on.
NODE_ENVNodevelopmentRuntime environment flag.

Local Host Routing​

When the service detects a localhost or 127.0.0.1 hostname in a tool argument URL, it automatically rewrites it to host.docker.internal so that containerized tool calls can reach processes on the developer's host machine.

Automatic port-to-application mapping used during rewriting:

PortApplication
3002Docusaurus docs site
5173hub-web Vite dev server
3000hub-api Fastify service

Transport​

  • Path: /mcp
  • Protocol: Streamable HTTP (MCP specification)
  • Session model: Stateless — sessionIdGenerator is set to undefined. Each POST to /mcp instantiates a fresh MCP Server object and tears it down after the response completes. No server-side session state is retained between requests.

Health Check​

GET /health

Response:

{ "status": "healthy", "service": "cortex-firecrawl-mcp" }

Tools​

scrape​

Fetches clean Markdown, HTML, or structured JSON from a single URL.

ParameterTypeRequiredDefaultDescription
urlstringYes—Target URL to scrape.
formatsarray[string]No["markdown"]Output formats: markdown, html, rawHtml, links, screenshot, json.
onlyMainContentbooleanNotrueStrip navigation, headers, footers, and boilerplate.
includeTagsarray[string]No—HTML tags whose content is always included.
excludeTagsarray[string]No—HTML tags whose content is always excluded.
waitFornumberNo—Milliseconds to wait for dynamic content before extracting.
mobilebooleanNo—Emulate a mobile browser viewport.
skipTlsVerificationbooleanNo—Bypass TLS certificate validation.

crawl​

Recursively crawls all discoverable subpages from a base URL and returns their content.

ParameterTypeRequiredDefaultDescription
urlstringYes—Root URL to begin crawling.
limitnumberNo10Maximum number of pages to crawl.
maxDiscoveryDepthnumberNo—Maximum link depth from the root URL.
allowExternalLinksbooleanNo—Follow links to external domains.
allowSubdomainsbooleanNo—Follow links to subdomains of the root domain.
sitemapstringNo—Sitemap handling: include, skip, or only.
includePathsarray[string]No—URL path glob patterns to include.
excludePathsarray[string]No—URL path glob patterns to exclude.

Runs a web search and returns full Markdown-rendered results for each matching page.

ParameterTypeRequiredDefaultDescription
querystringYes—Search query string.
limitnumberNo5Maximum number of results to return.
locationstringNo—Country/region code for localized results (e.g., US, BR).
includeDomainsarray[string]No—Restrict results to these domains.
excludeDomainsarray[string]No—Exclude results from these domains.
scrapeResultsbooleanNotrueFetch and render full page content for each result.

map​

Discovers all indexed URLs and sitemap routes for a given domain.

ParameterTypeRequiredDefaultDescription
urlstringYes—Base URL of the site to map.
searchstringNo—Filter discovered URLs by this keyword.
limitnumberNo50Maximum number of URLs to return.
sitemapstringNo—Sitemap handling: include, skip, or only.
includeSubdomainsbooleanNo—Include URLs from subdomains.

extract​

Extracts structured JSON data matching a provided schema from one or more URLs.

ParameterTypeRequiredDefaultDescription
urlsarray[string]Yes—List of URLs to extract data from.
promptstringNo—Natural language description of the target data.
schemaobjectNo—JSON Schema object defining the expected output shape.
systemPromptstringNo—Override the extraction system prompt.
allowExternalLinksbooleanNo—Allow extraction from external links found on the page.

batch_scrape​

Scrapes multiple URLs concurrently and returns results in the same order as input.

ParameterTypeRequiredDefaultDescription
urlsarray[string]Yes—List of URLs to scrape.
formatsarray[string]No["markdown"]Output formats (same options as scrape).
onlyMainContentbooleanNotrueStrip boilerplate from all scraped pages.

Architecture Notes​

Stateless Per-Request Server Instantiation​

Each POST request to /mcp creates a dedicated @modelcontextprotocol/sdk Server instance. The sessionIdGenerator option is explicitly set to undefined, which disables MCP session management. This design:

  • Eliminates server-side memory growth from session accumulation.
  • Ensures horizontal scalability with no affinity requirements.
  • Means any session state required by multi-step workflows must be maintained by the caller (AgentGateway or the agent itself).

Self-Hosted Firecrawl​

Set FIRECRAWL_API_URL to the internal address of a self-hosted Firecrawl instance to route all tool calls away from the cloud API. The FIRECRAWL_API_KEY is still required even for self-hosted deployments unless the self-hosted instance disables authentication.