Skip to content

feat(scrape): expose knowledgeGraph format to agents#252

Open
beardfaceguy wants to merge 1 commit into
firecrawl:mainfrom
beardfaceguy:adding-knowledge-graph-capability
Open

feat(scrape): expose knowledgeGraph format to agents#252
beardfaceguy wants to merge 1 commit into
firecrawl:mainfrom
beardfaceguy:adding-knowledge-graph-capability

Conversation

@beardfaceguy

Copy link
Copy Markdown

Summary

Exposes the knowledgeGraph scrape format in the MCP server, mirroring how json/query formats are surfaced. Agents using the Firecrawl MCP server can now request entity/relationship graphs from scrape, search, and crawl calls without bypassing the MCP layer.

Structurally identical to #223 (audio format passthrough).

Companion API change

The API-side format itself is being discussed as an RFC in firecrawl/firecrawl#3684. This wrapper is intentionally minimal (just passthrough), and is safe to merge regardless of the decision on the API-side PR — the API will reject unknown formats, so this is a no-op until the API supports knowledgeGraph.

Changes (src/index.ts)

  • scrapeParamsSchema.formats enum: added 'knowledgeGraph'.
  • New knowledgeGraphOptions param: { entityTypes: string[].max(50) }.
  • buildFormatsArray: maps 'knowledgeGraph'{ type: 'knowledgeGraph', ...knowledgeGraphOptions } (mirrors json/query handling).
  • transformScrapeParams: strips knowledgeGraphOptions after building.
  • Tool description: added knowledgeGraph format docs + example.

Because scrapeParamsSchema is shared, the search and crawl tools (scrapeOptions) pick this up for free.

SDK note

The bundled @mendable/firecrawl-js@4.24.0's ensureValidFormats() is permissive — unknown format types fall through unchanged. No SDK patch needed.

Validation

  • pnpm run build: clean (tsc).
  • End-to-end via stdio JSON-RPC against a local self-hosted Firecrawl instance with the API-side change applied:
    • Scrape Ada_Lovelace with entityTypes=['Person'] → 4 nodes / 3 edges, all typed Person.
  • Pattern follows existing format passthroughs.

CHANGELOG

Happy to add a CHANGELOG.md entry following the existing convention if you'd like — let me know your preference. Did not bump package.json version (per VERSIONING.md, that triggers npm publish — maintainer's call).

Made with Cursor

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.
@beardfaceguy beardfaceguy force-pushed the adding-knowledge-graph-capability branch from 1311d88 to 6fef27f Compare June 8, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant