You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(mcp)!: More reliable structure + new tools
A better fix than #418 is to eliminate this bug class and keep the AI agent knowing the default parameter values.
I have also shortened the docstrings where possible to save tokens.
Copy file name to clipboardExpand all lines: agent-skill/Scrapling-Skill/references/mcp-server.md
+39-17Lines changed: 39 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# Scrapling MCP Server
2
2
3
-
The Scrapling MCP server exposes ten tools over the MCP protocol. It supports CSS-selector-based content narrowing (reducing tokens by extracting only relevant elements before returning results), three levels of scraping capability (plain HTTP, browser-rendered, and stealth/anti-bot bypass), persistent browser session management, and page screenshots returned as real image content blocks.
3
+
The Scrapling MCP server exposes eleven tools over the MCP protocol. It supports CSS-selector-based content narrowing (reducing tokens by extracting only relevant elements before returning results), three levels of scraping capability (plain HTTP, browser-rendered, and stealth/anti-bot bypass), persistent browser session management, and page screenshots returned as real image content blocks. Fetch tools come in two modes: one-shot tools (`fetch`, `bulk_fetch`, `stealthy_fetch`, `bulk_stealthy_fetch`) each launch and close their own browser, while `session_fetch` fetches through a session opened with `open_session`.
4
4
5
5
All scraping tools return a `ResponseModel` with fields: `status` (int), `content` (list of strings), `url` (str). The `screenshot` tool returns a list of MCP content blocks: an `ImageContent` (the screenshot bytes) followed by a `TextContent` (the post-redirect URL).
6
6
7
-
## Tools
7
+
## One-shot tools
8
8
9
9
### `get` -- HTTP request (single URL)
10
10
@@ -66,11 +66,12 @@ Opens a Chromium browser via Playwright to render JavaScript. Suitable for dynam
66
66
|`cookies`| list or null | null | Playwright-format cookies |
67
67
|`timezone_id`| str or null | null | Browser timezone, e.g. `"America/New_York"`|
68
68
|`locale`| str or null | null | Browser locale, e.g. `"en-GB"`|
69
-
|`session_id`| str or null | null | Reuse a persistent session from `open_session` instead of creating a new browser |
69
+
70
+
This is a one-shot tool: it always launches its own browser. To fetch through a persistent session, use `session_fetch`.
70
71
71
72
### `bulk_fetch` -- Browser fetch (multiple URLs)
72
73
73
-
Concurrent browser version of `fetch`. Same parameters (including `session_id`) except `url` is replaced by `urls` (list of strings). Each URL opens in a separate browser tab. Returns a list of `ResponseModel`.
74
+
Concurrent browser version of `fetch`. Same parameters except `url` is replaced by `urls` (list of strings). Each URL opens in a separate browser tab. Returns a list of `ResponseModel`.
@@ -85,17 +86,18 @@ Anti-bot bypass fetcher with fingerprint spoofing. Use this for sites with Cloud
85
86
|`block_webrtc`| bool | false | Force WebRTC to respect proxy settings (prevents IP leak) |
86
87
|`allow_webgl`| bool | true | Keep WebGL enabled (disabling is detectable by WAFs) |
87
88
|`additional_args`| dict or null | null | Extra Playwright context args (overrides Scrapling defaults) |
88
-
|`session_id`| str or null | null | Reuse a persistent stealthy session from `open_session`|
89
89
90
-
All parameters from `fetch` are also accepted.
90
+
All parameters from `fetch` are also accepted. Like `fetch`, this is a one-shot tool that launches its own browser; use `session_fetch` for a stealthy session.
Concurrent stealth version. Same parameters (including `session_id`) as `stealthy_fetch` except `url` is replaced by `urls` (list of strings). Returns a list of `ResponseModel`.
94
+
Concurrent stealth version. Same parameters as `stealthy_fetch` except `url` is replaced by `urls` (list of strings). Returns a list of `ResponseModel`.
95
+
96
+
## Session tools
95
97
96
98
### `open_session` -- Create a persistent browser session
97
99
98
-
Opens a browser session that stays alive across multiple fetch calls, avoiding the overhead of launching a new browser each time. Returns a `SessionCreatedModel` with `session_id`, `session_type`, `created_at`, `is_alive`, and `message`.
100
+
Opens a browser session that stays alive across multiple `session_fetch` calls, avoiding the overhead of launching a new browser each time. It holds the browser-level configuration only; per-request options are passed to `session_fetch`. Returns a `SessionCreatedModel` with `session_id`, `session_type`, `created_at`, `is_alive`, `settings` (the session's effective configuration for the AI agent; empty for CDP sessions), and `message`.
99
101
100
102
**Key parameters:**
101
103
@@ -104,17 +106,37 @@ Opens a browser session that stays alive across multiple fetch calls, avoiding t
104
106
|`session_type`|`"dynamic"` / `"stealthy"`| required | Type of browser session to create |
105
107
|`session_id`| str or null | null | Custom ID for the session. If omitted, a random 12-char hex ID is generated. Raises if already in use |
106
108
|`headless`| bool | true | Run browser hidden or visible |
107
-
|`max_pages`| int | 5 | Max concurrent browser tabs (1-50) |
108
-
|`proxy`| str or dict or null | null | Proxy for all requests in this session |
109
-
|`timeout`| number | 30000 | Default timeout in ms |
Plus all other browser session parameters (`google_search`, `real_chrome`, `cdp_url`, `locale`, `timezone_id`, `useragent`, `extra_headers`, `cookies`, `disable_resources`, `network_idle`, `wait_selector`, `wait_selector_state`).
113
+
Plus the other browser-level session parameters (`real_chrome`, `cdp_url`, `locale`, `timezone_id`, `useragent`, `cookies`, `executable_path`, `additional_args`). Per-request options (`timeout`, `wait`, `google_search`, `network_idle`, `disable_resources`, `wait_selector`, `wait_selector_state`, `extra_headers`, `proxy`, `solve_cloudflare`) are not set here; pass them to `session_fetch`.
114
+
115
+
One `session_fetch` works with either session type; `solve_cloudflare` only applies to a stealthy session.
116
+
117
+
### `session_fetch` -- Fetch through an open session (single URL)
118
+
119
+
Fetches one URL through a session opened with `open_session` (dynamic or stealthy). The session holds the browser-level configuration; every parameter here applies to this request only.
116
120
117
-
A dynamic session can only be used with `fetch`/`bulk_fetch`. A stealthy session can only be used with `stealthy_fetch`/`bulk_stealthy_fetch`.
|`blocked_domains`| list or null | null | Domain names to block for this request (subdomains matched too) |
138
+
|`proxy`| str or dict or null | null | Proxy for this request |
139
+
|`solve_cloudflare`| bool | false | (Stealthy sessions only) Auto-solve Cloudflare challenges; errors on a dynamic session |
118
140
119
141
### `close_session` -- Close a persistent browser session
120
142
@@ -128,7 +150,7 @@ Returns a `SessionClosedModel` with `session_id` and `message`.
128
150
129
151
### `list_sessions` -- List active sessions
130
152
131
-
Returns a list of `SessionInfo` objects, each with `session_id`, `session_type`, `created_at`, and `is_alive`.
153
+
Returns a list of `SessionInfo` objects, each with `session_id`, `session_type`, `created_at`, `is_alive`, and `settings` (same as `open_session` returns).
132
154
133
155
No parameters.
134
156
@@ -161,7 +183,7 @@ Requires an open browser session. Call `open_session` first, then pass the `sess
161
183
| Multiple JS-rendered pages |`bulk_fetch`|
162
184
| Cloudflare or strong anti-bot protection |`stealthy_fetch` (with `solve_cloudflare=true` for Turnstile) |
| Multiple pages from the same site |`open_session` + `fetch`/`stealthy_fetch` with `session_id`|
186
+
| Multiple pages from the same site |`open_session` + `session_fetch` per page |
165
187
| Need a screenshot of a page |`open_session` + `screenshot` with `session_id`|
166
188
167
189
Start with `get` (fastest, lowest resource cost). Escalate to `fetch` if content requires JS rendering. Escalate to `stealthy_fetch` only if blocked. For multiple pages from the same site, use a persistent session to avoid browser launch overhead.
@@ -253,7 +275,7 @@ The MCP server name when registering with a client is `ScraplingServer`. The com
253
275
254
276
## Connecting to remote browsers
255
277
256
-
`open_session` doesn't have to launch a browser locally. Pass a `cdp_url` and it connects to an already-running browser through the Chrome DevTools Protocol, whether that browser is on the same machine, another host, or a managed browser provider. Both session types (`dynamic` and `stealthy`) accept it, and the `session_id` you get back is used with the fetch and screenshot tools as usual.
278
+
`open_session` doesn't have to launch a browser locally. Pass a `cdp_url` and it connects to an already-running browser through the Chrome DevTools Protocol, whether that browser is on the same machine, another host, or a managed browser provider. Both session types (`dynamic` and `stealthy`) accept it, and the `session_id` you get back is used with `session_fetch`and `screenshot` as usual.
257
279
258
280
The URL can be a WebSocket endpoint (`ws://`/`wss://`), which is what managed browser providers hand out, or the HTTP endpoint of a browser started with `--remote-debugging-port=9222`, reached as `cdp_url="http://localhost:9222"`.
0 commit comments