HTML to Markdown MCP Server

io.github.sunshad0w由 GitHub 帳號 sunshad0w 發布v0.3.0更新於 Oct 24, 2026

Converts HTML to Markdown with auto-summary and section extraction. Supports Playwright.

概覽

AI 產生的概覽

一個本機 MCP 伺服器,擷取網頁並把 HTML 轉換成乾淨精簡的 Markdown,可選用 Playwright 瀏覽器模式處理 JavaScript 較多的頁面或需登入的頁面。

可以做什麼
擷取指定 URL 的 HTML 並轉換成乾淨的 Markdown,可選擇保留圖片、表格和連結,並移除指令碼、樣式、導覽和頁尾。限制下載大小、設定請求逾時,並用可設定的快取有效期加速重複轉換。切換到 Playwright 瀏覽器模式以渲染 JavaScript 較多的網站,可選 Chromium、Firefox 或 WebKit,並設定等待策略。重複使用本機瀏覽器設定檔和 Cookie 以存取需要登入的頁面。
適用情境
適合需要可讀網頁正文而非原始 HTML 的情境,尤其是長文章或文件,避免佔滿上下文。瀏覽器模式適用於單頁應用程式或需要登入的頁面。
執行需求
以本機程序執行,通常透過 Docker 或 Python 安裝。非 Docker 方式需要 Python 3.10 或更高版本以及 uv 或 pip,瀏覽器模式還需安裝 Playwright 瀏覽器。未宣告需要帳號、API 金鑰或環境變數。
安裝前請注意
使用使用者設定檔的瀏覽器模式會讀取本機瀏覽器的 Cookie,可存取已登入頁面,因而暴露登入工作階段;使用前必須先關閉 Chrome。伺服器會從任意 URL 下載頁面,除記憶體快取外不寫入資料。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 HTML to Markdown MCP Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

HTML to Markdown MCP Server

MCP (Model Context Protocol) server for converting HTML webpages to clean Markdown format. Reduces HTML size by ~90-95% while preserving tables, images, and important content - perfect for AI context.

Features

  • Converts HTML from URLs to clean Markdown
  • Preserves tables, images, and links
  • Removes unnecessary elements (scripts, styles, navigation, footers, headers)
  • Significant size reduction (typically 90-95% compression)
  • Configurable options for images, tables, and links
  • Built with trafilatura and BeautifulSoup4 for robust extraction
  • Stream processing for efficient handling of large pages
  • Size limits to prevent downloading excessively large content (1MB-50MB)
  • Optional caching to speed up repeated conversions of the same URLs
  • 🌐 Browser mode with Playwright - Handles JavaScript-heavy sites and authenticated pages
    • Execute JavaScript (perfect for SPAs: React, Vue, Angular)
    • Use your browser profile with cookies (access authenticated pages!)
    • Support for Chrome, Firefox, WebKit
    • Configurable wait strategies for dynamic content

Installation

Prerequisites

  • Python 3.10 or higher
  • uv package manager (recommended) or pip

Install with uv (recommended)

bash
# Clone the repositorygit clone <your-repo-url>cd html2md
# Install dependenciesuv pip install -e .
# Install Playwright browsers (required for browser mode)playwright install chromium

Install with pip

bash
# Clone the repositorygit clone <your-repo-url>cd html2md
# Create virtual environmentpython -m venv venvsource venv/bin/activate  # On Windows: venv\Scripts\activate
# Install dependenciespip install -e .
# Install Playwright browsers (required for browser mode)playwright install chromium

Docker Installation (Recommended for Production)

The easiest way to use html2md is with Docker:

bash
# Build the imagedocker build -t html2md .
# Or use pre-built image (when published)docker pull your-registry/html2md:latest

For Claude Desktop, configure with Docker:

json
{  "mcpServers": {    "html2md": {      "command": "docker",      "args": [        "run",        "-i",        "--rm",        "html2md"      ]    }  }}

Docker Image Features:

  • Pre-installed Playwright with Chromium
  • Optimized for minimal size (~1GB)
  • Non-root user for security
  • Ready to use - no additional setup required

Configuration

Add the server to your Claude Desktop configuration file:

macOS

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

json
{  "mcpServers": {    "html2md": {      "command": "uv",      "args": [        "--directory",        "/absolute/path/to/html2md",        "run",        "html2md"      ]    }  }}

Windows

Edit %APPDATA%/Claude/claude_desktop_config.json:

json
{  "mcpServers": {    "html2md": {      "command": "uv",      "args": [        "--directory",        "C:\\absolute\\path\\to\\html2md",        "run",        "html2md"      ]    }  }}

Linux

Edit ~/.config/Claude/claude_desktop_config.json:

json
{  "mcpServers": {    "html2md": {      "command": "uv",      "args": [        "--directory",        "/absolute/path/to/html2md",        "run",        "html2md"      ]    }  }}

