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_KEYYesAPI 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
urlstringYesTarget URL to scrape.
formatsarray[string]No["markdown"]Output formats: markdown, html, rawHtml, links, screenshot, json.
onlyMainContentbooleanNotrueStrip navigation, headers, footers, and boilerplate.
includeTagsarray[string]NoHTML tags whose content is always included.
excludeTagsarray[string]NoHTML tags whose content is always excluded.
waitFornumberNoMilliseconds to wait for dynamic content before extracting.
mobilebooleanNoEmulate a mobile browser viewport.
skipTlsVerificationbooleanNoBypass TLS certificate validation.

crawl

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

ParameterTypeRequiredDefaultDescription
urlstringYesRoot URL to begin crawling.
limitnumberNo10Maximum number of pages to crawl.
maxDiscoveryDepthnumberNoMaximum link depth from the root URL.
allowExternalLinksbooleanNoFollow links to external domains.
allowSubdomainsbooleanNoFollow links to subdomains of the root domain.
sitemapstringNoSitemap handling: include, skip, or only.
includePathsarray[string]NoURL path glob patterns to include.
excludePathsarray[string]NoURL path glob patterns to exclude.

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

ParameterTypeRequiredDefaultDescription
querystringYesSearch query string.
limitnumberNo5Maximum number of results to return.
locationstringNoCountry/region code for localized results (e.g., US, BR).
includeDomainsarray[string]NoRestrict results to these domains.
excludeDomainsarray[string]NoExclude 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
urlstringYesBase URL of the site to map.
searchstringNoFilter discovered URLs by this keyword.
limitnumberNo50Maximum number of URLs to return.
sitemapstringNoSitemap handling: include, skip, or only.
includeSubdomainsbooleanNoInclude URLs from subdomains.

extract

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

ParameterTypeRequiredDefaultDescription
urlsarray[string]YesList of URLs to extract data from.
promptstringNoNatural language description of the target data.
schemaobjectNoJSON Schema object defining the expected output shape.
systemPromptstringNoOverride the extraction system prompt.
allowExternalLinksbooleanNoAllow 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]YesList 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.