MCP Hub
Back to servers

Fetch URL MCP Server

Intelligent web content fetcher MCP server that converts HTML to clean, AI-readable Markdown

Updated
Feb 11, 2026

Quick Install

npx -y @j0hanz/fetch-url-mcp

Fetch URL MCP Server

npm version License: MIT Node.js TypeScript MCP SDK

Install in VS Code Install in VS Code Insiders Install in Cursor

Fetch public web pages and convert them into clean, AI-readable Markdown.

Overview

Fetch URL is a Model Context Protocol (MCP) server that fetches public web pages, extracts meaningful content using Mozilla's Readability algorithm, and converts the result into clean Markdown optimized for LLM context windows. It handles noise removal, caching, SSRF protection, async task execution, and supports both stdio and Streamable HTTP transports.

[!NOTE] Content extraction quality varies depending on the HTML structure and complexity of the source page. Fetch URL works best with standard article and documentation layouts. Pages relying on client-side JavaScript rendering may yield incomplete results.

Key Features

  • HTML to Markdown — Content extraction via Mozilla Readability + node-html-markdown
  • Noise removal — Strips navigation, ads, cookie banners, and other non-content elements
  • In-memory LRU cache — Faster repeat fetches with configurable TTL (24 h default)
  • Raw URL rewriting — Auto-converts GitHub, GitLab, Bitbucket, and Gist URLs to raw content endpoints

Tech Stack

ComponentTechnology
RuntimeNode.js >= 24
LanguageTypeScript 5.9
MCP SDK@modelcontextprotocol/sdk ^1.26.0
Content Extraction@mozilla/readability ^0.6.0
DOM Parsinglinkedom ^0.18.12
Markdown Conversionnode-html-markdown ^2.0.0
Schema Validationzod ^4.3.6
Package Managernpm

Architecture

URL → Validate → DNS Preflight → HTTP Fetch → Decompress
  → Truncate HTML → Readability Extract → Noise Removal
  → Markdown Convert → Cleanup Pipeline → Cache → Response
  1. URL Validation — Normalize, block private hosts, transform raw-content URLs (GitHub, GitLab, Bitbucket)
  2. Fetch — HTTP request with redirect following, DNS preflight SSRF checks, and size limits (10 MB)
  3. Transform — Offloaded to worker threads: parse HTML with linkedom, extract with Readability, remove DOM noise, convert to Markdown
  4. Cleanup — Multi-pass Markdown normalization (heading promotion, spacing, skip-link removal)
  5. Cache + Respond — Store result in LRU cache, apply inline content limits, return structured content

Repository Structure

fetch-url-mcp/
├── assets/              # Server icon (logo.svg)
├── scripts/             # Build & test orchestration
├── src/
│   ├── workers/         # Worker-thread child for HTML transforms
│   ├── index.ts         # CLI entrypoint, transport wiring, shutdown
│   ├── server.ts        # McpServer lifecycle and registration
│   ├── tools.ts         # fetch-url tool definition and pipeline
│   ├── fetch.ts         # URL normalization, SSRF, HTTP fetch
│   ├── transform.ts     # HTML-to-Markdown pipeline, worker pool
│   ├── config.ts        # Env-driven configuration
│   ├── resources.ts     # MCP resource/template registration
│   ├── prompts.ts       # MCP prompt registration (get-help)
│   ├── mcp.ts           # Task execution management
│   ├── http-native.ts   # Streamable HTTP server, auth, sessions
│   └── instructions.md  # Server instructions embedded at runtime
├── tests/               # Unit/integration tests (Node.js test runner)
├── package.json
├── tsconfig.json
└── AGENTS.md

Requirements

  • Node.js >= 24

Quickstart

npx -y @j0hanz/fetch-url-mcp@latest --stdio

Add to your MCP client configuration:

{
  "mcpServers": {
    "fetch-url-mcp": {
      "command": "npx",
      "args": ["-y", "@j0hanz/fetch-url-mcp@latest", "--stdio"]
    }
  }
}

Installation

NPX (Recommended)

No installation required — runs directly:

npx -y @j0hanz/fetch-url-mcp@latest --stdio

Global Install

npm install -g @j0hanz/fetch-url-mcp
fetch-url-mcp --stdio

From Source

git clone https://github.com/j0hanz/fetch-url-mcp.git
cd fetch-url-mcp
npm install
npm run build
node dist/index.js --stdio

