🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
Python aiai-scrapingautomationcrawlercrawlingcrawling-pythondatadata-extractionmcpmcp-serverplaywrightpythonscrapingselectorsstealthweb-scraperweb-scrapingweb-scraping-pythonwebscrapingxpath
docs(mcp): add section about prompt injection in docs and skill
Karim shoair3ac7f76f9b15
diff --git a/agent-skill/Scrapling-Skill/references/mcp-server.md b/agent-skill/Scrapling-Skill/references/mcp-server.mdindex 1e18a04..0a63642 100644--- a/agent-skill/Scrapling-Skill/references/mcp-server.md+++ b/agent-skill/Scrapling-Skill/references/mcp-server.md@@ -152,6 +152,18 @@ Start with `get` (fastest, lowest resource cost). Escalate to `fetch` if content- `extraction_type="markdown"` (default) is best for readability. Use `"text"` for minimal output, `"html"` when structure matters.- If a `css_selector` matches multiple elements, all are returned in the `content` list.+## Prompt injection protection++When `main_content_only=true` (the default), the server automatically sanitizes scraped content to prevent prompt injection from malicious websites. It strips:++- CSS-hidden elements (`display:none`, `visibility:hidden`, `opacity:0`, `font-size:0`, `height:0`, `width:0`)+- `aria-hidden="true"` elements+- `<template>` tags+- HTML comments+- Zero-width unicode characters++Keep `main_content_only=true` for maximum protection.+## SetupStart the server (stdio transport, used by most MCP clients):diff --git a/docs/ai/mcp-server.md b/docs/ai/mcp-server.mdindex c87b6cf..27156af 100644--- a/docs/ai/mcp-server.md+++ b/docs/ai/mcp-server.md@@ -33,6 +33,7 @@ The Scrapling MCP Server provides nine powerful tools for web scraping:- **Browser Impersonation**: Mimic real browsers with TLS fingerprinting, real browser headers matching that version, and more- **Parallel Processing**: Scrape multiple URLs concurrently for efficiency- **Session Persistence**: Reuse browser sessions across multiple requests for better performance+- **Prompt Injection Protection**: Automatic sanitization of hidden content (CSS-hidden elements, aria-hidden, zero-width characters, HTML comments, template tags) that could be used for prompt injection attacks#### But why use Scrapling MCP Server instead of other available tools?@@ -312,7 +313,18 @@ Here is some technical advice for you.- Use `main_content_only=true` to avoid navigation/ads- Choose an appropriate `extraction_type` for your use case-### 5. Use Sessions for Multiple Requests+### 5. Prompt Injection Protection+The MCP server automatically sanitizes scraped content when `main_content_only` is enabled (the default). This strips hidden content that malicious websites could use to inject instructions into the AI's context:++- **CSS-hidden elements**: `display:none`, `visibility:hidden`, `opacity:0`, `font-size:0`, `height:0`, `width:0`+- **Accessibility-hidden elements**: `aria-hidden="true"`+- **Template tags**: `<template>` elements+- **HTML comments**: `<!-- ... -->`+- **Zero-width characters**: Invisible unicode characters like zero-width spaces++This protection runs automatically on all MCP tool responses. Keep `main_content_only=true` (the default) for maximum protection.++### 6. Use Sessions for Multiple Requests- Use `open_session` to create a persistent browser session when scraping multiple pages- Pass the `session_id` to `fetch` or `stealthy_fetch` calls to reuse the same browser- Always close sessions with `close_session` when done to free resources