mdread
Fetch any public URL as clean Markdown.
Agent-friendly HTML→Markdown with redirect re-validation and size limits. Extracted from tomo's web_fetch tool.
pip install mdread
# or with uv:
uv add mdread
# or as a CLI tool:
uv tool install mdread
Why mdread?
| Feature | What you get |
|---|---|
| One call | mdread.fetch(url) → Markdown string |
| Readable | Prefers <article> / <main>; strips scripts, nav, chrome |
| Bounded | Large/script-heavy pages fall back to plain text; output is truncated |
| Library + CLI | Import it, or run mdread https://… |
Quick start
from mdread import fetch, html_to_markdown, HtmlToMarkdown
# Fetch a page as Markdown
md = fetch("https://example.com")
print(md)
# Convert HTML you already have
print(html_to_markdown("<h1>Hi</h1><p>Hello <strong>world</strong>.</p>"))
# → # Hi
# Hello **world**.
# Full CommonMark converter (options: ATX headings, fenced code, …)
converter = HtmlToMarkdown({"headingStyle": "atx", "codeBlockStyle": "fenced"})
print(converter.convert("<h2>Title</h2><ul><li>One</li></ul>"))
Structured result
from mdread import fetch_result, FetchError
result = fetch_result("https://example.com", raise_on_error=True)
print(result.url, result.truncated, len(result.text))
CLI
mdread https://example.com
mdread --timeout 30 --max-chars 50000 https://docs.python.org/3/
python -m mdread https://example.com
API
| Symbol | Description |
|---|---|
fetch(url, *, timeout=15, max_chars=100_000, …) |
GET URL → Markdown/text string |
fetch_result(…) |
Same, returns FetchResult on success |
html_to_markdown(html) |
HTML string → Markdown (chrome stripped) |
HtmlToMarkdown |
Configurable CommonMark converter |
check_url |
URL validation helper |
FetchError |
Raised when raise_on_error=True |
On soft failure (default), fetch returns a string starting with Error: so agent tool loops never crash.
Safety defaults
- Only
http/https - Manual redirect following (each hop re-checked), max 5 redirects
- Default 15s timeout, 100k char output cap
Install / develop
git clone https://github.com/Alg0rix/mdread
cd mdread
uv sync --group dev # or: pip install -e ".[dev]"
pytest
License
MIT
Metadata
Release files for mdread 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mdread-0.1.0.tar.gz | 16.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mdread-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.1 kB
Release files / mdread-0.1.0.tar.gz
| Download URL | mdread-0.1.0.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da82398529af24cc8a351bbce05910d0f4afd89a081cd8500f0ba5ac02ecc18a
|
|
BLAKE2b-256 checksum How to use checksums |
0f50504758022061a733831ce0b311e5fda62648ec67bf06eae8dfc793f220b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.
Transparency logRelease files / mdread-0.1.0-py3-none-any.whl
| Download URL | mdread-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e72070ef0eef9a9ffa92735441f0a93b341dc29eb8d4956704dc452674d4115
|
|
BLAKE2b-256 checksum How to use checksums |
0d0e931e4f7df523dc3106a7b42fd1eea5602f13722576ecd3601bb154434f63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.
Transparency log