Skip to content

Commit 6fef044

Browse files
authored
(feat/interact) Interact (#193)
* Nick: * Update index.ts * Update index.ts * Update README.md * Nick:
1 parent d267d9b commit 6fef044

4 files changed

Lines changed: 156 additions & 27 deletions

File tree

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,21 @@ Use this guide to select the right tool for your task:
317317
- **If you want to search the web for info:** use **search**
318318
- **If you need complex research across multiple unknown sources:** use **agent**
319319
- **If you want to analyze a whole site or section:** use **crawl** (with limits!)
320-
- **If you need interactive browser automation** (click, type, navigate): use **browser**
320+
- **If you need interactive browser automation** (click, type, navigate): use **scrape** + **interact**
321+
- **If you need a raw CDP browser session** (advanced): use **browser** (deprecated)
321322

322323
### Quick Reference Table
323324

324325
| Tool | Best for | Returns |
325326
| ------------ | ----------------------------------- | -------------------------- |
326327
| scrape | Single page content | JSON (preferred) or markdown |
328+
| interact | Interact with a scraped page | Execution result |
327329
| batch_scrape | Multiple known URLs | JSON (preferred) or markdown[] |
328330
| map | Discovering URLs on a site | URL[] |
329331
| crawl | Multi-page extraction (with limits) | markdown/html[] |
330332
| search | Web search for info | results[] |
331333
| agent | Complex multi-source research | JSON (structured data) |
332-
| browser | Interactive multi-step automation | Session with live browser |
334+
| browser | Interactive multi-step automation (deprecated) | Session with live browser |
333335

334336
### Format Selection Guide
335337

@@ -816,16 +818,11 @@ Check the status of an agent job and retrieve results when complete. Use this to
816818
- `completed`: Research finished - response includes the extracted data
817819
- `failed`: An error occurred
818820

819-
### 11. Browser Create (`firecrawl_browser_create`)
821+
### 11. Browser Create (`firecrawl_browser_create`) — Deprecated
820822

821-
Create a cloud browser session for interactive automation.
822-
823-
**Best for:**
823+
> **Deprecated:** Prefer `firecrawl_scrape` + `firecrawl_interact` instead. Interact lets you scrape a page and then click, fill forms, and navigate without managing sessions manually.
824824
825-
- Multi-step browser automation (navigate, click, fill forms, extract data)
826-
- Interactive workflows that require maintaining state across actions
827-
- Testing and debugging web pages in a live browser
828-
- Saving and reusing browser state with profiles
825+
Create a cloud browser session for interactive automation.
829826

830827
**Arguments:**
831828

@@ -852,7 +849,9 @@ Create a cloud browser session for interactive automation.
852849

853850
- Session ID, CDP URL, and live view URL
854851

855-
### 12. Browser Execute (`firecrawl_browser_execute`)
852+
### 12. Browser Execute (`firecrawl_browser_execute`) — Deprecated
853+
854+
> **Deprecated:** Prefer `firecrawl_scrape` + `firecrawl_interact` instead.
856855
857856
Execute code in a browser session. Supports agent-browser commands (bash), Python, or JavaScript.
858857

@@ -894,7 +893,9 @@ Execute code in a browser session. Supports agent-browser commands (bash), Pytho
894893
}
895894
```
896895

897-
### 13. Browser List (`firecrawl_browser_list`)
896+
### 13. Browser List (`firecrawl_browser_list`) — Deprecated
897+
898+
> **Deprecated:** Prefer `firecrawl_scrape` + `firecrawl_interact` instead.
898899
899900
List browser sessions, optionally filtered by status.
900901

@@ -907,7 +908,9 @@ List browser sessions, optionally filtered by status.
907908
}
908909
```
909910

