Metadata-Version: 2.5
Name: webread
Version: 0.2.0
Summary: MCP server and CLI that read web pages the way a browser does: clean markdown, PDFs, optional JS rendering
Project-URL: Homepage, https://github.com/vykio/webread-mcp
Project-URL: Issues, https://github.com/vykio/webread-mcp/issues
Author: vykio
License-Expression: MIT
License-File: LICENSE
Keywords: claude,fetch,llm,markdown,mcp,model-context-protocol,scraper,web
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.10
Requires-Dist: httpx[http2]>=0.27
Requires-Dist: mcp<3,>=2.3
Requires-Dist: pypdf>=5.0
Requires-Dist: trafilatura>=2.0
Provides-Extra: browser
Requires-Dist: playwright>=1.45; extra == 'browser'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/vykio/webread-mcp/main/docs/banner.webp" alt="A small robot reading a page that unrolls out of a browser window" width="100%">
</p>

<h1 align="center">webread</h1>

<p align="center">
  <strong>Let your AI agent read the web like you do.</strong><br>
  An MCP server that returns what a page actually says, as clean markdown, with nothing in between.
</p>

<p align="center">
  <a href="https://github.com/vykio/webread-mcp/actions/workflows/ci.yml"><img src="https://github.com/vykio/webread-mcp/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
  <a href="https://pypi.org/project/webread/"><img src="https://img.shields.io/pypi/v/webread?color=3776ab" alt="PyPI"></a>
  <img src="https://img.shields.io/badge/python-3.10%2B-3776ab" alt="Python 3.10+">
  <a href="https://registry.modelcontextprotocol.io/v0/servers?search=io.github.vykio/webread"><img src="https://img.shields.io/badge/MCP_Registry-io.github.vykio%2Fwebread-7c3aed" alt="MCP Registry"></a>
  <a href="https://glama.ai/mcp/servers/vykio/webread-mcp"><img src="https://glama.ai/mcp/servers/vykio/webread-mcp/badges/score.svg" alt="webread MCP server on Glama"></a>
  <a href="https://github.com/vykio/webread-mcp/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-22c55e" alt="MIT license"></a>
</p>

---

## Why

You paste a link into your coding agent and get back *"I couldn't fetch that page"*, or a vague
three-line summary of a 40-page doc. Usually the page is fine. The fetch tool is the problem:

- **It summarizes through a second model** that truncates, paraphrases or declines.
- **It scrapes HTML** even when the site would hand over clean markdown if asked.
- **It reads raw HTML**, so JavaScript apps come back as an empty `<div id="root">`.
- **It chokes on PDFs**, which is where half the interesting docs live.

`webread` is one tool, `read_url`, that fixes those. It returns the text itself, paginated, and
lets the model read one section of a long page or list its links to decide where to go next.

On [33 real pages](https://github.com/vykio/webread-mcp/blob/main/bench/RESULTS.md) (docs,
articles, forums, PDFs, JavaScript apps), webread read **28** (29 with the browser extra) where the
reference `mcp-server-fetch` read 24. The rest are sites that block every automated client, and
webread says so instead of returning a login wall as if it were the page.

## Features

|                         |                                                                                   |
| ----------------------- | --------------------------------------------------------------------------------- |
| 🙋 **Honest first** | Introduces itself as `webread/<version>` and asks for markdown; retries with ordinary browser headers only if the site refuses |
| 📝 **Markdown when offered** | Stripe, Vercel, Next.js, React, Cloudflare and Claude docs serve markdown to clients that ask |
| 📰 **Main-content extraction** | Otherwise, article text as markdown with links and tables; nav, ads and footers dropped |
| 🧩 **Site adapters** | GitHub files, arXiv papers, crates.io, Apple developer docs, YouTube |
| 📄 **PDF, JSON, text** | PDFs extracted page by page; JSON and plain text returned verbatim |
| 📑 **Sections and links** | Read just the part under one heading, or list a page's links; long pages show their outline |
| ⚡ **JavaScript rendering** | Optional headless Chromium, used automatically when a page comes back empty |
| 🛑 **Honest failures** | Anti-bot challenges, HTTP errors and login walls are reported as such |
| 🖥️ **CLI included** | `webread <url>` prints the same output in your terminal |

## Quick start

### Claude Desktop: one-click extension