Usage

Once configured, the MCP server will be available in Claude Desktop. You can use the html_to_markdown tool:

Example 1: Basic conversion

Convert this webpage to markdown: https://example.com/article

Example 2: With options

Use the html_to_markdown tool with:- url: https://example.com/docs- include_images: false- include_tables: true

Example 3: Browser mode for JavaScript-heavy sites

Use the html_to_markdown tool with:- url: https://spa-application.com- fetch_method: playwright- wait_for: networkidle

Example 4: Access authenticated pages

Use the html_to_markdown tool with:- url: https://private-site.com/dashboard- fetch_method: playwright- use_user_profile: true- browser_type: chromium

Note: For use_user_profile=true, make sure Chrome is closed before running.

Tool Parameters

Basic Parameters:

  • url (required): URL of the webpage to convert
  • include_images (optional, default: true): Include images in Markdown
  • include_tables (optional, default: true): Include tables in Markdown
  • include_links (optional, default: true): Include links in Markdown
  • timeout (optional, default: 30): Request timeout in seconds (5-120)

Performance Parameters:

  • max_size (optional, default: 10MB): Maximum size of content to download in bytes (1MB-50MB)
  • use_cache (optional, default: false): Enable caching for faster repeated conversions
  • cache_ttl (optional, default: 3600): Cache time-to-live in seconds (60-86400)

Browser Mode Parameters:

  • fetch_method (optional, default: "fetch"): Fetch method - "fetch" (fast) or "playwright" (handles JS, auth)
  • browser_type (optional, default: "chromium"): Browser to use - "chromium", "firefox", or "webkit"
  • headless (optional, default: true): Run browser in headless mode
  • wait_for (optional, default: "networkidle"): Wait strategy - "load", "domcontentloaded", or "networkidle"
  • use_user_profile (optional, default: false): Use your browser profile with cookies (requires Chrome closed)

Development

Install development dependencies

bash
uv pip install -e ".[dev]"

Run tests

bash
pytest

Code formatting

bash
# Format with blackblack src/ tests/
# Lint with ruffruff check src/ tests/

Type checking

bash
mypy src/

Architecture

The project consists of three main modules:

converter.py

Core HTML to Markdown conversion functionality:

  • fetch_html(): Downloads HTML from URL
  • clean_html(): Removes unnecessary elements with BeautifulSoup
  • convert_to_markdown(): Converts cleaned HTML to Markdown with trafilatura
  • html_to_markdown(): Main workflow combining all steps

server.py

MCP server implementation:

  • Registers the html_to_markdown tool
  • Handles tool calls and error responses
  • Runs async MCP server with stdio transport

utils.py

Utility functions:

  • Hash calculation for caching
  • Text formatting and truncation
  • Domain extraction
  • Filename sanitization

cache.py

In-memory caching system:

  • SimpleCache class with TTL support
  • Global cache instance management
  • Automatic expiration of old entries
  • Hash-based cache keys for URL + parameters

browser.py

Playwright browser automation:

  • fetch_html_playwright() - Async browser-based HTML fetching
  • Support for Chromium, Firefox, WebKit
  • User profile integration for authenticated access
  • Configurable wait strategies for dynamic content

Troubleshooting

Server not appearing in Claude Desktop

  1. Check that the path in claude_desktop_config.json is absolute and correct
  2. Restart Claude Desktop completely
  3. Check Claude Desktop logs for errors

Installation issues

bash
# Verify Python versionpython --version  # Should be 3.10+
# Try reinstalling dependenciesuv pip install --force-reinstall -e .

Conversion errors

  • Timeout errors: Increase the timeout parameter
  • Empty content: Some websites may block automated requests or use JavaScript rendering
    • Solution: Use fetch_method: playwright to execute JavaScript
  • Parse errors: The webpage structure may be unusual or malformed
  • Content too large: Increase the max_size parameter (up to 50MB) or the page exceeds limits
  • Cache issues: Disable caching with use_cache: false if you need fresh content

Browser mode issues

  • Playwright not installed: Run playwright install chromium
  • Browser launch fails: Check that you have sufficient permissions and disk space
  • User profile error: Make sure Chrome is completely closed before using use_user_profile: true
  • Page doesn't load fully: Try different wait_for strategies:
    • "load" - fastest, waits for page load event
    • "domcontentloaded" - waits for DOM to be ready
    • "networkidle" - slowest but most reliable, waits for network to be idle
  • Authentication not working: Ensure you're using browser_type: chromium and use_user_profile: true

Performance

Typical conversion results:

  • Original HTML: ~500KB - 2MB
  • Markdown output: ~25KB - 100KB
  • Compression: 90-95%
  • Processing time: 2-10 seconds (depending on page size and network)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Credits

Built with:

來源:README.md,提交 e8daa0c

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.3.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分