
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.
概览
一个本地 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 密钥或环境变量。
安装
在 SourceWeft 中
- 打开 控制台中的 HTML to Markdown MCP Server,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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
trafilaturaandBeautifulSoup4for 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
uvpackage manager (recommended) orpip
Install with uv (recommended)
Install with pip
Docker Installation (Recommended for Production)
The easiest way to use html2md is with Docker:
For Claude Desktop, configure with Docker:
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:
Windows
Edit %APPDATA%/Claude/claude_desktop_config.json:
Linux
Edit ~/.config/Claude/claude_desktop_config.json:
Usage
Once configured, the MCP server will be available in Claude Desktop. You can use the html_to_markdown tool:
Example 1: Basic conversion
Example 2: With options
Example 3: Browser mode for JavaScript-heavy sites
Example 4: Access authenticated pages
Note: For use_user_profile=true, make sure Chrome is closed before running.
Tool Parameters
Basic Parameters:
url(required): URL of the webpage to convertinclude_images(optional, default: true): Include images in Markdowninclude_tables(optional, default: true): Include tables in Markdowninclude_links(optional, default: true): Include links in Markdowntimeout(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 conversionscache_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 modewait_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
Run tests
Code formatting
Type checking
Architecture
The project consists of three main modules:
converter.py
Core HTML to Markdown conversion functionality:
fetch_html(): Downloads HTML from URLclean_html(): Removes unnecessary elements with BeautifulSoupconvert_to_markdown(): Converts cleaned HTML to Markdown with trafilaturahtml_to_markdown(): Main workflow combining all steps
server.py
MCP server implementation:
- Registers the
html_to_markdowntool - 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:
SimpleCacheclass 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
- Check that the path in
claude_desktop_config.jsonis absolute and correct - Restart Claude Desktop completely
- Check Claude Desktop logs for errors
Installation issues
Conversion errors
- Timeout errors: Increase the
timeoutparameter - Empty content: Some websites may block automated requests or use JavaScript rendering
- Solution: Use
fetch_method: playwrightto execute JavaScript
- Solution: Use
- Parse errors: The webpage structure may be unusual or malformed
- Content too large: Increase the
max_sizeparameter (up to 50MB) or the page exceeds limits - Cache issues: Disable caching with
use_cache: falseif 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_forstrategies:"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: chromiumanduse_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:
- MCP SDK - Model Context Protocol
- trafilatura - Web content extraction
- BeautifulSoup4 - HTML parsing
来源:README.md,提交 e8daa0c
工具
0版本历史
1- v0.3.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分