910-
### 14. Browser Delete (`firecrawl_browser_delete`)
911+
### 14. Browser Delete (`firecrawl_browser_delete`) — Deprecated
912+
913+
> **Deprecated:** Prefer `firecrawl_scrape` + `firecrawl_interact` instead.
911914
912915
Destroy a browser session.
913916

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firecrawl-mcp",
3-
"version": "3.12.1",
3+
"version": "3.13.0",
44
"description": "MCP server for Firecrawl web scraping integration. Supports both cloud and self-hosted instances. Features include web scraping, search, batch processing, structured data extraction, and LLM-powered content analysis.",
55
"type": "module",
66
"mcpName": "io.github.firecrawl/firecrawl-mcp-server",
@@ -28,7 +28,7 @@
2828
},
2929
"license": "MIT",
3030
"dependencies": {
31-
"@mendable/firecrawl-js": "4.15.2",
31+
"@mendable/firecrawl-js": "4.17.0",
3232
"dotenv": "^17.2.2",
3333
"firecrawl-fastmcp": "^1.0.4",
3434
"typescript": "^5.9.2",

pnpm-lock.yaml

Lines changed: 19 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 119 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ const scrapeParamsSchema = z.object({
334334
zeroDataRetention: z.boolean().optional(),
335335
maxAge: z.number().optional(),
336336
proxy: z.enum(['basic', 'stealth', 'enhanced', 'auto']).optional(),
337+
profile: z
338+
.object({
339+
name: z.string(),
340+
saveChanges: z.boolean().optional(),
341+
})
342+
.optional(),
337343
});
338344

339345
server.addTool({
@@ -820,7 +826,7 @@ Autonomous web research agent. This is a separate AI agent layer that independen
820826
**Not recommended for:**
821827
- Single-page extraction when you have a URL (use firecrawl_scrape, faster and cheaper)
822828
- Web search (use firecrawl_search first)
823-
- Interactive page tasks like clicking, filling forms, login, or navigating JS-heavy SPAs (use firecrawl_browser_create + firecrawl_browser_execute)
829+
- Interactive page tasks like clicking, filling forms, login, or navigating JS-heavy SPAs (use firecrawl_scrape + firecrawl_interact)
824830
- Extracting specific data from a known page (use firecrawl_scrape with JSON format)
825831
826832
**Arguments:**
@@ -936,14 +942,13 @@ Check the status of an agent job and retrieve results when complete. Use this to
936942
},
937943
});
938944

