md2
Formats Markdown into Bluesky-ready posts or threads with grapheme-aware counting, sentence splitting, numbering, and image attachment.
Formats Markdown into Mastodon-ready posts or threads with platform-accurate link counting, sentence splitting, numbering, and image attachment.
Supports local AI writing assistance through Ollama models for generating social-media captions, headlines, and copy.
Supports AI writing assistance through OpenAI-compatible models for generating social-media captions, headlines, and copy.
Formats Markdown into Threads-ready thread posts with platform-accurate counting, sentence splitting, 1/n numbering, and image attachment.
Generates WeChat Official Account-ready rich text with inlined styles, formulas as SVG, and reference links, and can create WeChat draft posts via the official API including image and cover upload.
Generates Xiaohongshu (RED) 1080×1440 image cards, covers, and captions with smart pagination and title/body character-limit validation.
Generates Zhihu-ready semantic HTML with native equations, code blocks, and native references for footnotes, suitable for pasting into Zhihu articles.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@md2Turn this Markdown into WeChat official account rich text with the Claude theme."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
md2
Write once in Markdown, publish to WeChat, Zhihu, Xiaohongshu and X / Threads, and get long images and covers too.
English · 简体中文
Web App · VS Code extension · CLI · MCP / AI agents

Why md2
Every platform's editor has its own quirks. md2 handles them all in one pass:
Platform | What md2 produces | How it gets there |
WeChat Official Account (公众号) | Rich text with every style inlined, copied in one click, or a draft created through the API | A specificity-aware CSS inliner (respects |
Zhihu (知乎) | Clean semantic HTML, copied in one click | Zhihu's native inline and block equations, |
Xiaohongshu / RED (小红书) | 1080×1440 image cards, a cover and a caption | Smart pagination: splits by paragraph, list item, code line and table row, never leaves a heading stranded, repeats table headers across pages, and treats |
X / Threads / Bluesky / Mastodon / LinkedIn | An auto-split thread or a single long post | Each platform's counting rules (X: CJK = 2, URL = 23; Bluesky counts graphemes; Mastodon URL = 23), splits at sentences, |
Long image | One 1080 px-wide PNG | For WeChat Moments, Weibo or Xiaohongshu, in the same theme as your article |
Cover | 10 modern templates × 6 sizes | Xiaohongshu 3:4 / 1:1, WeChat 2.35:1 / 1:1, Zhihu 16:9, X 16:9, with the title font sized to fit |
Also included: Mermaid diagrams (styles fully inlined, so they survive pasting into WeChat), math, fine-tuning (first-line indent, justify, line / paragraph / letter spacing, custom CSS), an AI writing assistant (bring your own key: Claude, DeepSeek, Kimi, Qwen or Ollama; writes Xiaohongshu titles and captions, rewrites threads, drafts WeChat headlines and digests, and writes cover copy) and a Chinese / English UI.
Everything renders locally. The web app runs in your browser and the CLI and VS Code extension run on your machine. Only the AI and WeChat API calls you trigger yourself go over the network.
16 contemporary themes + 8 code palettes
The themes follow current design languages: Claude, Linear, Geist (Vercel), Apple keynote, Editorial, Swiss, Neo-Brutal, Bento, Aurora, Midnight, Matcha, Wabi-sabi, Distill, Coral, Stripe docs and 宋韵 (Song dynasty). Code highlighting comes in GitHub Light/Dark, Vitesse, Tokyo Night, Catppuccin and Rosé Pine. Any theme can take a new accent color in one click.


Xiaohongshu cards


Covers


Zhihu & X


Mermaid, fine-tuning, AI




Related MCP server: md2card-mcp-server
Getting started
VS Code extension
Install md2 from the VS Code Marketplace (search md2 in the Extensions view, or run code --install-extension brycewang-stanford.md2). Cursor, VSCodium and Windsurf users can install it from Open VSX. A .vsix is also attached to each release. Open any Markdown file, then click the md2 icon in the editor title bar or press ⌘⌥M (Windows / Linux: CtrlAltM):
Live preview for every platform, scrolling with your editor.
From the Command Palette or the right-click menu: copy for WeChat / Zhihu, export Xiaohongshu cards, long images or covers (saved to
md2-export/), copy a thread.Publish to WeChat drafts (your AppID / AppSecret are kept in VS Code's encrypted SecretStorage).
See the extension README for every command and setting.
Web App
Open https://brycewang-stanford.github.io/md2/. Write Markdown on the left (you can drop in a .md file or paste images) and switch platforms on the right:
WeChat: click Copy for WeChat and paste into the WeChat Official Account editor.
Zhihu: click Copy for Zhihu and paste into the article editor. Formulas and code blocks stay editable.
Xiaohongshu: click Export N cards to download a ZIP (images +
caption.txt). Click the title or body on the right to copy it.X: copy posts one at a time, or the whole thread at once.
Cover: pick a template and size, then export a PNG, or export every size at once.
Local development:
pnpm install
pnpm dev # http://localhost:5173CLI
git clone https://github.com/brycewang-stanford/md2 && cd md2
pnpm install && pnpm build
cd packages/cli && npm link && cd - # global `md2` command (once the md2all npm package is published: npx md2all)
md2 wechat post.md --copy -t claude # WeChat rich text → clipboard
md2 zhihu post.md --copy # Zhihu rich text → clipboard
md2 xhs post.md -o out/xhs -s bento # Xiaohongshu cards + caption.txt
md2 thread post.md -p x # X thread (-p threads|bluesky|mastodon|linkedin)
md2 long post.md -t claude # long image
md2 ai xhs post.md # AI Xiaohongshu title / caption (needs ANTHROPIC_API_KEY)
md2 cover post.md -s wechat -t aurora # WeChat header image
md2 cover post.md --all -s xhs # render every cover template at once
md2 themes # list all themes / card styles / covers / sizesImage commands (xhs, long, cover) render with your local Chrome or Edge. You can also run npx playwright install chromium, or point MD2_CHROME_PATH at a browser.
Publish straight to WeChat drafts
export MD2_WECHAT_APPID=wx...
export MD2_WECHAT_SECRET=...
md2 publish wechat post.md -t linear # upload body images → upload/generate cover → create draft
md2 publish wechat post.md --dry-run # rehearse without calling the APIAdd your machine's outbound IP to the whitelist under Settings & Development → Basic Configuration (设置与开发 → 基本配置) in the WeChat Official Account platform. md2 only creates drafts. It never mass-sends. Common error codes (40164 IP not whitelisted, 48001 API not authorized, and others) come with an explanation.
Front matter
---
title: Article title # falls back to the first H1
subtitle: Subtitle # used on covers
author: Author
tags: [AI, Productivity] # Xiaohongshu / X hashtags, cover chips
description: Summary # WeChat digest, first post of a thread
cover: ./cover.png # WeChat cover (else the first image, else generated)
xhs:
title: Xiaohongshu title, ≤20 characters
---Extended syntax: GFM tables / task lists / strikethrough, $inline$ and $$block$$ math, footnotes [^1], GitHub-style alerts > [!TIP], and embedded HTML.
MCP / AI agents
md2 ships an MCP server so Claude, Cursor and other agents can typeset and render images directly:
{
"mcpServers": {
"md2": { "command": "node", "args": ["/path/to/md2/packages/cli/dist/cli.js", "mcp"] }
}
}(Once the npm package is published, use "command": "npx", "args": ["-y", "md2all", "mcp"].)
Tools: md2_wechat, md2_zhihu, md2_thread, md2_xhs_cards, md2_long_image, md2_cover, md2_ai, md2_publish_wechat_draft, md2_list_styles.
Claude Code users can also use the skill in this repo: skills/md2/SKILL.md.
Architecture
packages/core @md2/core isomorphic rendering engine (browser + Node)
parse unified / remark / rehype → hast (front matter, GFM, math, alerts)
inline-css CSS inliner built on PostCSS + hast-util-select (WeChat)
article formula SVG (MathJax), code highlighting (lowlight), heading decoration, footnotes & references
platforms/ wechat · zhihu · xhs · x
cover/ 10 cover templates
dom.ts Xiaohongshu paginator & cover title fitting (browser; the CLI reuses it via headless Chromium)
packages/cli md2all CLI + MCP server + WeChat API
apps/web Web App (React + CodeMirror 6), also embedded in the VS Code webview
apps/vscode VS Code extension (preview panel, commands, SecretStorage, draft publishing)Xiaohongshu pagination and covers run the same DOM code in the web app and the CLI, so both export identical images.
pnpm build && pnpm testRoadmap
Mermaid diagrams · AI writing assistant · VS Code extension · long images · Threads / Bluesky / LinkedIn
Browser autofill for Zhihu / Xiaohongshu (Playwright, with saved login)
Theme marketplace: import / share custom themes
Obsidian plugin (reusing
@md2/core)
Issues and PRs are welcome, in English or Chinese.
Also from the author: StatsPAI
StatsPAI is an agent-native Python library for causal inference and applied econometrics, a Python-first replacement path for Stata / R workflows (regress, reghdfe, csdid, rdrobust, synth, DoubleML, esttab and more), with machine-readable schemas and an MCP server for Claude Code, Claude Desktop and Cursor. It is developed and maintained by the Stanford REAP team (Rural Education Action Program, Center on China's Economy & Institutions).
pip install statspaiStatsPAI is published in the Journal of Open Source Software: Wang & Rozelle (2026), 11(125), 10604, doi:10.21105/joss.10604.
@article{wang2026statspaijoss,
author = {Wang, Biaoyue and Rozelle, Scott},
title = {StatsPAI: A Unified, Agent-Native Python Toolkit for
Causal Inference and Applied Econometrics},
journal = {Journal of Open Source Software},
year = {2026},
volume = {11},
number = {125},
pages = {10604},
doi = {10.21105/joss.10604},
url = {https://doi.org/10.21105/joss.10604}
}License
MIT © Bryce Wang and contributors. See NOTICE for acknowledgements.
This server cannot be deployed
Maintenance
Related MCP Connectors
The document publishing layer for AI tools. Convert markdown to 6 destinations, 62 templates.
Publish to self-hosted WordPress from AI agents: markdown, images, SEO, and Notion sync.
Draft, schedule, and analyze content for Substack, Medium, LinkedIn, X, Bluesky, and Threads.
- mcpOAuthai.posteverywhere
The agentic social media scheduler. Write, schedule and publish to all top social platforms.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceBridges AI writing and content platforms by enabling AI agents to format Markdown and publish posts directly to WeChat Official Accounts with automatic image handling. It supports conversational theme management and streamlined drafting to eliminate the need for manual copy-pasting between editors.84 npm1,341Apache 2.0
- FlicenseNot gradedqualityDmaintenanceConverts Markdown documents into visually appealing image cards through the MCP protocol. Supports 19 theme styles and intelligent content splitting.8-
- FlicenseAqualityFmaintenanceEnables AI agents to publish articles to WeChat Official Account (微信公众号). Supports image upload, draft creation, and publishing via standardized MCP protocol.51-
- AlicenseAqualityDmaintenanceConverts text or markdown into Xiaohongshu (Little Red Book) style image cards with AI cover generation, supporting multiple themes and aspect ratios.411 npm2MIT