Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ const openAiAppsChallengeToken = normalizeHeader(
);

const FULL_PROFILE_INSTRUCTIONS =
`Firecrawl provides web search, page retrieval, site URL discovery, multi-page collection, structured page data, monitoring, and multi-source research that returns structured data. Match the requested operation to the tool boundary: firecrawl_scrape retrieves one supplied page and can return JSON matching a supplied schema, firecrawl_map enumerates URLs under a site without retrieving their content, and firecrawl_agent runs multi-source research and returns structured data when the URLs are not known or the answer spans several sites (an entity plus its fields, a list, a dataset); its result is read with firecrawl_agent_status. Authenticated firecrawl_search returns web results together with matching Alexandria providers in data.tools. ${ALEXANDRIA_CATALOGUE_SENTENCE} A matching provider can return the same fields across several entities, provenance, exact figures or timestamps, or a large set of records through firecrawl_scrape with its published contract. If web results already answer the question, use them. For the same fields across multiple pages, firecrawl_find_tools offers free provider discovery. Use firecrawl_find_tools to read a contract that was not returned in full or to browse the catalogue by category. ${ALEXANDRIA_SOURCES_OPT_OUT} If no provider fits, continue with web search or firecrawl_agent. For biomedical, life-science, clinical, or arXiv literature, the firecrawl_research_* tools search a paper index of abstracts and full text; firecrawl_search with categories: ["research"] is a website filter over ordinary web results and reaches different sources. For a programming question (code behaviour, a library or framework, an API contract, an error message, or a known bug), firecrawl_developer_search (or firecrawl_search with categories: ["developer"]) searches an index of public repositories, GitHub issues, merged pull requests, READMEs, and code documentation. Alexandria requestId identifies one logical execution; repeated attempts of the identical payload require the same ID, including pending or uncertain executions. firecrawl_search with sources: [{type: "alexandria"}] returns compact tool summaries in data.tools; toolDetail: "full" includes contracts, firecrawl_find_tools starts with categories, lists providers, then compact tools, and expands the selected full contract, and firecrawl_scrape with alexandria: [{provider, capability, options}] executes up to ten capabilities and returns their results. Alexandria access needs an API key on a team with it enabled. A terms-gated Alexandria provider fails with code THIRD_PARTY_DATA_TERMS_REQUIRED and a requiresAction.url. Through firecrawl_scrape, terms/show displays the agreement and terms/accept records acceptance; acceptance requires explicit user authorization for the reviewed version and digest and confirmed:true. A data request does not authorize acceptance. The dashboard URL provides an alternative for an organization admin. A retained result provides nextTool access without repeating a successful provider call. Provide only the required inputs and account for stated network or external side effects.`;
`Firecrawl provides web search, page retrieval, site URL discovery, multi-page collection, structured page data, monitoring, and multi-source research that returns structured data. Match the requested operation to the tool boundary: firecrawl_scrape retrieves one supplied page and can return JSON matching a supplied schema, firecrawl_map enumerates URLs under a site without retrieving their content, and firecrawl_agent runs multi-source research and returns structured data when the URLs are not known or the answer spans several sites (an entity plus its fields, a list, a dataset); its result is read with firecrawl_agent_status. Authenticated firecrawl_search returns web results together with matching Alexandria providers in data.tools. ${ALEXANDRIA_CATALOGUE_SENTENCE} A matching provider can return the same fields across several entities, provenance, exact figures or timestamps, or a large set of records through firecrawl_scrape with its published contract. If web results already answer the question, use them. For the same fields across multiple pages, firecrawl_find_tools offers free provider discovery. Use firecrawl_find_tools to read a contract that was not returned in full or to browse the catalogue by category. ${ALEXANDRIA_SOURCES_OPT_OUT} If no provider fits, continue with web search or firecrawl_agent. For biomedical, life-science, clinical, or arXiv literature, the firecrawl_research_* tools search a paper index of abstracts and full text; firecrawl_search with categories: ["research"] is a website filter over ordinary web results and reaches different sources. For a programming question (code behaviour, a library or framework, an API contract, an error message, or a known bug), firecrawl_developer_search (or firecrawl_search with categories: ["developer"]) searches an index of public repositories, GitHub issues, merged pull requests, READMEs, and code documentation. firecrawl_search with sources: [{type: "alexandria"}] returns compact tool summaries in data.tools; toolDetail: "full" includes contracts, firecrawl_find_tools starts with categories, lists providers, then compact tools, and expands the selected full contract, and firecrawl_scrape with alexandria: [{provider, capability, options}] executes up to ten capabilities and returns their results. Alexandria access needs an API key on a team with it enabled. Provide only the required inputs and account for stated network or external side effects.`;
const KEYLESS_PROFILE_INSTRUCTIONS = `Hosted keyless sessions expose firecrawl_search, firecrawl_scrape, and firecrawl_parse with usage limits. firecrawl_search searches the web. For programming questions, firecrawl_search with categories: ["developer"] searches indexed public repositories, GitHub issues, merged pull requests, repository READMEs, and code documentation. For biomedical, life-science, clinical, or arXiv literature, firecrawl_search with categories: ["research"] filters ordinary web results to research-affiliated websites. firecrawl_scrape retrieves one supplied page and can return JSON matching a supplied schema. firecrawl_parse processes supported local files through its two-phase upload flow. An Authorization bearer API key can provide higher usage limits and expose additional tools, subject to plan, deployment, and team policy, including firecrawl_map for site URL discovery, firecrawl_agent and firecrawl_agent_status for multi-source research that returns structured data when the URLs are not known, firecrawl_research_* for paper-index and repository research, and firecrawl_find_tools as the progressive Alexandria catalogue lookup alongside the Alexandria options of firecrawl_search and firecrawl_scrape for catalogued data providers.`;

// The search surface exposes web/developer/research search plus the two Alexandria
Expand Down Expand Up @@ -2019,14 +2019,14 @@ const scrapeToolParamsSchema = scrapeParamsSchema
.regex(/^[A-Za-z0-9._:-]{1,128}$/)
.optional()
.describe(
'Identifies one logical Alexandria execution; generated when omitted and returned with the result. Repeated attempts of the identical payload require the same ID. A new ID cannot reconcile a pending or uncertain execution. A caller-supplied ID supports recovery if no response is received. Errors relay a code and may include chargeId. request_in_flight (409) means the execution is pending; request_unresolved (503) requires reconciliation under the same ID; duplicate_request (409) means the ID belongs to a different payload; unknown_provider (404), insufficient_credits (402) and billing_unavailable (503) mean nothing executed.'
'Idempotency key bound to one Alexandria execution payload. Generated when omitted and returned with the result.'
),
alexandria: z.union([exchangeCallSchema, exchangeCallsSchema])
.optional()
.describe(
'Catalogued Alexandria capability invocation, mutually exclusive with url. One {provider, capability, options} object or an array of 1-10, with contracts available through firecrawl_search or firecrawl_find_tools. Each call may include version to pin a published workflow; omitting it uses latest. Only requestId and timeout are supported alongside alexandria. ' +
ALEXANDRIA_CONTRACT_GUIDANCE +
' Returns per-capability results in data.alexandria with data, records, or an error with a code; individual capabilities can fail even when the outer response succeeds. nextTool identifies access to retained results without repeating a successful provider call. Requires an API key on a team with Alexandria enabled. THIRD_PARTY_DATA_TERMS_REQUIRED (403) means execution is blocked by provider terms, with requiresAction.url for review by an organization admin. Through this tool, terms/show displays the agreement and terms/accept records acceptance; acceptance requires explicit user authorization for the reviewed version and digest and confirmed:true. A data request does not authorize acceptance. Provider execution remains blocked until acceptance is confirmed.'
' Returns per-capability results in data.alexandria with data, records, or an error with a code; individual capabilities can fail even when the outer response succeeds. Requires an API key on a team with Alexandria enabled. Some providers require accepted terms; blocked requests return the applicable requirements.'
),
toolDetail: z.enum(['compact', 'summary', 'full']).optional().describe('URL mode only: domain discovery detail, summary by default; compact returns provider/capability/description, full includes contracts. Ignored with alexandria.'),
domainTools: z
Expand Down Expand Up @@ -2464,7 +2464,7 @@ Firecrawl may serve recently indexed content; set \`maxAge: 0\` for a live fetch

On an authenticated session with Alexandria access, \`firecrawl_search\` with \`sources\` unset and \`firecrawl_find_tools\` can discover providers for the same fields across several pages; a matching provider returns typed records in one call. Keyless sessions have no provider matches.

Alexandria mode, on an authenticated session with Alexandria access: \`alexandria\` selects catalogued capability execution and is mutually exclusive with \`url\`; the \`alexandria\` and \`requestId\` parameters describe batching, retries, errors and provider terms.
Alexandria mode, on an authenticated session with Alexandria access: \`alexandria\` selects catalogued capability execution and is mutually exclusive with \`url\`.
`,
outputSchema: scrapeOutputSchema,
parameters: scrapeToolParamsSchema,
Expand Down Expand Up @@ -2763,7 +2763,7 @@ Scrape one URL and return its content, or execute catalogued Alexandria capabili

