Safe Fetch
URL-fetching MCP server that blocks SSRF, DNS rebinding and redirects to internal hosts
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-serverAdd --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"
]
}
}
}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.
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.
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.
Add with the CLI
Run in a terminal
codex mcp add safe-fetch -- npx -y safe-fetch-mcp-serverOr add to config.toml
Add to ~/.codex/config.toml
[mcp_servers.safe-fetch]
command = "npx"
args = ["-y", "safe-fetch-mcp-server"]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.
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.
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.
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.
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.
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.
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.



