Fetch the public web in agent-ready formats.
A lightweight, agent-friendly MCP server (mcp-fetch-server) and local CLI
(mcp-fetch) for HTML, Markdown, Readability articles, plain text, JSON, and YouTube
transcripts—with custom headers, HTTP/SOCKS proxies, pagination, and built-in SSRF protection. Supports
Node.js >= 22 LTS and Bun.
Quickstart
Run mcp-fetch-server over stdio or stateless MCP 2025-11-25
Streamable HTTP, or run the same fetcher directly from your shell via mcp-fetch.
{
"mcpServers": {
"fetch": {
"command": "npx",
"args": ["mcp-fetch-server"]
}
}
}
# Start stateless MCP 2025-11-25 Streamable HTTP on http://127.0.0.1:3000/mcp
npx mcp-fetch-server --http --host 127.0.0.1 --port 3000
# Run directly with npx or install globally with: npm install -g mcp-fetch-server
npx -p mcp-fetch-server mcp-fetch readable https://example.com
npx -p mcp-fetch-server mcp-fetch transcript 'https://www.youtube.com/watch?v=jNQXAC9IVRw' --lang en
MCP Clients
Works out of the box with Claude, Gemini, OpenAI, Cursor, and MCP Inspector.
{
"mcpServers": {
"fetch": {
"command": "npx",
"args": ["mcp-fetch-server"],
"env": {
"DEFAULT_LIMIT": "50000",
"MAX_RESPONSE_BYTES": "10485760",
"HTTPS_PROXY": "socks5://127.0.0.1:1080"
}
}
}
}
# Terminal 1 — launch Streamable HTTP server
npx mcp-fetch-server --http --port 3000
# Terminal 2 — connect with stock MCP Inspector
npx @modelcontextprotocol/inspector --url http://127.0.0.1:3000/mcp
# Register Fetch MCP in Claude Code
claude mcp add fetch -- npx mcp-fetch-server
MCP Tools & Formats
Six read-only tools for pulling public URLs in the exact format your agent needs.
# <title> when present.
markdown
<script> and <style> elements, and
converts the document to Markdown via Turndown.
markdown
<script>, <style>, and HTML tags, returning whitespace-normalized
plain text.
text/plain
JSON.parse, and returns compact JSON (failing
explicitly on invalid JSON).
json
yt-dlp with manual & auto-generated subtitles
first, falling back to direct watch-page + XML extraction). Accepts optional lang (default
"en") and lists available codes when missing.
transcript
Common Tool Parameters
http: or https: URL to fetch.
string · req
Record<string, string>); CR/LF and invalid header
characters are rejected.
object · opt
DEFAULT_LIMIT / 5000;
0 = unlimited). Returns sliced text only with no footer.
number · opt
0; returns
"" if at or past output length).
number · opt
fetch_transcript only. Caption language code (default "en"; matches exact
code first, then regional prefix like en → en-US).
string · opt
Local CLI
Use mcp-fetch <command> <url> [flags] directly from terminals or scripts. Subcommands
mirror the MCP tools: html, markdown, readable, text,
json, and transcript. Errors write to stderr and exit
1.
0 = unlimited).
all commands
http, https, socks4,
socks4a, socks5, socks5h, or host:port; bypasses
NO_PROXY).
CLI only
en). Rejected with a validation error on non-transcript
subcommands.
transcript
2.0.1).
meta
# Extract readable article Markdown without boilerplate
mcp-fetch readable https://example.com/blog/post
# Fetch YouTube transcript (quote URLs containing '?' in zsh)
mcp-fetch transcript 'https://www.youtube.com/watch?v=jNQXAC9IVRw' --lang en
# Pass custom headers and window bounds
mcp-fetch html https://example.com --header "Accept-Language: en-US" --max-length 10000
# Route through a SOCKS5 proxy
mcp-fetch json https://api.example.com/data --proxy socks5://127.0.0.1:1080
Streamable HTTP
Launch mcp-fetch-server --http to expose stateless MCP 2025-11-25 Streamable HTTP
on POST /mcp. Requests validate both Host and Origin headers against
the bound address (returning 403 on mismatch). Unknown paths (including legacy /sse)
return 404, and non-POST methods return 405.
stdio.
default: off
--http).
127.0.0.1
1–65535 (requires --http).
3000
Proxies & Operator Limits
mcp-fetch-server parses DEFAULT_LIMIT and MAX_RESPONSE_BYTES at
startup and exits 1 immediately if invalid. Proxy routing is re-evaluated on every redirect hop
and supports HTTP, HTTPS, SOCKS4/4a/5/5h, and bare host:port.
0 = unlimited; fails
explicitly if invalid).
5000
yt-dlp subtitle files).
10 MB
https:// targets (HTTPS_PROXY → https_proxy →
HTTP_PROXY → http_proxy → ALL_PROXY →
all_proxy).
https:
http:// targets and fallback for all HTTP(S) traffic (including
yt-dlp --proxy).
http/all
.domain / *.domain suffixes, :port entries,
[ipv6]:port, or * bypassing Operator env proxies (non-empty
NO_PROXY takes precedence).
bypass
SSRF & Security Model
Fail-closed by default.
Every request, redirect hop, DNS lookup, decompression stream, and MCP tool call fails closed—blocked IPs, invalid limits, bad proxies, and unexpected arguments error explicitly instead of falling back.
http:/https:; blocks
localhost, *.localhost, and all IANA-reserved IPv4/IPv6 ranges (including
IPv4-mapped IPv6 and multicast).
fail-closed
lang strictly, passes
-- end-of-options sentinel to yt-dlp, and never swallows SSRF/validation
errors into fallback.
allowlist
Authorization, Cookie, and Proxy-Authorization across
cross-origin redirects and cross-origin YouTube caption track URLs; rejects CR/LF injection.
cross-origin
MAX_RESPONSE_BYTES across declared Content-Length, raw wire bytes,
decompressed gzip/deflate/br streams, and yt-dlp
files; rejects binary Content-Types; 30s single-attempt timeout.
10 MB / 30s
stderr, MCP
tool results, and recorded test cassettes.
redacted
v2.0 Migration Guide
Version 2.0.0 is a clean breaking release aligning tool names, CLI flags, MCP
2025-11-25 compliance, and explicit error semantics.
fetch_txt → fetch_text; fetch_youtube_transcript →
fetch_transcript.
renamed
txt → text; youtube → transcript. Added repeatable
--header; --lang is now rejected on non-transcript commands.
renamed
proxy) return
isError: true instead of being ignored.
strict
DEFAULT_LIMIT, MAX_RESPONSE_BYTES, or proxy URLs fail fast instead of
silently falling back; missing YouTube caption languages fail listing available codes.
explicit
>= 22 LTS or Bun (Node 18 & 20 are EOL).
Node 22+
More Projects
Other MCP servers and agent-friendly command-line tools I build and maintain.