Docker

docker compose up --build

Configuration

Runtime Modes

FlagDescription
--stdio, -sRun in stdio mode (for desktop MCP clients)
--help, -hShow usage help
--version, -vPrint server version

When no --stdio flag is passed, the server starts in HTTP mode (Streamable HTTP on port 3000 by default).

Environment Variables

Core Settings

VariableDefaultDescription
HOST127.0.0.1HTTP server bind address
PORT3000HTTP server port (1024–65535)
LOG_LEVELinfoLog level: debug, info, warn, error
FETCH_TIMEOUT_MS15000HTTP fetch timeout in ms (1000–60000)
CACHE_ENABLEDtrueEnable/disable in-memory content cache
USER_AGENTfetch-url-mcp/{version}Custom User-Agent header
ALLOW_REMOTEfalseAllow remote connections in HTTP mode
ALLOWED_HOSTS(empty)Comma-separated host/origin allowlist for HTTP mode

Task Management

VariableDefaultDescription
TASKS_MAX_TOTAL5000Maximum retained task records across all owners
TASKS_MAX_PER_OWNER1000Maximum retained task records per session/client

Authentication (HTTP Mode)

VariableDefaultDescription
ACCESS_TOKENS(empty)Comma-separated static bearer tokens
API_KEY(empty)Single API key (added to static tokens)
OAUTH_ISSUER_URL(empty)OAuth issuer URL (enables OAuth mode)
OAUTH_AUTHORIZATION_URL(empty)OAuth authorization endpoint
OAUTH_TOKEN_URL(empty)OAuth token endpoint
OAUTH_INTROSPECTION_URL(empty)OAuth token introspection endpoint
OAUTH_REVOCATION_URL(empty)OAuth token revocation endpoint
OAUTH_REGISTRATION_URL(empty)OAuth dynamic client registration
OAUTH_REQUIRED_SCOPES(empty)Required OAuth scopes
OAUTH_CLIENT_ID(empty)OAuth client ID
OAUTH_CLIENT_SECRET(empty)OAuth client secret

Transform & Workers

VariableDefaultDescription
TRANSFORM_WORKER_MODEthreadsWorker mode: threads or process
TRANSFORM_WORKER_MAX_OLD_GENERATION_MB(unset)V8 old generation heap limit per worker
TRANSFORM_WORKER_MAX_YOUNG_GENERATION_MB(unset)V8 young generation heap limit per worker
TRANSFORM_WORKER_CODE_RANGE_MB(unset)V8 code range limit per worker
TRANSFORM_WORKER_STACK_MB(unset)Stack size limit per worker

Content Tuning

VariableDefaultDescription
MAX_INLINE_CONTENT_CHARS0Global inline markdown limit (0 = unlimited)
FETCH_URL_MCP_EXTRA_NOISE_TOKENS(empty)Additional CSS class/id tokens for noise removal
FETCH_URL_MCP_EXTRA_NOISE_SELECTORS(empty)Additional CSS selectors for noise removal
MARKDOWN_HEADING_KEYWORDS(built-in list)Keywords triggering heading promotion
FETCH_URL_MCP_LOCALE(system)Locale for content processing

Server Tuning

VariableDefaultDescription
SERVER_MAX_CONNECTIONS0 (unlimited)Maximum concurrent HTTP connections
SERVER_BLOCK_PRIVATE_CONNECTIONSfalseBlock connections from private IP ranges

Hardcoded Defaults

SettingValue
Max HTML size10 MB
Max inline content chars0 (unlimited, configurable)
Fetch timeout15 s
Transform timeout30 s
Tool timeoutFetch + Transform + 5 s padding
Max redirects5
Cache TTL86400 s (24 h)
Cache max keys100
Rate limit100 requests / 60 s
Max sessions200
Session TTL30 min
Max URL length2048 chars
Worker pool max scale4

Usage

Stdio Mode

fetch-url-mcp --stdio

The server communicates via JSON-RPC over stdin/stdout. All MCP clients that support stdio transport can connect directly.

HTTP Mode

fetch-url-mcp
# or
PORT=8080 HOST=0.0.0.0 ALLOW_REMOTE=true fetch-url-mcp

The server starts a Streamable HTTP endpoint at /mcp. Authenticate with bearer tokens via the ACCESS_TOKENS or API_KEY environment variables.