\`firecrawl_search\` with \`sources\` unset and \`firecrawl_find_tools\` can discover providers for the same fields across several pages; a matching Alexandria provider returns typed records in one call.

Alexandria mode: \`alexandria\` selects catalogued capability execution and is mutually exclusive with \`url\`; the \`alexandria\` and \`requestId\` parameters describe batching, retries, errors and provider terms. Alexandria execution is billed at the capability's listed price and needs a team with Alexandria enabled.
Alexandria mode: \`alexandria\` selects catalogued capability execution and is mutually exclusive with \`url\`. Alexandria execution is billed at the capability's listed price and needs a team with Alexandria enabled.
`;
const searchSurfaceScrapeTool: RegisteredTool = {
...scrapeTool,
Expand Down
2 changes: 1 addition & 1 deletion src/tool-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const warning = str('Non-fatal warning about the result.');

/** Keys every Alexandria-capable response can carry (see `alexandriaOutput`). */
const alexandriaEnvelope = {
requestId: str('Identifier of this logical execution; reuse it only for a retry of the identical payload.'),
requestId: str('Identifier of this Alexandria execution.'),
scrape_id: str('Identifier of the underlying scrape.'),
receipt: unknown('Billing receipt for the execution.'),
creditsCost: num('Credits this call consumed.'),
Expand Down
21 changes: 10 additions & 11 deletions tests/helpers/alexandria-metadata.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ export function assertAlexandriaMetadata(tools, instructions) {
assert.ok(requestId?.description, 'firecrawl_scrape.requestId needs a description');
assert.ok(alexandria?.description, 'firecrawl_scrape.alexandria needs a description');
assert.equal(scrape.annotations.readOnlyHint, false);
assert.match(requestId.description, /identical payload.*same ID/i);
assert.match(requestId.description, /new ID cannot reconcile a pending or uncertain execution/i);
assert.match(requestId.description, /request_in_flight.*pending/);
assert.match(requestId.description, /request_unresolved.*reconciliation under the same ID/);
assert.match(requestId.description, /idempotency key.*payload/i);
assert.match(requestId.description, /generated when omitted and returned with the result/i);
assert.match(alexandria.description, /mutually exclusive with url/);
assert.match(alexandria.description, /array of 1-10/);
assert.match(alexandria.description, /terms\/show.*terms\/accept/);
assert.match(alexandria.description, /explicit user authorization for the reviewed version and digest and confirmed:true/);
assert.match(alexandria.description, /data request does not authorize acceptance/i);
assert.match(alexandria.description, /execution remains blocked until acceptance is confirmed/i);
assert.match(alexandria.description, /per-capability results in data\.alexandria/);
assert.match(alexandria.description, /blocked requests return the applicable requirements/i);

const descriptions = [instructions];
for (const name of ['firecrawl_search', 'firecrawl_scrape', 'firecrawl_find_tools']) {
const tool = tools.find((item) => item.name === name);
assert.ok(tool, `${name} must be registered`);
assert.ok(tool.outputSchema?.properties, `${name} must expose output property metadata`);
descriptions.push(tool.description ?? '');
for (const field of Object.values(tool.inputSchema?.properties ?? {})) {
if (field.description) descriptions.push(field.description);
for (const schema of [tool.inputSchema, tool.outputSchema]) {
for (const field of Object.values(schema?.properties ?? {})) {
if (field.description) descriptions.push(field.description);
}
}
}
for (const description of descriptions) {
assert.doesNotMatch(description, /follow the returned terms\/show and terms\/accept|retry the same requestId later|call firecrawl_feedback once per website|after the task, report how the catalogue/i);
assert.doesNotMatch(description, /terms\/show|terms\/accept|confirmed:true|repeated attempts|reuse it only for a retry|retry the same requestId|call firecrawl_feedback once per website|after the task, report how the catalogue/i);
}
}
4 changes: 3 additions & 1 deletion tests/mcp-alexandria-terms.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ test('terms are disclosed after a blocked provider and use scrape instead of top
assert.ok(!listing.tools.some(tool => /^firecrawl_terms_/.test(tool.name)));
const blocked = await callExpectingError(client, { name: 'firecrawl_scrape', arguments: { alexandria: [{ provider: 'benzinga', capability: 'news/search' }] } });
assert.equal(api.requests.length, 1, 'blocked requests never auto-accept');
assert.match(blocked.content[0].text, /explicit authorization/);
assert.match(blocked.content[0].text, /explicit authorization to accept that exact version and digest/);
assert.match(blocked.content[0].text, /Never infer acceptance from a data request/);
assert.match(blocked.content[0].text, /Reuse this ID only with the identical payload/);
const { code, status, requiresAction, requestId, next_actions } = blocked.structuredContent;
assert.equal(code, TERMS_REQUIRED_BODY.code);
assert.equal(status, 403);
Expand Down
12 changes: 2 additions & 10 deletions tests/mcp-smoke.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,12 +1125,8 @@ test('stdio transport initializes and lists Firecrawl tools', async (t) => {
// A stdio session with an API key gets the Alexandria-aware instructions,
// not the keyless wording.
assert.match(init.instructions, /firecrawl_scrape retrieves one supplied page/i);
// Claude Code truncates server instructions at CLAUDE_CODE_TEXT_CAP characters; the
// Alexandria routing paragraph has to land inside that window. Trade-off: the
// developer/research routing and the requestId retry rule now sit after it, past the
// cap. Both are also carried where Claude Code does not truncate them: the
// firecrawl_search description (developer and research categories, asserted below)
// and the requestId parameter description (retry rule, asserted in the budget test).
// Keep Alexandria routing within the truncated server instructions. The search
// description also carries developer and research routing (asserted below).
const instructionsHead = init.instructions.slice(0, CLAUDE_CODE_TEXT_CAP);
assert.match(instructionsHead, /Alexandria is Firecrawl's catalogue of data providers/);
assert.match(instructionsHead, /For the same fields across multiple pages/);
Expand All @@ -1147,10 +1143,6 @@ test('stdio transport initializes and lists Firecrawl tools', async (t) => {
init.instructions,
/For the same fields across multiple pages, firecrawl_find_tools offers free provider discovery/
);
assert.match(
init.instructions,
/THIRD_PARTY_DATA_TERMS_REQUIRED.*terms\/show.*terms\/accept.*acceptance requires explicit user authorization/is
);
assert.match(
byName.get('firecrawl_scrape').description,
/request identifies a page and needs its content or defined fields/i
Expand Down
Loading