# webfetch-mcp ![Python](https://img.shields.io/badge/python-3.10%2B-blue) ![License](https://img.shields.io/badge/license-MIT-green) ![MCP](https://img.shields.io/badge/MCP-compatible-purple) [![simonediroma/webfetch_mcp MCP server](https://glama.ai/mcp/servers/simonediroma/webfetch_mcp/badges/score.svg)](https://glama.ai/mcp/servers/simonediroma/webfetch_mcp) A local Python MCP server that replaces your AI assistant's built-in `WebFetch` tool with a fully configurable HTTP client — supporting **domain-scoped headers, retries, proxies, timeouts, output formats, bot-block detection, and prompt-injection sanitization**, all without touching a single line of your assistant's config beyond registering the server. ## Why The built-in `WebFetch` tool available in most AI assistants (Claude Code, Cursor, Continue, Zed, etc.) sends requests without custom headers, which means it gets blocked by bot-protection systems (Akamai, Cloudflare, paywalls, etc.) and can't authenticate against APIs that require domain-specific tokens. This server is a drop-in replacement: it exposes the same `fetch` tool to any MCP-compatible AI assistant, but enriches every outbound request with the right headers, format, and retry strategy based on the target domain — automatically, without you having to configure headers every time. --- ## Features | Feature | Description | |---------|-------------| | **Domain-scoped headers** | Different auth headers per domain; global `*` fallback | | **Per-call headers** | The client (or you) can inject extra headers for a single request | | **YAML config** | Single readable file controls headers, timeouts, retries, proxies, and output formats | | **Configurable timeout** | Per-domain request timeout (default 30 s) | | **Retry with backoff** | Auto-retry on HTTP 5xx or network errors, with exponential backoff | | **Per-domain proxy** | Route traffic through a different proxy per domain | | **Output formats** | `raw`, `markdown`, `trafilatura` (main content), `json` (pretty-print), `lighthtml` (minimal HTML) | | **JSON auto-detection** | Responses with `application/json` Content-Type are pretty-printed automatically | | **Metadata extraction** | Extracts title, author, date, source via trafilatura (opt-in per domain) | | **Bot-block detection** | Detects Cloudflare / CAPTCHA blocks; optionally retries with a Chrome User-Agent | | **Prompt-injection sanitization** | Scans fetched content for injection patterns; `flag` or `strip` mode | | **CSS selector extraction** | Extract specific HTML elements before format conversion, configurable per domain or per call | | **Redirect tracing** | Optionally record and display the full redirect chain in the summary | | **Response assertions** | `assert_status` / `assert_contains` raise an error on mismatch — useful for CI/CD smoke tests | | **Header injection protection** | Validates headers for control characters (`\r`, `\n`, NUL) | | **Response truncation** | `max_bytes` cap to avoid filling the assistant's context window | | **Detailed response summary** | Every response includes a structured summary (status, elapsed ms, injected headers, format, etc.) | | **JS rendering (Playwright)** | Render JavaScript-heavy SPAs with headless Chromium before extracting content; configurable globally, per-domain, or per-call | | **lighthtml output format** | Strips `