Labsco
levz0r logo

HTML to Markdown MCP

โ˜… 25

from levz0r

Fetch web pages and convert HTML to clean, formatted Markdown. Handles large pages with automatic file saving to bypass token limits.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

HTML to Markdown MCP Server

npm version npm downloads

An MCP (Model Context Protocol) server that converts HTML content to Markdown format using Turndown.js.

Table of Contents

Features

  • ๐ŸŒ Fetch and convert web pages - Automatically fetch HTML from any URL
  • ๐Ÿ”„ Convert HTML to clean, formatted Markdown
  • ๐Ÿ“ Preserves formatting (headers, links, code blocks, lists, tables)
  • ๐Ÿ—‘๏ธ Automatically removes unwanted elements (scripts, styles, etc.)
  • ๐Ÿ“Š Auto-extracts page titles and metadata
  • โšก Fast conversion using Turndown.js
  • ๐Ÿ”’ SSRF protection - Blocks requests to private/internal networks by default

Local Development

If you want to contribute or modify the server:

Copy & paste โ€” that's it
# Clone the repository
git clone https://github.com/levz0r/html-to-markdown-mcp.git
cd html-to-markdown-mcp

# Install dependencies
npm install

# Run the server
npm start

Testing

Run the test suite using Node's built-in test runner:

Copy & paste โ€” that's it
# Run all tests
npm test

# Run tests in watch mode (re-runs on file changes)
npm run test:watch

The test suite includes:

  • Tool discovery tests
  • HTML to markdown conversion tests
  • URL fetching tests
  • File saving tests
  • Truncation and large page handling tests
  • SSRF protection tests
  • Integration workflow tests

Publishing a New Version

The project uses automated CI/CD for publishing to npm:

  1. Update version using npm version scripts:

    Copy & paste โ€” that's it
    npm run version:patch  # 1.0.0 -> 1.0.1
    npm run version:minor  # 1.0.0 -> 1.1.0
    npm run version:major  # 1.0.0 -> 2.0.0
  2. Push the tag to trigger automated publishing:

    Copy & paste โ€” that's it
    git push && git push --tags
  3. GitHub Actions will automatically:

    • Run all tests
    • Publish to npm if tests pass
    • Add provenance information to the package

Manual publishing (if needed):

Copy & paste โ€” that's it
npm run release:patch --otp=<code>
npm run release:minor --otp=<code>
npm run release:major --otp=<code>

Security

SSRF Protection

By default, the server blocks URL requests to private and internal network addresses to prevent Server-Side Request Forgery (SSRF) attacks. This includes:

  • Loopback addresses (127.0.0.0/8, ::1)
  • Private networks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
  • Link-local / cloud metadata endpoints (169.254.0.0/16)
  • Non-HTTP(S) schemes (file://, ftp://, etc.)

DNS resolution is checked to prevent bypass via hostnames that resolve to private IPs.

Allowing Local Network Access

If you need to convert HTML from local or internal servers (e.g., a local dev server), you can opt in with the --allow-local flag or the ALLOW_LOCAL_NETWORK environment variable:

Copy & paste โ€” that's it
# Via CLI flag
npx html-to-markdown-mcp --allow-local
Copy & paste โ€” that's it
# Via environment variable
ALLOW_LOCAL_NETWORK=true npx html-to-markdown-mcp

Claude Desktop / Cursor configuration with local access:

Copy & paste โ€” that's it
{
  "mcpServers": {
    "html-to-markdown": {
      "command": "npx",
      "args": ["html-to-markdown-mcp", "--allow-local"]
    }
  }
}

Warning: Only enable local network access if you trust the AI agent's URL inputs. With this flag enabled, the server can reach internal services, localhost ports, and cloud metadata endpoints.

Technical Details

  • Protocol: Model Context Protocol (MCP)
  • Conversion Library: Turndown.js
  • Transport: stdio
  • Node.js: ES modules

Related Projects

This server uses the same conversion approach as markdown-printer, a browser extension for saving web pages as Markdown files.

License

MIT