thermal-mcp
Print beautiful HTML & Markdown on a $30 thermal receipt printer, straight from your AI agent.
README
thermal-mcp 🧾
Print beautiful HTML & Markdown on a $30 thermal receipt printer, straight from your AI agent.
thermal-mcp is an MCP server that turns any 58mm ESC/POS thermal printer into a typographic output device for LLM agents. The agent hands over Markdown or HTML; the server renders it in headless Chromium (2× supersampled), converts it to 1-bit with quality dithering, encodes ESC/POS, and ships it to the printer over USB, Bluetooth serial, or CUPS — wired preferred, automatically.
agent ──MCP──► render (Chromium @2x) ──► 1-bit (Atkinson/Jarvis/Bayer + CLAHE)
──► ESC/POS (heat-tuned, blank-line elision) ──► USB / BT / CUPS
Why it's nice
- Markdown in, ticket out — GFM plus syntax-highlighted code (monochrome scheme),
mermaiddiagrams, LaTeX math (KaTeX), task lists, tables, remote images. Three type-size tiers. - Full custom HTML when the agent wants layout control: real Chromium, so flexbox/grid/SVG/emoji/web fonts all work.
- Offline font library — Geist Sans/Mono, Inter, JetBrains Mono, Space Grotesk, Lora, Playfair Display, Caveat, Noto Sans SC, plus Font Awesome icons, all bundled and loaded via
file://. - Print quality obsessed — supersampled rendering, CLAHE + unsharp photo pipeline, three dither algorithms, ESC/POS heat/density tuning (
ESC 7,DC2 #), blank-line elision, paced Bluetooth writes. Calibrated on real hardware. - Exact previews —
preview_*tools return the true 1-bit image that will print, so agents iterate without wasting paper. <img data-qr="...">becomes a scannable QR code, generated server-side.
Tools
| tool | what it does |
|---|---|
print_markdown { markdown, size?, feed_lines? } |
quick path: markdown → house-styled ticket |
preview_markdown { markdown, size? } |
exact 1-bit preview, no paper |
print_html { html, mode?, algorithm?, feed_lines? } |
full custom design |
preview_html { html, mode?, algorithm? } |
exact 1-bit preview |
printer_status {} |
transport + printer state |
design_guide {} |
returns the full design guide (fonts, layout, house style) — client-agnostic, works in Claude Desktop |
mode: auto (detect photos, keep text sharp) / text / photo · algorithm: atkinson / jarvis / bayer · size: large 24px / medium 19px / small 14px.
Setup
git clone https://github.com/EthanPany/thermal-mcp && cd thermal-mcp
npm install
npx puppeteer browsers install chrome
npm run smoke # renders out/smoke.png without a printer
Register with Claude Code:
claude mcp add --scope user thermal --env THERMAL_TRANSPORT=auto \
-- "$(which node)" /absolute/path/to/thermal-mcp/node_modules/tsx/dist/cli.mjs \
/absolute/path/to/thermal-mcp/src/index.ts
Claude Desktop (claude_desktop_config.json). Use absolute paths — GUI
apps launch with a minimal PATH and won't find npx/tsx on their own:
"thermal": {
"command": "/absolute/path/to/node",
"args": [
"/absolute/path/to/thermal-mcp/node_modules/tsx/dist/cli.mjs",
"/absolute/path/to/thermal-mcp/src/index.ts"
],
"env": { "THERMAL_TRANSPORT": "auto" }
}
Design guidance. In Claude Code, optionally install the skill so it auto-loads:
ln -s /absolute/path/to/thermal-mcp/skills/thermal-print ~/.claude/skills/thermal-print
In Claude Desktop (or any other MCP client) the skill mechanism isn't
available, but the same guidance is served over MCP by the design_guide
tool — the agent calls it before designing. No extra setup.
Printer configuration
THERMAL_TRANSPORT=auto (default) probes in order: USB (any printer-class device) → Bluetooth SPP serial (THERMAL_DEVICE, default /dev/cu.MPT-II) → dry-run (writes PNG + ESC/POS bytes to out/). Or force usb / serial / lp-raw / lp-image / file.
Darkness: by default the server sends only ESC @ and uses the printer's
firmware-default darkness — clean, no bleed. Hardware heat/density commands are
opt-in because some clone firmwares (incl. the MPT-II tested here) misparse
ESC 7 and leak a parameter byte as a stray glyph. Set these only if your
firmware honors them and you need to push darker:
| env | meaning | default |
|---|---|---|
THERMAL_HEAT_TIME |
ESC 7 n2 — heat pulse ×10µs (darker); enables ESC 7 | unset |
THERMAL_HEAT_DOTS |
ESC 7 n1 — dots per strobe = 8×(n+1) | 3 (if ESC 7 on) |
THERMAL_HEAT_INTERVAL |
ESC 7 n3 — recovery ×10µs (fixes fading) | 60 (if ESC 7 on) |
THERMAL_DENSITY |
DC2 # density 0–31; enables DC2 # | unset |
THERMAL_BREAK |
DC2 # per-line break time 0–7 | 4 (if DC2 # on) |
THERMAL_THIN |
software stroke-thinning 0–2 (0.3–0.6 lightens fat Latin text; >0.7 breaks small/CJK text) | 0 (off) |
THERMAL_MAX_PX |
max ticket height in px; taller content is truncated with a warning (roll-saver) | 12000 (~1.5m) |
THERMAL_DITHER |
default photo algorithm | atkinson |
THERMAL_CHUNK / THERMAL_PACE_MS |
Bluetooth pacing | 256 / 30 |
Tested on a Sunydog 58mm (USB 6868:0200, Bluetooth "MPT-II") on macOS. Any printer speaking GS v 0 raster should work.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。