For POST /mcp, clients should send:

  • Accept: application/json, text/event-stream
  • MCP-Protocol-Version: 2025-11-25 (or 2025-03-26 for legacy clients)

MCP Surface

Tools

fetch-url

Fetches a webpage and converts it to clean Markdown format optimized for LLM context.

Useful for:

  • Reading documentation, blog posts, or articles
  • Extracting main content while removing navigation and ads
  • Caching content to speed up repeated queries

Limitations:

  • Does not execute complex client-side JavaScript interactions
  • Inline output may be truncated when MAX_INLINE_CONTENT_CHARS is set
Parameters
ParameterTypeRequiredDefaultDescription
urlstring (URL)YesThe URL of the webpage to fetch (http/https, max 2048 chars)
skipNoiseRemovalbooleanNofalsePreserve navigation, footers, and other elements normally filtered
forceRefreshbooleanNofalseBypass cache and fetch fresh content
maxInlineCharsnumberNo0Per-call inline markdown limit (0 = unlimited; global cap still applies)
Returns
{
  "url": "https://example.com",
  "inputUrl": "https://example.com",
  "resolvedUrl": "https://example.com",
  "finalUrl": "https://example.com",
  "title": "Example Domain",
  "metadata": {
    "title": "Example Domain",
    "description": "...",
    "author": "...",
    "image": "...",
    "favicon": "...",
    "publishedAt": "...",
    "modifiedAt": "..."
  },
  "markdown": "# Example Domain\n\nThis domain is for use in illustrative examples...",
  "fromCache": false,
  "fetchedAt": "2026-02-11T12:00:00.000Z",
  "contentSize": 1234,
  "truncated": false
}
FieldTypeDescription
urlstringThe canonical URL (pre-raw-transform)
inputUrlstring?The original URL provided by the caller
resolvedUrlstring?The normalized/transformed URL that was fetched
finalUrlstring?Final response URL after redirects
titlestring?Extracted page title
metadataobject?Extracted metadata (title, description, author, image, favicon, publishedAt, modifiedAt)
markdownstring?Extracted content in Markdown format
fromCacheboolean?Whether the response was served from cache
fetchedAtstring?ISO timestamp for fetch/cache retrieval
contentSizenumber?Full markdown size before inline truncation
truncatedboolean?Whether inline markdown was truncated
errorstring?Error message if the request failed
statusCodenumber?HTTP status code for failed requests
detailsobject?Additional error details
Annotations
AnnotationValue
readOnlyHinttrue
destructiveHintfalse
idempotentHinttrue
openWorldHinttrue
Async Task Execution

The fetch-url tool supports optional async task execution (execution.taskSupport: "optional"). Include a task field in the tool call to run the fetch in the background:

{
  "method": "tools/call",
  "params": {
    "name": "fetch-url",
    "arguments": { "url": "https://example.com" },
    "task": { "ttl": 30000 }
  }
}

Then poll tasks/get until the task status is completed or failed, and retrieve the result via tasks/result.

Prompts

NameDescription
get-helpReturns server usage instructions

Resources

URI PatternMIME TypeDescription
internal://instructionstext/markdownServer instructions and usage guidance
internal://cache/{namespace}/{hash}text/markdownCached markdown entries from prior fetch-url calls

Tasks

The server declares full MCP task support:

EndpointDescription
tasks/listList tasks (scoped to session/owner)
tasks/getGet task status by ID
tasks/resultRetrieve completed task result
tasks/cancelCancel an in-flight task

HTTP Mode Endpoints

MethodPathAuthDescription
GET/healthNoHealth check (minimal payload)
GET/health?verbose=trueYes*Detailed diagnostics and runtime metrics
POST/mcpYesMCP JSON-RPC (Streamable HTTP)
GET/mcpYesSSE stream for server-initiated messages
DELETE/mcpYesTerminate MCP session
GET/mcp/downloads/{namespace}/{hash}YesDownload cached content

* verbose=true can be read without auth only for local-only deployments (ALLOW_REMOTE=false).

Session Behavior

  • Sessions are created on the first POST /mcp request with an initialize message
  • Session ID is returned in the mcp-session-id response header
  • Sessions expire after 30 minutes of inactivity (max 200 concurrent)

