Fetch Guard MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add fetch-guard -- uvx fetch-guard
README.md

Fetch URLs and return clean, LLM-ready markdown with prompt injection defense.

Fetch Guard

An MCP server and CLI tool that fetches URLs and returns clean, LLM-ready markdown. A purpose-built extraction pipeline sanitizes HTML, pulls structured metadata, detects prompt injection attempts, and handles the edge cases that break naive fetchers: bot blocks, paywalls, login walls, non-HTML content types, and pages that require JavaScript to render.

The core problem is straightforward: LLMs need web content, but raw HTML is noisy and potentially hostile. Fetched pages can contain hidden text, invisible Unicode, off-screen elements, and outright prompt injection attempts embedded in the content itself. This pipeline strips all of that before the content reaches the model.

Three layers handle the injection defense specifically:

  1. Pre-extraction sanitization removes hidden elements (display:none, visibility:hidden, opacity:0, font-size:0, transform:scale(0), clip:rect(0,0,0,0), zero-height overflow containers, and elements with matching foreground and background colors), elements hidden via CSS class/ID rules in <style> tags, off-screen positioned content, aria-hidden elements, <noscript> and <template> tags, and 26 categories of non-printing Unicode characters including bidi isolates and Unicode Tags. This happens before content extraction, so trafilatura never sees the attack vectors.
  2. Pattern scanning runs a four-phase scan against the extracted text and metadata fields. Phase one applies 50 compiled regex patterns covering system prompt overrides, ignore-previous instructions, role injection, fake conversation tags, and hidden instruction markers, in English, Spanish, French, German, Japanese, Simplified Chinese, and Portuguese. Phase two normalizes the text via NFKC and confusable-character mapping, then rescans to catch homoglyph bypasses (Cyrillic or mathematical Unicode characters substituted for Latin, etc.). Phase three finds base64, hex-encoded, and URL percent-encoded blocks, decodes them, and scans against high-severity patterns. Phase four decodes the full document with ROT13 and scans against high-severity patterns. Metadata fields (title, description, og:title, etc.) are scanned independently with matches namespaced to their source field.
  3. Session-salted output wrapping generates a random 8-character hex salt per invocation and wraps the body in <fetch-content-{salt}> tags. Since the salt is unpredictable, injected content cannot spoof the wrapper boundaries.

One Tool

This is a single-tool MCP server. It exposes one tool — fetch — that runs a full extraction pipeline behind a consistent interface. No tool selection, no routing, no multi-step workflows. One URL in, one structured result out, configurable via parameters.

Quick Start

Prerequisites

  • Python 3.10+
  • pip

Install

pip install fetch-guard

For JavaScript rendering (optional):

pip install 'fetch-guard[js]' && playwright install chromium

Configure Your MCP Client

Add the following to your MCP client config. Works with Claude Code, Claude Desktop, Cursor, or any MCP-compatible client.

Via uvx (recommended):

{
  "mcpServers": {
    "fetch-guard": {
      "command": "uvx",
      "args": ["fetch-guard"]
    }
  }
}

Via pip install:

{
  "mcpServers": {
    "fetch-guard": {
      "command": "fetch-guard"
    }
  }
}

From source:

{
  "mcpServers": {
    "fetch-guard": {
      "command": "python",
      "args": ["-m", "fetch_guard.server"]
    }
  }
}

Via Docker:

{
  "mcpServers": {
    "fetch-guard": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "sterlsnyc/fetch-guard"]
    }
  }
}

Note: The Docker image does not include Playwright. JavaScript rendering (js: true) is not available when running via Docker. Use the uvx or pip install if you need JS rendering.

Verify

Ask your AI assistant to fetch any URL. If it returns structured content with a status header, metadata, and risk assessment, you're connected.

CLI

fetch-guard-cli <url> [options]
# or: python -m fetch_guard.cli <url> [options]
Flag Default Description
--timeout N 180 Request timeout in seconds
--max-words N none Word cap on extracted body content. Also disables th

Tools (1)

fetchFetches a URL and returns clean, LLM-ready markdown with metadata and security sanitization.

Configuration

claude_desktop_config.json
{"mcpServers": {"fetch-guard": {"command": "uvx", "args": ["fetch-guard"]}}}

Try it

Fetch the content of https://example.com and summarize it for me.
Can you scrape the article at https://news.ycombinator.com/item?id=12345 and extract the main points?
Fetch the documentation page at https://docs.example.com/api using JavaScript rendering to ensure all content is captured.
Retrieve the content from this URL and ensure it is sanitized for prompt injection risks.

Frequently Asked Questions

What are the key features of Fetch Guard?

Pre-extraction sanitization of hidden elements and non-printing Unicode characters. Multi-phase pattern scanning to detect and block prompt injection attempts. Session-salted output wrapping to prevent boundary spoofing. Support for JavaScript rendering via Playwright. Configurable timeouts and word limits for extracted content.

What can I use Fetch Guard for?

Safely ingesting web content into LLMs without risk of prompt injection. Converting complex or noisy web pages into clean, structured markdown. Automating research tasks by scraping and summarizing multiple URLs. Extracting metadata and content from sites that require JavaScript to render.

How do I install Fetch Guard?

Install Fetch Guard by running: uvx fetch-guard

What MCP clients work with Fetch Guard?

Fetch Guard works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Fetch Guard docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare