MCP server for fetching URLs, safe against SSRF, DNS rebinding, and redirect-to-internal attacks.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
An MCP server that fetches web content for an agent and is correct and secure
where the popular fetch servers are not. Not "has SSRF protection" β everyone
claims that β but provably correct against the edge cases that produced real
2026 CVEs in other fetch servers, verified against the OWASP MCP Top 10 and an
independent scanner. See SECURITY.md for the full evidence trail.
::ffff:127.0.0.1), a poller that
re-fetches a URL through a different code path than the one that was guarded.That's the stdio config (default, for local single-user MCP clients like Claude Desktop). No build step, no config required β safe by default.
A normal public URL just works and comes back as clean markdown, framed as untrusted data (not instructions) for the calling agent:
Every outbound request β including every redirect hop β goes through the exact
same pipeline in src/security/. There is deliberately no second fetch path;
that exact gap (a guard applied on first load but skipped by a recurring
poller) was a real 2026 CVE.
urlPolicy enforces the scheme allowlist (http/https only) and
rejects embedded userinfo (user:pass@host).resolveAndPin resolves the hostname once, validates every resolved
IP against explicit blocked ranges, then pins the connection to that exact
IP β this is what defeats DNS rebinding.Location header, from
scratch, through the same code path as the original request β not a
separate one.| Attack | Defense |
|---|---|
Cloud metadata (169.254.169.254) | Blocked on resolved IP, never bypassable via SAFE_FETCH_ALLOW_LOCAL |
| Private ranges (RFC-1918) | Blocked on resolved IP; bypassable via SAFE_FETCH_ALLOW_LOCAL for trusted local dev |
Loopback (127.0.0.1, 127.x.x.x, ::1) | Blocked on resolved IP after normalization |
IPv4-mapped IPv6 (::ffff:127.0.0.1) | IPv6 unwrapped, embedded IPv4 re-checked |
IPv6 ULA / link-local (fc00::/7, fe80::/10) | Blocked on resolved IP |
| Encoded IPs (octal/hex/decimal/dotless) | Not string-parsed β validated post-resolution, on the canonical IP |
| DNS rebinding | Resolved once; connection pinned to that exact IP via a custom DNS lookup hook |
| Redirect-to-internal | Every hop re-runs the full guard from scratch |
Non-http(s) schemes (file:, gopher:, ...) | Scheme allowlist |
| Credentials in URL | Userinfo rejected outright |
| Resource exhaustion | Byte cap + connect/idle/total timeouts |
Full matrix, control flow, and rationale:
.claude/skills/secure-fetch-ssrf/SKILL.md.
| Env var | Default | Meaning |
|---|---|---|
SAFE_FETCH_ALLOW_LOCAL | false | Allow loopback/RFC-1918 targets (never allows metadata/link-local) |
SAFE_FETCH_ALLOWLIST | (empty) | Comma-separated host allowlist |
SAFE_FETCH_MAX_BYTES | 5000000 | Response size cap |
SAFE_FETCH_TIMEOUT_MS | 10000 | Request timeout |
SAFE_FETCH_MAX_REDIRECTS | 5 | Redirect hop limit |
TRANSPORT / --http flag | stdio | Switch to Streamable HTTP |
HOST | 127.0.0.1 | HTTP bind address |
PORT | 3000 | HTTP port |
SAFE_FETCH_ALLOWED_ORIGINS | (empty) | Comma-separated Origin allowlist (CORS) for HTTP mode |
SAFE_FETCH_RATE_LIMIT_MAX | 60 | Requests per window, per IP (HTTP mode) |
SAFE_FETCH_RATE_LIMIT_WINDOW_MS | 60000 | Rate-limit window |
See CLAUDE.md for the full contributor contract (the one rule
that matters most: every outbound request goes through the single security
guard β no exceptions).
See SECURITY.md for the full OWASP MCP Top 10 mapping and
external scanner validation (13 findings β 2, zero critical/high remaining,
via agent-audit-kit).
MIT β see LICENSE.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/safe-fetch)<a href="https://allmcps.com/mcp/safe-fetch"><img src="https://allmcps.com/api/badge/safe-fetch?style=directory" alt="Safe Fetch on AllMCPs" /></a>