939-
// Browser session tools
945+
// Browser session tools (deprecated — prefer firecrawl_scrape + firecrawl_interact)
940946
server.addTool({
941947
name: 'firecrawl_browser_create',
942948
description: `
943-
Create a browser session for code execution via CDP (Chrome DevTools Protocol).
949+
**DEPRECATED — prefer firecrawl_scrape + firecrawl_interact instead.** Interact lets you scrape a page and then click, fill forms, and navigate without managing sessions manually.
944950
945-
**Best for:** Running code (Python/JS) that interacts with a live browser page, multi-step browser automation, sessions with profiles that survive across multiple tool calls.
946-
**Not recommended for:** Simple page scraping (use firecrawl_scrape instead).
951+
Create a browser session for code execution via CDP (Chrome DevTools Protocol).
947952
948953
**Arguments:**
949954
- ttl: Total session lifetime in seconds (30-3600, optional)
@@ -990,9 +995,9 @@ if (!SAFE_MODE) {
990995
server.addTool({
991996
name: 'firecrawl_browser_execute',
992997
description: `
993-
Execute code in a browser session. Supports agent-browser commands (bash), Python, or JavaScript.
998+
**DEPRECATED — prefer firecrawl_scrape + firecrawl_interact instead.** Interact lets you scrape a page and then click, fill forms, and navigate without managing sessions manually.
994999
995-
**Best for:** Browser automation, navigating pages, clicking elements, extracting data, multi-step browser workflows.
1000+
Execute code in a browser session. Supports agent-browser commands (bash), Python, or JavaScript.
9961001
**Requires:** An active browser session (create one with firecrawl_browser_create first).
9971002
9981003
**Arguments:**
@@ -1067,6 +1072,8 @@ Execute code in a browser session. Supports agent-browser commands (bash), Pytho
10671072
server.addTool({
10681073
name: 'firecrawl_browser_delete',
10691074
description: `
1075+
**DEPRECATED — prefer firecrawl_scrape + firecrawl_interact instead.**
1076+
10701077
Destroy a browser session.
10711078
10721079
**Usage Example:**
@@ -1098,6 +1105,8 @@ Destroy a browser session.
10981105
server.addTool({
10991106
name: 'firecrawl_browser_list',
11001107
description: `
1108+
**DEPRECATED — prefer firecrawl_scrape + firecrawl_interact instead.**
1109+
11011110
List browser sessions, optionally filtered by status.
11021111
11031112
**Usage Example:**
@@ -1126,6 +1135,109 @@ List browser sessions, optionally filtered by status.
11261135
},
11271136
});
11281137

1138+
// Interact tools (scrape-bound browser sessions)
1139+
server.addTool({
1140+
name: 'firecrawl_interact',
1141+
description: `
1142+
Interact with a previously scraped page in a live browser session. Scrape a page first with firecrawl_scrape, then use the returned scrapeId to click buttons, fill forms, extract dynamic content, or navigate deeper.
1143+
1144+
**Best for:** Multi-step workflows on a single page — searching a site, clicking through results, filling forms, extracting data that requires interaction.
1145+
**Requires:** A scrapeId from a previous firecrawl_scrape call (found in the metadata of the scrape response).
1146+
1147+
**Arguments:**
1148+
- scrapeId: The scrape job ID from a previous scrape (required)
1149+
- prompt: Natural language instruction describing the action to take (use this OR code)
1150+
- code: Code to execute in the browser session (use this OR prompt)
1151+
- language: "bash", "python", or "node" (optional, defaults to "node", only used with code)
1152+
- timeout: Execution timeout in seconds, 1-300 (optional, defaults to 30)
1153+
1154+
**Usage Example (prompt):**
1155+
\`\`\`json
1156+
{
1157+
"name": "firecrawl_interact",
1158+
"arguments": {
1159+
"scrapeId": "scrape-id-from-previous-scrape",
1160+
"prompt": "Click on the first product and tell me its price"
1161+
}
1162+
}
1163+
\`\`\`
1164+
1165+
**Usage Example (code):**
1166+
\`\`\`json
1167+
{
1168+
"name": "firecrawl_interact",
1169+
"arguments": {
1170+
"scrapeId": "scrape-id-from-previous-scrape",
1171+
"code": "agent-browser click @e5",
1172+
"language": "bash"
1173+
}
1174+
}
1175+
\`\`\`
1176+
**Returns:** Execution result including output, stdout, stderr, exit code, and live view URLs.
1177+
`,
1178+
parameters: z.object({
1179+
scrapeId: z.string(),
1180+
prompt: z.string().optional(),
1181+
code: z.string().optional(),
1182+
language: z.enum(['bash', 'python', 'node']).optional(),
1183+
timeout: z.number().min(1).max(300).optional(),
1184+
}).refine(data => data.code || data.prompt, {
1185+
message: "Either 'code' or 'prompt' must be provided.",
1186+
}),
1187+
execute: async (
1188+
args: unknown,
1189+
{ session, log }: { session?: SessionData; log: Logger }
1190+
): Promise<string> => {
1191+
const client = getClient(session);
1192+
const { scrapeId, prompt, code, language, timeout } = args as {
1193+
scrapeId: string;
1194+
prompt?: string;
1195+
code?: string;
1196+
language?: 'bash' | 'python' | 'node';
1197+
timeout?: number;
1198+
};
1199+
log.info('Interacting with scraped page', { scrapeId });
1200+
const interactArgs: Record<string, unknown> = { origin: ORIGIN };
1201+
if (prompt) interactArgs.prompt = prompt;
1202+
if (code) interactArgs.code = code;
1203+
if (language) interactArgs.language = language;
1204+
if (timeout != null) interactArgs.timeout = timeout;
1205+
const res = await client.interact(scrapeId, interactArgs as any);
1206+
return asText(res);
1207+
},
1208+
});
1209+
1210+
server.addTool({
1211+
name: 'firecrawl_interact_stop',
1212+
description: `
1213+
Stop an interact session for a scraped page. Call this when you are done interacting to free resources.
1214+
1215+
**Usage Example:**
1216+
\`\`\`json
1217+
{
1218+
"name": "firecrawl_interact_stop",
1219+
"arguments": {
1220+
"scrapeId": "scrape-id-here"
1221+
}
1222+
}
1223+
\`\`\`
1224+
**Returns:** Success confirmation.
1225+
`,
1226+
parameters: z.object({
1227+
scrapeId: z.string(),
1228+
}),
1229+
execute: async (
1230+
args: unknown,
1231+
{ session, log }: { session?: SessionData; log: Logger }
1232+
): Promise<string> => {
1233+
const client = getClient(session);
1234+
const { scrapeId } = args as { scrapeId: string };
1235+
log.info('Stopping interact session', { scrapeId });
1236+
const res = await client.stopInteraction(scrapeId);
1237+
return asText(res);
1238+
},
1239+
});
1240+
11291241
const PORT = Number(process.env.PORT || 3000);
11301242
const HOST =
11311243
process.env.CLOUD_SERVICE === 'true'

0 commit comments

Comments
 (0)