Authentication

  • Static tokens: Set ACCESS_TOKENS or API_KEY environment variables; pass as Authorization: Bearer <token>
  • OAuth: Configure OAUTH_* environment variables to enable OAuth 2.0 token introspection

Client Configuration Examples

VS Code / VS Code Insiders

Add to your VS Code settings (.vscode/mcp.json or User Settings):

{
  "servers": {
    "fetch-url-mcp": {
      "command": "npx",
      "args": ["-y", "@j0hanz/fetch-url-mcp@latest", "--stdio"]
    }
  }
}
Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "fetch-url-mcp": {
      "command": "npx",
      "args": ["-y", "@j0hanz/fetch-url-mcp@latest", "--stdio"]
    }
  }
}
Cursor

Install in Cursor

Or manually add to Cursor MCP settings:

{
  "mcpServers": {
    "fetch-url-mcp": {
      "command": "npx",
      "args": ["-y", "@j0hanz/fetch-url-mcp@latest", "--stdio"]
    }
  }
}
Windsurf

Add to your Windsurf MCP configuration:

{
  "mcpServers": {
    "fetch-url-mcp": {
      "command": "npx",
      "args": ["-y", "@j0hanz/fetch-url-mcp@latest", "--stdio"]
    }
  }
}
Docker

Use the published image from GitHub Container Registry:

{
  "mcpServers": {
    "fetch-url-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/j0hanz/fetch-url-mcp:latest",
        "--stdio"
      ]
    }
  }
}

Or build and run locally:

docker build -t fetch-url-mcp .
docker run -i --rm fetch-url-mcp --stdio

Security

SSRF Protection

Fetch URL blocks requests to private and internal network addresses:

  • Blocked hosts: localhost, 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16, 100.64.0.0/10
  • Blocked IPv6: ::1, fc00::/7, fe80::/10, IPv4-mapped private addresses
  • Cloud metadata: 169.254.169.254 (AWS), metadata.google.internal, metadata.azure.com, 100.100.100.200 (Azure IMDS)

DNS preflight checks run on every redirect hop to prevent DNS rebinding attacks.

Stdio Transport Safety

The server never writes non-protocol data to stdout. All logs and diagnostics go to stderr.

Rate Limiting

HTTP mode enforces a rate limit of 100 requests per 60-second window per client.

Content Safety

  • HTML downloads are capped at 10 MB
  • Worker threads run in isolation with configurable resource limits
  • Auth tokens are stored in-memory only and compared using timing-safe equality

Development Workflow

Install Dependencies

npm install

Scripts

ScriptCommandDescription
devnpm run devTypeScript watch mode
dev:runnpm run dev:runRun compiled output with watch + .env
buildnpm run buildClean, compile, copy assets, make executable
startnpm startRun compiled server
testnpm testRun test suite (Node.js native test runner)
test:coveragenpm run test:coverageRun tests with coverage
lintnpm run lintESLint
lint:fixnpm run lint:fixESLint with auto-fix
formatnpm run formatPrettier
type-checknpm run type-checkTypeScript type checking
inspectornpm run inspectorBuild and launch MCP Inspector

Build and Release

npm run build           # Clean → Compile → Copy Assets → chmod
npm run prepublishOnly  # Lint → Type-Check → Build
npm publish             # Publish to npm

CI/CD is handled via a GitHub Actions workflow (release.yml) that runs lint, type-check, test, build, and publishes to npm with version bumping.

Troubleshooting

MCP Inspector

Use the built-in inspector to test the server interactively:

npm run inspector

Common Issues

IssueSolution
VALIDATION_ERROR on URLURL is blocked (private IP/localhost) or malformed. Do not retry.
queue_full errorWorker pool busy. Wait briefly, then retry or use async task mode.
Garbled outputBinary content (images, PDFs) cannot be converted. Ensure the URL serves HTML.
No output in stdio modeEnsure --stdio flag is passed. Without it, the server starts in HTTP mode.
Auth errors in HTTP modeSet ACCESS_TOKENS or API_KEY env var and pass as Authorization: Bearer <token>.

Stdout / Stderr Guidance

In stdio mode, stdout is reserved exclusively for MCP JSON-RPC messages. Logs and diagnostics are written to stderr. Never pipe stdout to a log file when using stdio transport.

License

MIT

Reviews

No reviews yet

Sign in to write a review