mcp-web-reader
# mcp-web-reader
[](https://github.com/aranshayan/mcp-web-reader/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/@aranshayan/mcp-web-reader)
[](LICENSE)
An [MCP](https://modelcontextprotocol.io) server that lets Claude **read web pages as clean Markdown** — article extraction (Mozilla Readability), tables, absolute links — with the guard rails a tool that fetches model-chosen URLs needs.
- **SSRF protection on by default.** Blocks localhost, private ranges, link-local/cloud-metadata (`169.254.169.254`), CGNAT, IPv6 loopback/ULA, IPv4-mapped IPv6 and NAT64. Hostnames are validated **at connect time** (defeats DNS rebinding) and **every redirect hop is re-validated**.
- **Polite.** Honours `robots.txt`, identifies itself with a clear User-Agent.
- **Bounded.** Response size cap, request timeout, redirect limit, content-type allowlist (text/HTML/JSON/XML only).
- **Paginated.** Long pages are read in pieces with `start_index`.
- Pure JS, no browser, no native dependencies. (Pages that need JavaScript to render are not supported.)
## Quick start
```json
{
"mcpServers": {
"web": { "command": "npx", "args": ["-y", "@aranshayan/mcp-web-reader"] }
}
}
```
Claude Code: `claude mcp add web -- npx -y @aranshayan/mcp-web-reader`. Requires Node.js 22+.
## Tools
| Tool | Description |
| --- | --- |
| `fetch_page` | Page → Markdown (or text). Options: `main_content`, `max_chars`, `start_index`. |
| `extract_links` | Unique absolute http(s) links, optionally same-domain only. |
| `page_metadata` | Title, description, canonical URL, language, Open Graph. |
All tools are `readOnlyHint`. Fetched content is untrusted: the server instructs the model to treat it as data, not instructions, but prompt injection remains a risk with any web-reading tool — pair it with `--allowed-domains` for sensitive agents.
## Options
| Flag | Default | |
| --- | --- | --- |
| `--allow-private` | off | Permit localhost / private networks (for local docs sites). |
| `--ignore-robots` | off | Skip robots.txt. Only with permission. |
| `--allowed-domains a.com,b.org` | any | Restrict to these domains and subdomains. |
| `--blocked-domains …` | none | Never fetch these. |
| `--timeout-ms` | 15000 | Per request. |
| `--max-bytes` | 5 MiB | Max download size. |
| `--user-agent` | `mcp-web-reader/x (+repo)` | |
Environment: `MCP_WEB_ALLOW_PRIVATE`, `MCP_WEB_IGNORE_ROBOTS`, `MCP_WEB_ALLOWED_DOMAINS`, `MCP_WEB_BLOCKED_DOMAINS`.
## Tests
`npm test` covers the IP classifier (IPv4/IPv6 edge cases), URL policy, extraction, pagination, size/type limits, robots.txt, redirect loops, proof that blocked requests never reach the server, and the built CLI over stdio. Not tested: behaviour against the live internet (tests use a local HTTP server).
## License
[MIT](LICENSE)
TDQS
Scored across 3 tools
Each tool has a distinct output shape: page content as Markdown, a list of links, or metadata only. There is mild overlap since all three fetch the same page, and an agent may be unsure whether to call fetch_page and parse links itself or use extract_links, but the descriptions clearly state the boundary (page_metadata explicitly skips body conversion).
fetch_page and extract_links follow a clean verb_noun snake_case pattern. page_metadata breaks that pattern by putting the resource first, but it is still readable and unambiguous, so this is a minor deviation rather than a real inconsistency.
Three tools is on the thin side, but for a narrowly scoped single-page reader each tool covers a genuinely distinct need (content, links, metadata) and none are redundant. It is slightly minimal rather than over- or under-built.
The core read-a-page workflow is covered end to end: fetch content, extract navigable links, and cheaply inspect metadata. Gaps are minor: no raw-HTML mode, no batch/multi-URL fetch, and no search or crawl operation, which agents can work around by repeated single-page calls.