Skip to content
MCP server

Safe Fetch

URL-fetching MCP server that blocks SSRF, DNS rebinding and redirects to internal hosts

Runs locally

Safe Fetch is an open-source MCP server for security. It runs locally on your machine and is started by your AI client.

Pricing
Open source
Platforms
CLI, Self-hosted
Runs
Locally
What it can do
Read-only
Version
0.6.1

Similar MCP servers

Install

Add with the CLI

Run in a terminal

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.

Or share it with your project

Add to .mcp.json

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

Claude Code setup guide

Add to claude_desktop_config.json

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

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

Claude Desktop setup guide

Install in CursorOpens Cursor, which asks you to confirm. Or add it by hand:

Add to ~/.cursor/mcp.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.

Cursor setup guide

Install in VS CodeOpens VS Code, which asks you to confirm. Or add it by hand:

Add to ~/.copilot/mcp-config.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.

VS Code setup guide

Add with the CLI

Run in a terminal

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

Or add to config.toml

Add to ~/.codex/config.toml

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

Codex setup guide

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "safe-fetch": {
      "command": "npx",
      "args": [
        "-y",
        "safe-fetch-mcp-server"
      ]
    }
  }
}
  • Gemini CLI and Antigravity

    Gemini CLI

    Add to ~/.gemini/settings.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

    Antigravity

    Add to ~/.gemini/config/mcp_config.json

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

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

    Gemini CLI and Antigravity setup guide

  • Devin Desktop (formerly Windsurf)

    Add to ~/.config/devin/mcp_config.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.

    Devin Desktop setup guide

  • Cline

    Add to cline_mcp_settings.json

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

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

    Cline setup guide

  • Zed

    Add to Zed settings.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.

    Zed setup guide

  • JetBrains AI Assistant and Junie

    AI Assistant

    Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add

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

    Junie

    Add to ~/.junie/mcp/mcp.json

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

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

    JetBrains AI Assistant and Junie setup guide

  • Kiro

    Add to ~/.kiro/settings/mcp.json

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

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

    Kiro setup guide

Using several servers? Build one config file with the MCP config generator.

About Safe Fetch

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.

Tools this server provides (2)

Taken from the project documentation; the running server may differ.

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_urlName suggests: reads
Fetches an http(s) URL through the SSRF guard and returns markdown or raw text.
fetchName suggests: reads
Compatibility tool with the reference fetch server's arguments, enabled with --compat.

What it does

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

Pricing

Open source

Safe Fetch 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.

How AIPoweredBot checks servers