Skip to main content
Glama

Page2MD

Paste a URL, get the page's real content back as clean Markdown — headings, links, images, lists, code blocks and tables, with nav and footer chrome stripped. Built for RAG pipelines and LLM workflows, and for agents that read documentation: tabbed and collapsible panels are converted in full, not just the visible one, and every result carries a completeness report so missing or cut content is never silent.

Pure Python standard library — no dependencies, nothing to pip install.

MCP server

This repo is a Model Context Protocol (MCP) server: mcp_server.py speaks MCP over stdio (JSON-RPC, protocol version 2024-11-05) using only the Python standard library — no MCP SDK required. It exposes one tool, implemented on top of the local converter in converter.py:

Tool

Input

Output

url_to_markdown

{ "url": "https://example.com/docs" }

{ url, final_url, title, markdown, chars, mode, completeness } — the Markdown plus a completeness report (see below)

Run it directly:

python3 mcp_server.py

Or with Docker (a Dockerfile is included, python:3.12-slim, no installs):

docker build -t page2md .
docker run -i page2md

Add it to any MCP client (e.g. Claude Desktop claude_desktop_config.json):

{
  "mcpServers": {
    "page2md": {
      "command": "python3",
      "args": ["/path/to/page2md-mcp/mcp_server.py"],
      "env": { "PAGE2MD_RAPIDAPI_KEY": "your_key_here" }
    }
  }
}

The PAGE2MD_RAPIDAPI_KEY env var is optional — without it the free local converter runs; with it, conversions go to the hosted Page2MD API on RapidAPI (see "Deep mode" below).

Related MCP server: web2md-mcp

The completeness report

Most converters silently return only the visible tab of a tabbed docs page — the other panels exist in the HTML but never reach your RAG index, and nothing tells you they were dropped. Page2MD walks the whole document regardless of visibility and reports what it found:

"completeness": {
  "panels_found": 5,
  "panels_included": 5,
  "truncated": false,
  "notes": ["page contains 5 tabbed/collapsible panel(s); 5 included in full"]
}
  • panels_found / panels_included — role="tabpanel" elements, tab-panel classes and <details> blocks, and how many of them made it into the Markdown.

  • truncated — output is capped at 200,000 characters; if a page converts to more, the Markdown is cut at a line boundary and this flag (plus a note) says so. A truncated result never pretends to be complete.

What the local converter handles

  • Headings, paragraphs, links (relative URLs resolved), images (alt text + resolved src), nested ordered/unordered lists, blockquotes, inline code, fenced pre blocks, simple pipe tables (pipes in cells escaped), definition lists, <details> sections.

  • Chrome stripped: script, style, nav, footer, forms and other non-content elements, plus role="navigation" / "banner" / "contentinfo" / "search" containers.

  • Lenient parsing: unclosed and mismatched tags do not crash it.

  • Plain-text responses are returned as-is.

Known limits: no JavaScript execution (content that only exists after client-side rendering is not in the HTML and cannot be converted), tables with merged cells are flattened, and deeply exotic markup may lose formatting. The completeness report covers panels and truncation; it cannot detect content that was never in the served HTML.

Deep mode (hosted API)

export PAGE2MD_RAPIDAPI_KEY=your_key_here
python3 mcp_server.py

With a key set, url_to_markdown POSTs the URL to the hosted Page2MD API — the same conversion the production backend serves (POST /convert with {"url": ...}, returning JSON with markdown / title / url) — via its RapidAPI gateway:

Env var

Default

Meaning

PAGE2MD_RAPIDAPI_KEY

(unset = local mode)

Your RapidAPI key for the Page2MD listing

PAGE2MD_RAPIDAPI_HOST

page2md-url-to-clean-markdown-api.p.rapidapi.com

Gateway host (the RapidAPI convention for the listing slug page2md-url-to-clean-markdown-api); override if your gateway host differs

PAGE2MD_RAPIDAPI_PATH

/convert

Endpoint path

If the hosted call fails, the tool falls back to the local converter and says so in the completeness notes — it never returns an empty shell. Hosted results note that panel-level completeness is determined by the hosted converter.

Get a key on RapidAPI — the hosted API is the Page2MD listing by NewKwLab.

Tests

python3 tests/run_tests.py

Runs the converter and the MCP server against local fixtures only (a localhost stub server and file:// URLs — no external network): a tabbed docs page whose hidden panels must all appear, a messy article with nested lists/tables/code, garbage inputs, a 404, an oversized page that must report truncation, and full stdio protocol checks (initialize / tools/list / tools/call).

Use without MCP

import converter
result = converter.url_to_markdown("https://example.com/docs")
print(result["markdown"])
print(result["completeness"])

License

MIT

Available Tools

1 tool
url_to_markdownA

Fetch a web page and convert its real content to clean Markdown: headings, paragraphs, links, images, lists, blockquotes, code blocks and tables, with nav/footer chrome stripped. Tabbed and collapsible panels (e.g. documentation tabs, ) are included in full - not just the visible panel - and the result carries a completeness report {panels_found, panels_included, truncated, notes} so missing or cut content is never silent. Without an API key the conversion runs locally; with PAGE2MD_RAPIDAPI_KEY set it uses the hosted Page2MD API on RapidAPI.

Inputs: url (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 1 tool

    Disambiguation5/5

    There is exactly one tool, so there is no possibility of confusion with a sibling tool. Its purpose (fetch a URL and return clean Markdown) is stated unambiguously in the description.

    Naming Consistency4/5

    The single name url_to_markdown is descriptive snake_case and clearly conveys source and output format. With only one tool there is no cross-tool pattern to validate, which caps this slightly below full marks.

    Tool Count4/5

    One tool is thin in absolute terms, but the server's scope is narrowly and honestly defined as URL-to-Markdown conversion, and the tool packs real capability (panel extraction, completeness reporting, local vs. hosted modes). It is not a trivial stub, so the minimal surface is defensible.

    Completeness4/5

    The single tool covers the full pipeline for its domain: fetch, clean, convert, strip chrome, and report completeness. Minor gaps remain—no batch/multi-URL input and no direct file-write or alternate output formats—but an agent can work around these.

    Related MCP Connectors

    Related MCP Servers