# Safe Fetch

> Safe Fetch is an open-source MCP server for security. URL-fetching MCP server that blocks SSRF, DNS rebinding and redirects to internal hosts. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, Self-hosted
- **Repository:** https://github.com/sanoy24/safe-fetch-mcp-server
- **MCP Registry name:** io.github.Sanoy24/safe-fetch
- **Categories:** [security](https://ai-powered.com/categories/security), [web search and scraping](https://ai-powered.com/categories/web-search-and-scraping)
- **Listing updated:** 2026-11-23

## About

Fetching pages for an agent normally means trusting that agent not to reach your internal network. This server resolves each hostname once, checks the resolved IP against explicit ranges, pins the connection to that address and re-checks on every redirect. Private, loopback and cloud-metadata destinations are refused, and so are non-http schemes such as file:. The README ties each defence to a regression test for edge cases like IPv4-mapped loopback.

Pages come back as markdown by default, wrapped in markers that tell the calling agent the text is untrusted data rather than instructions. It honours robots.txt for tool calls, with a flag to ignore it, and an allowlist setting limits which hosts can be fetched.

For teams using the reference mcp-server-fetch, a `--compat` flag adds a `fetch` tool with the same arguments (url, max_length, start_index, raw) so prompts keep working. Node.js 22 or newer is required, and a Streamable HTTP mode is available for clients that need a URL.

## Features

- **SSRF guard:** Validates the resolved IP and pins the connection to it.
- **Redirect re-validation:** Every redirect hop is checked again before it is followed.
- **Untrusted-content framing:** Fetched text is wrapped in markers marking it as data, not instructions.
- **Compatibility mode:** `--compat` adds a drop-in `fetch` tool matching the reference server.
- **Host allowlist:** SAFE_FETCH_ALLOWLIST restricts fetching to named domains.
- **Structured results:** Returns status, final URL, paging offsets and error codes.

## Good for

- Give a coding agent web access without exposing cloud metadata endpoints
- Replace the reference fetch server in an existing agent setup
- Restrict an agent to documentation sites through an allowlist
- Test how an agent handles refused internal URLs

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add safe-fetch -- npx -y safe-fetch-mcp-server
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add safe-fetch -- npx -y safe-fetch-mcp-server
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.safe-fetch]
command = "npx"
args = ["-y", "safe-fetch-mcp-server"]
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Or run: gemini mcp add -s user safe-fetch npx -- -y safe-fetch-mcp-server

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
```

## Tools

From the tool list in its README, going by the names, all 2 tools only read data. From the server's own tool labels and tool names; not verified by us.

- `fetch_url` (name suggests: reads): Fetches an http(s) URL through the SSRF guard and returns markdown or raw text.
- `fetch` (name suggests: reads): Compatibility tool with the reference fetch server's arguments, enabled with --compat.

## FAQ

### How do I check Safe Fetch blocks internal addresses?

Ask your agent to fetch http://169.254.169.254/latest/meta-data/; it should be refused with POLICY_REJECTED.

### What does Safe Fetch need to run?

Node.js 22 or newer, started through npx with no further configuration.

### Can I use Safe Fetch in place of mcp-server-fetch?

Yes, add the --compat flag to get a fetch tool with the same arguments.

### Which output formats are there?

Markdown by default, or raw text as-is.

### Is Safe Fetch free?

Yes. Safe Fetch is open source, so you can use and self-host it for free.

### How do I add Safe Fetch to Claude Code?

Run this command in your terminal: claude mcp add safe-fetch -- npx -y safe-fetch-mcp-server

### What are the best alternatives to Safe Fetch?

The closest alternatives to Safe Fetch are REA, Scrapling MCP Server, Firecrawl MCP Server, Douyin_TikTok_Download_API and AiSOC.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Scrapling MCP Server](https://ai-powered.com/mcp/scrapling-mcp-server): Scrapling MCP Server is an open-source MCP server for web search and scraping.
- [Firecrawl MCP Server](https://ai-powered.com/mcp/firecrawl-mcp-server): Firecrawl MCP Server is a freemium MCP server for web search and scraping.
- [Douyin_TikTok_Download_API](https://ai-powered.com/mcp/douyin-tiktok-download-api): Douyin_TikTok_Download_API is an open-source MCP server for web search and scraping.
- [AiSOC](https://ai-powered.com/mcp/aisoc): AiSOC is an open-source MCP server for ai models and llm tooling.
- [SearXNG Search](https://ai-powered.com/mcp/searxng-search): SearXNG Search is an open-source MCP server for web search and scraping.
- [x64dbg-mcp-server](https://ai-powered.com/mcp/x64dbg-mcp-server): x64dbg-mcp-server is an open-source MCP server for ai models and llm tooling.
- [redamon](https://ai-powered.com/mcp/redamon): redamon is an open-source MCP server for ai models and llm tooling.

---
Source: https://ai-powered.com/mcp/safe-fetch