Download `webread-<version>.mcpb` from the
[latest release](https://github.com/vykio/webread-mcp/releases/latest) and double-click it.
Claude Desktop installs it; you don't need Python or a terminal.

### Claude Code

You need [uv](https://docs.astral.sh/uv/). `uvx` fetches and caches the server from
[PyPI](https://pypi.org/project/webread/):

```bash
claude mcp add --scope user webread -- uvx webread
```

### Cursor, Windsurf, and other MCP clients

Add this to your client's MCP config (`.cursor/mcp.json`, `claude_desktop_config.json`, ...):

```json
{
  "mcpServers": {
    "webread": {
      "command": "uvx",
      "args": ["webread"]
    }
  }
}
```

`webread` is also in the [official MCP Registry](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.vykio/webread)
as `io.github.vykio/webread`, so clients that read the registry can install it by name.

### From the terminal

Without arguments `webread` is the MCP server; give it a URL and it prints the page:

```bash
uvx webread https://en.wikipedia.org/wiki/Robots.txt
uvx webread https://react.dev/learn --section "Using hooks"
uvx webread https://docs.python.org/3/ --links
```

## Rendering JavaScript pages (optional)

Install the `browser` extra and a Chromium build that matches it:

```bash
# Linux: --with-deps also installs Chromium's system libraries (asks for sudo)
uvx --from "webread[browser]" playwright install --with-deps chromium
```

Then point your MCP client at the extra:

```bash
claude mcp add --scope user webread -- uvx --from "webread[browser]" webread
```

With the extra installed, `render="auto"` (the default) first tries a plain HTTP fetch, which is
fast, and only starts Chromium when that fetch fails or returns less than a paragraph of text.
Whichever attempt produced more content wins.

## The `read_url` tool

| Parameter   | Type                              | Default  | What it does                                               |
| ----------- | --------------------------------- | -------- | ---------------------------------------------------------- |
| `url`       | string                            | required | The page to read. `https://` is assumed if missing.        |
| `start`     | int                               | `0`      | Character offset, to continue reading a long page.         |
| `max_chars` | int                               | `20000`  | Maximum characters returned by this call.                  |
| `section`   | string                            | none     | Return only the part under the first heading matching this text. |
| `links`     | bool                              | `false`  | Return the page's links (text and absolute URL) instead of its content. |
| `render`    | `"auto"` \| `"never"` \| `"always"` | `"auto"` | When to use headless Chromium.                             |
| `raw`       | bool                              | `false`  | Return the raw body (HTML source, JSON) instead of extracted text. |

What the model gets back for a long page (here with `max_chars=5000`):

```text
URL: https://react.dev/learn
Title: Quick Start
Status: 200 (text/markdown, via http)
Content: chars 0-5000 of 15859; call again with start=5000 for more
Sections (read one with section=...): Creating and nesting components · Writing markup with JSX ·
Adding styles · Displaying data · Conditional rendering · Rendering lists · Using Hooks · ...

Welcome to the React documentation! This page will give you an introduction to 80% of the
React concepts that you will use on a daily basis.
...
```

Results are cached for 15 minutes, so paging with `start`, `section` or `links` costs no extra
request. The tool is annotated read-only, and its description tells the model to treat page text
as data, not instructions.

### Making it the default

The server ships MCP instructions telling the model to prefer `read_url` over built-in fetch tools,
and most clients inject those into the system prompt. Models still have habits, so for a firmer
default add a line to your agent instructions (`~/.claude/CLAUDE.md`, `AGENTS.md`, Cursor rules...):

```markdown
To read a web page, use the webread MCP tool (read_url) instead of WebFetch.
```

In Claude Code you can go further and turn the built-in tool off by adding `"WebFetch"` to
`permissions.deny` in `~/.claude/settings.json`.

## How it works

```mermaid
flowchart LR
    A[read_url] --> B{cached?}
    B -- yes --> R[section / links / paginate]
    B -- no --> S{site adapter?}
    S -- data source --> R
    S -- no / rewrite --> C[GET as webread<br/>Accept: markdown]
    C --> D{refused?}
    D -- yes --> C2[retry with<br/>browser headers]
    D -- no --> E{nearly empty?}
    C2 --> E
    E -- yes --> F[headless Chromium<br/>optional]
    E -- no --> X[extract]
    F --> X
    X --> |markdown| R
    X --> |HTML| G[trafilatura → markdown] --> R
    X --> |PDF| H[pypdf → text] --> R
```

### Why "honest first"?

The first version sent Chrome headers on every request. Measured on real sites, that backfired:
a Python client claiming to be Chrome doesn't look like Chrome on the wire, and Medium, npm and
Hacker News challenged or refused it, while the same request from a client that names itself got
through. So webread now introduces itself, and falls back to browser headers only for sites that
turn away anything that isn't a browser.

## Site adapters

Some pages read badly as HTML but have a better public source. Each adapter is one small module in
[`src/webread/sites/`](https://github.com/vykio/webread-mcp/tree/main/src/webread/sites) with its
own tests, and falls back to the normal reader if anything goes wrong.

| Site | Instead of | webread reads |
| --- | --- | --- |
| GitHub `…/blob/…` | the file viewer | the raw file |
| arXiv `…/abs/…` | the abstract page | the full-text PDF |
| crates.io | an empty JavaScript app | the crates.io API and the README |
| Apple developer docs | an empty JavaScript app | the DocC JSON behind the page |
| YouTube | a title | title, channel, length, date and description (no transcript) |

## What it will not do

`webread` makes the request a person's browser would, once, when asked. It deliberately does
**not**:

- **Bypass anti-bot systems.** No TLS fingerprint spoofing, no CAPTCHA solving, no proxy rotation.
  When Cloudflare or a similar service serves a challenge, the tool says so plainly.
- **Log in for you.** Pages behind a login return the login page. For those, use a tool that drives
  your own signed-in browser, such as Claude in Chrome.
- **Crawl.** One URL per call, and repeated calls hit a 15-minute cache.
- **Read cloud metadata endpoints** (`169.254.169.254` and friends), so a prompt-injected page
  can't make it fetch instance credentials. Other local addresses stay readable for dev servers.

### Use it responsibly

Skipping robots.txt is reasonable for a person reading one page through an assistant, which is
exactly what a browser does. It is not a license to scrape. If you point this at a site in bulk,
respect its terms of service, its rate limits and any text-and-data-mining opt-out it publishes.

## How it compares

|                                  | Built-in agent fetch tools | [`mcp-server-fetch`](https://github.com/modelcontextprotocol/servers/tree/main/src/fetch) | **webread** |
| -------------------------------- | :------------------------: | :-------------------------: | :-------------: |
| Pages read in [the benchmark](https://github.com/vykio/webread-mcp/blob/main/bench/RESULTS.md) | – | 24 / 33 | **28 / 33** (29 with browser) |
| Returns the page text itself     | often summarized           | ✅                           | ✅               |
| Asks for markdown                | varies                     | ✅                           | ✅               |
| Retries with browser headers when refused | ❌                | ❌                           | ✅               |
| Honours robots.txt               | varies                     | ✅ (by default)              | ❌, one user-requested page |
| PDF                              | varies                     | ❌                           | ✅               |
| Site adapters                    | ❌                          | ❌                           | ✅               |
| Sections and link listing        | ❌                          | ❌                           | ✅               |
| JavaScript rendering             | ❌                          | ❌                           | optional        |
| Reports anti-bot challenges      | ❌                          | ❌                           | ✅               |

## Development

```bash
git clone https://github.com/vykio/webread-mcp
cd webread-mcp
uv run pytest            # offline: a local HTTP server and recorded adapter responses
uv run ruff check && uv run ruff format --check
uv run webread https://example.com
```

`core.py` fetches and extracts, `fetch.py` orchestrates adapters, HTTP and the browser,
`format.py` lays out the result, `server.py` exposes it over MCP and `cli.py` is the terminal
entry point.

### Adding a site adapter

1. Create `src/webread/sites/<site>.py` with a `NAME` and either `rewrite(url) -> str | None`
   (swap the URL for a better one) or `async read(url, timeout) -> Page | None` (build the page
   from the site's data). Return `None` for URLs that aren't yours.
2. Register it in `REWRITERS` or `READERS` in `src/webread/sites/__init__.py`.
3. Add `tests/sites/test_<site>.py`. The `fake_http` fixture serves canned responses, so tests
   never touch the network.
4. Add the page to `bench/urls.json` and rerun the benchmark (commands in `bench/run.py`).

### Releasing

1. Bump the version in `pyproject.toml` and in both `version` fields of `server.json`.
2. Commit, then push a tag: `git tag -a v0.3.0 -m "webread 0.3.0" && git push origin v0.3.0`.

The [release workflow](https://github.com/vykio/webread-mcp/blob/main/.github/workflows/release.yml)
checks that the versions match the tag, runs the tests, publishes to PyPI through trusted
publishing (no stored token), builds the Claude Desktop extension, attaches it to a GitHub release,
then updates the MCP Registry entry with both packages.

## License

[MIT](https://github.com/vykio/webread-mcp/blob/main/LICENSE). The banner was generated with FLUX.1 [schnell] (Apache 2.0).

<!-- mcp-name: io.github.vykio/webread -->
