Skip to content

Commit 6fef27f

Browse files
committed
feat: expose knowledgeGraph scrape format over MCP
Surface the new knowledgeGraph format (added in the firecrawl API) so agents can request it through the scrape/search/crawl tools. - scrapeParamsSchema: add 'knowledgeGraph' to the formats enum and a knowledgeGraphOptions param ({ entityTypes: string[].max(50) }). - buildFormatsArray: map 'knowledgeGraph' to { type:'knowledgeGraph', ...knowledgeGraphOptions }, mirroring the json/query handling. - transformScrapeParams: strip knowledgeGraphOptions after building. - Tool description: document the format and add a usage example. scrapeParamsSchema is shared by the scrape, search, and crawl tools, so this covers all three. The bundled @mendable/firecrawl-js validator is permissive toward unknown format types, so no SDK change is required.
1 parent 01e3b8a commit 6fef27f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ function buildFormatsArray(
386386
| Record<string, unknown>
387387
| undefined;
388388
result.push({ type: 'query', ...queryOpts });
389+
} else if (fmt === 'knowledgeGraph') {
390+
const kgOpts = args.knowledgeGraphOptions as
391+
| Record<string, unknown>
392+
| undefined;
393+
result.push({ type: 'knowledgeGraph', ...kgOpts });
389394
} else if (fmt === 'screenshot' && args.screenshotOptions) {
390395
const ssOpts = args.screenshotOptions as Record<string, unknown>;
391396
result.push({ type: 'screenshot', ...ssOpts });
@@ -439,6 +444,7 @@ function transformScrapeParams(
439444

440445
delete out.jsonOptions;
441446
delete out.queryOptions;
447+
delete out.knowledgeGraphOptions;
442448
delete out.screenshotOptions;
443449
delete out.pdfOptions;
444450

@@ -460,6 +466,7 @@ const scrapeParamsSchema = z.object({
460466
'branding',
461467
'json',
462468
'query',
469+
'knowledgeGraph',
463470
'audio',
464471
])
465472
)
@@ -470,6 +477,11 @@ const scrapeParamsSchema = z.object({
470477
schema: z.record(z.string(), z.any()).optional(),
471478
})
472479
.optional(),
480+
knowledgeGraphOptions: z
481+
.object({
482+
entityTypes: z.array(z.string()).max(50).optional(),
483+
})
484+
.optional(),
473485
queryOptions: z
474486
.object({
475487
prompt: z.string().max(10000),
@@ -637,6 +649,18 @@ If JSON extraction returns empty, minimal, or just navigation content, the page
637649
}
638650
\`\`\`
639651
**Branding format:** Extracts comprehensive brand identity (colors, fonts, typography, spacing, logo, UI components) for design analysis or style replication.
652+
**Knowledge graph format:** Use \`knowledgeGraph\` to extract a graph of the entities on a page (nodes) and the relationships between them (edges). Each node has \`id\`, \`label\`, \`type\`; each edge has \`source\`, \`target\`, \`relation\`. Optionally pass \`knowledgeGraphOptions.entityTypes\` (max 50) to restrict which entity types are extracted. Best for mapping people/organizations/concepts and how they connect, rather than reading prose.
653+
**Knowledge graph example:**
654+
\`\`\`json
655+
{
656+
"name": "firecrawl_scrape",
657+
"arguments": {
658+
"url": "https://en.wikipedia.org/wiki/Marie_Curie",
659+
"formats": ["knowledgeGraph"],
660+
"knowledgeGraphOptions": { "entityTypes": ["Person", "Organization"] }
661+
}
662+
}
663+
\`\`\`
640664
**Performance:** Add maxAge parameter for 500% faster scrapes using cached data.
641665
**Lockdown mode:** Set \`lockdown: true\` to serve the request only from the existing index/cache without any outbound network request. For air-gapped or compliance-constrained use where the request URL itself is considered sensitive. Errors on cache miss. Billed at 5 credits.
642666
**Privacy:** Set \`redactPII: true\` to return content with personally identifiable information redacted.

0 commit comments

Comments
 (0)