mcp-web-print-pdf 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -11
- package/README_EN.md +162 -11
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -1,20 +1,96 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center"><img src="https://raw.githubusercontent.com/weixiaoyi/mcp-web-print-pdf/master/assets/logo.svg" width="96" height="96" alt="mcp-web-print-pdf logo"></p>
|
|
2
|
+
|
|
3
|
+
<h1 align="center">mcp-web-print-pdf</h1>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<b>让 AI agent 把 HTML / 网页 / PDF / 图片直接打印到本机打印机</b><br>
|
|
7
|
+
<sub>MCP server for silent printing · Claude Desktop · Cursor · Claude Code · VS Code · Cline · Codex · dsh</sub>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://www.npmjs.com/package/mcp-web-print-pdf"><img src="https://img.shields.io/npm/v/mcp-web-print-pdf?logo=npm&logoColor=white&label=npm&color=cb3837" alt="npm version"></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/mcp-web-print-pdf"><img src="https://img.shields.io/npm/dm/mcp-web-print-pdf?logo=npm&logoColor=white&label=downloads&color=cb3837" alt="npm downloads"></a>
|
|
13
|
+
<a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-compatible-6f42c1" alt="MCP compatible"></a>
|
|
14
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/package.json"><img src="https://img.shields.io/badge/node-%E2%89%A518-339933?logo=node.js&logoColor=white" alt="node >=18"></a>
|
|
15
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/LICENSE"><img src="https://img.shields.io/github/license/weixiaoyi/mcp-web-print-pdf?color=2b9348" alt="license MIT"></a>
|
|
16
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/actions/workflows/test.yml"><img src="https://github.com/weixiaoyi/mcp-web-print-pdf/actions/workflows/test.yml/badge.svg?branch=master" alt="CI"></a>
|
|
17
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/stargazers"><img src="https://img.shields.io/github/stars/weixiaoyi/mcp-web-print-pdf?style=social" alt="GitHub stars"></a>
|
|
18
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen" alt="PRs welcome"></a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<b>中文</b> · <a href="https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/README_EN.md">English</a> ·
|
|
23
|
+
<a href="https://webprintpdf.com/">官网</a> ·
|
|
24
|
+
<a href="https://webprintpdf.com/docs/mcp-print/">接入文档</a> ·
|
|
25
|
+
<a href="https://webprintpdf.com/downloadApp/">下载客户端</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
一句话:**装一个 MCP server,模型就能「说一句、打一张」**——不必截图、不必弹浏览器、不必让用户按 Ctrl+P。
|
|
31
|
+
|
|
32
|
+
它**不改**「Web打印专家」客户端,也不改 `web-print-pdf` 浏览器库——只是给客户端已有的
|
|
33
|
+
`ws://127.0.0.1:16794/websocket/standard` 再加一个客户端,并把 `web-print-pdf@2.x` 的公开 API
|
|
34
|
+
一对一映射成 16 个 MCP 工具。
|
|
2
35
|
|
|
3
|
-
|
|
36
|
+
```
|
|
37
|
+
Claude / Cursor / Cline / dsh ──stdio──> mcp-web-print-pdf ──ws──> Web打印专家客户端 ──> 打印机
|
|
38
|
+
```
|
|
4
39
|
|
|
5
|
-
|
|
40
|
+
## 为什么用它
|
|
6
41
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
42
|
+
| 你想要的 | 常见做法 | 用 mcp-web-print-pdf |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| 让模型打印一张发票 / 报表 | 截图 → 手工打开 → Ctrl+P | 模型调 `printHtml`,静默出纸 |
|
|
45
|
+
| 批量打 100 张面单 | 循环开页面、逐个确认 | 一次 `batchPrint` 提交混合任务 |
|
|
46
|
+
| 80mm 热敏小票 | 前端 `window.print()`,样式全乱 | `pdf_options` 控制纸宽 / 边距 / 水印 |
|
|
47
|
+
| 打印本机 PDF | 上传到网盘再让用户下载 | `printFile` 按路径直连客户端 |
|
|
48
|
+
| 电子面单 / 标签机 | 需要专用 SDK | 走系统打印驱动 + `print_options` |
|
|
10
49
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- 文档:<https://webprintpdf.com/docs/>
|
|
50
|
+
和 Playwright / Puppeteer 打印相比,它不是「无头浏览器另存 PDF」,而是**调用本机已装好的打印驱动**:
|
|
51
|
+
支持热敏、针式、标签机,支持纸盒 / 双面 / 缩放 / 锐化等驱动级参数,也不用额外下载 Chromium。
|
|
14
52
|
|
|
53
|
+
## 30 秒上手
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"mcpServers": {
|
|
58
|
+
"webprint": {
|
|
59
|
+
"command": "npx",
|
|
60
|
+
"args": ["-y", "mcp-web-print-pdf"]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
15
64
|
```
|
|
16
|
-
|
|
17
|
-
|
|
65
|
+
|
|
66
|
+
1. 装并启动 [Web打印专家客户端](https://webprintpdf.com/downloadApp/)(监听 `ws://127.0.0.1:16794/websocket/standard`)
|
|
67
|
+
2. 把上面的 JSON 贴进宿主配置(各宿主位置见[配置](#配置))
|
|
68
|
+
3. 让模型先 `getConnectStatus` 探活,再 `printHtml` 出一张测试页
|
|
69
|
+
|
|
70
|
+
> 首次运行 `npx` 会自动下载并缓存;要固定版本写 `npx -y mcp-web-print-pdf@0.2.3`。
|
|
71
|
+
|
|
72
|
+
## 目录
|
|
73
|
+
|
|
74
|
+
- [为什么用它](#为什么用它) · [30 秒上手](#30-秒上手) · [支持的宿主](#支持的宿主)
|
|
75
|
+
- [前置条件](#前置条件) · [安装](#安装) · [配置](#配置)
|
|
76
|
+
- [工具](#工具) · [参数](#参数) · [示例](#示例)
|
|
77
|
+
- [常见问题 FAQ](#常见问题-faq)
|
|
78
|
+
- [大文件怎么打](#大文件怎么打) · [实现要点](#实现要点)
|
|
79
|
+
- [本地开发](#本地开发) · [已知边界](#已知边界) · [相关链接](#相关链接)
|
|
80
|
+
|
|
81
|
+
## 支持的宿主
|
|
82
|
+
|
|
83
|
+
| 宿主 | 配置位置 | 顶层键 |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| [Claude Desktop](#claude-desktop) | `claude_desktop_config.json` | `mcpServers` |
|
|
86
|
+
| [Cursor](#cursor) | `.cursor/mcp.json`、`~/.cursor/mcp.json` | `mcpServers` |
|
|
87
|
+
| [Claude Code](#claude-code) | `claude mcp add` 或 `.mcp.json` | `mcpServers` |
|
|
88
|
+
| [VS Code + Copilot](#vs-code--github-copilot) | `.vscode/mcp.json` | `servers` |
|
|
89
|
+
| [DeepSeek Harness(dsh)](#deepseek-harnessdsh) | `cordis.patch.yml` | — |
|
|
90
|
+
| [Codex CLI](#openai-codex-cli) | `~/.codex/config.toml` | `[mcp_servers.…]` |
|
|
91
|
+
| [Cline / Roo / Kilo](#cline--roo-code--kilo-code) | `cline_mcp_settings.json` | `mcpServers` |
|
|
92
|
+
| [Cherry Studio](#cherry-studio) · [Trae](#trae) | 图形界面 | `mcpServers` |
|
|
93
|
+
| [其它宿主](#其它宿主) | 见下表 | `mcpServers` |
|
|
18
94
|
|
|
19
95
|
## 前置条件
|
|
20
96
|
|
|
@@ -371,6 +447,66 @@ Roo Code / Kilo Code 是 Cline 的分叉,配置结构相同,只是文件路
|
|
|
371
447
|
> 批量任务里每个 `extraOptions.action` 必须一致(客户端在浅合并后会校验),所以别在单个任务里
|
|
372
448
|
> 混用 `print` 和 `preview`;统一用顶层 `dry_run` 控制即可。
|
|
373
449
|
|
|
450
|
+
## 常见问题 FAQ
|
|
451
|
+
|
|
452
|
+
### MCP 是什么?为什么打印要经过 MCP?
|
|
453
|
+
|
|
454
|
+
MCP(Model Context Protocol)是模型调用外部工具的通用协议。把打印能力做成 MCP server 后,
|
|
455
|
+
Claude、Cursor、Cline、dsh 这些宿主不用各写一套对接代码,接一次就能在所有宿主里用同一批工具。
|
|
456
|
+
|
|
457
|
+
### 需要联网吗?
|
|
458
|
+
|
|
459
|
+
不需要。所有打印请求都走本机 `ws://127.0.0.1:16794/websocket/standard`,只有首次 `npx` 下载包时需要网络。
|
|
460
|
+
|
|
461
|
+
### 需要额外买授权吗?
|
|
462
|
+
|
|
463
|
+
预览(`extra_options.action = "preview"` / `dry_run: true`)只渲染不送印,不检查授权;
|
|
464
|
+
正式出纸由 Web打印专家客户端校验,未授权时会返回 `Not allowed to use, please purchase authorization`。
|
|
465
|
+
|
|
466
|
+
### 会不会「偷偷」打印、浪费纸?
|
|
467
|
+
|
|
468
|
+
默认 `dry_run: false` 是直接出纸(和服务端 API 语义一致)。调试阶段请显式传 `dry_run: true`,
|
|
469
|
+
确认排版后再改成 `false`。
|
|
470
|
+
|
|
471
|
+
### 支持热敏小票机 / 标签打印机吗?
|
|
472
|
+
|
|
473
|
+
支持。热敏、针式、面单机都走系统打印驱动,用 `pdf_options.width/height` 控制版面,
|
|
474
|
+
用 `print_options.paperFormat` 指定驱动里的纸名,必要时开 `sharp: true` + `dpi` 提升小票清晰度。
|
|
475
|
+
|
|
476
|
+
### 和 Playwright / Puppeteer 打印有什么区别?
|
|
477
|
+
|
|
478
|
+
Playwright 是在无头 Chromium 里渲染成 PDF 再调用系统打印,需要单独下载浏览器内核,
|
|
479
|
+
拿不到驱动级参数(纸盒、锐化、双面翻转);本项目直接把参数交给已经装好的客户端和驱动,
|
|
480
|
+
更贴近「真的在这台机器上打印」。
|
|
481
|
+
|
|
482
|
+
### 支持 macOS / Linux / 国产系统吗?
|
|
483
|
+
|
|
484
|
+
客户端支持 Windows 10/11、macOS 11+,以及 Linux / 银河麒麟 / 统信 UOS;本 MCP 是纯 Node 进程(Node ≥ 18),
|
|
485
|
+
能跑客户端的地方就能跑它。
|
|
486
|
+
|
|
487
|
+
### 为什么预览只返回一个 URL,模型看不到图?
|
|
488
|
+
|
|
489
|
+
预览返回的是 `pdfUrl` / `printPreviewUrl`,MCP 通道里没有图片内容。要让模型「看图」,
|
|
490
|
+
需要额外把 PDF 转成 PNG 再喂给模型。
|
|
491
|
+
|
|
492
|
+
### 大文件 / 大 HTML 为什么失败?
|
|
493
|
+
|
|
494
|
+
MCP 的 stdio 单条消息默认上限 10MB,Base64 会再膨胀约 4/3。大文件请用 `printFile`(本机读文件)
|
|
495
|
+
或先挂到 HTTP 地址用 `printPdfByUrl` / `printImageByUrl`。
|
|
496
|
+
|
|
497
|
+
### 端口不是 16794 怎么办?
|
|
498
|
+
|
|
499
|
+
设环境变量 `WEBPRINT_PORT`;请求超时设 `WEBPRINT_TIMEOUT`(毫秒)。这两个都从宿主配置的 `env` 传入。
|
|
500
|
+
|
|
501
|
+
### 能让 ChatGPT / claude.ai 网页版直接用吗?
|
|
502
|
+
|
|
503
|
+
暂时不行。网页版只接受远程 HTTP MCP,需要额外一层 HTTP 桥接本机 stdio server(本项目未提供)。
|
|
504
|
+
|
|
505
|
+
### 打印出来是空白 / 内容被截断?
|
|
506
|
+
|
|
507
|
+
通常是纸张尺寸和内容不匹配:显式传 `paper_format` 或 `pdf_options.width/height`,并打开
|
|
508
|
+
`printBackground: true`(背景色 / 背景图默认不打)。
|
|
509
|
+
|
|
374
510
|
## 大文件怎么打
|
|
375
511
|
|
|
376
512
|
MCP 的 stdio 通道单条消息默认上限 **10MB**(SDK 的 `ReadBuffer`),所以:
|
|
@@ -463,6 +599,14 @@ npx @modelcontextprotocol/inspector node bin/mcp.js
|
|
|
463
599
|
- 客户端下载:<https://webprintpdf.com/downloadApp/>
|
|
464
600
|
- web-print-pdf(npm):<https://www.npmjs.com/package/web-print-pdf>
|
|
465
601
|
- 本仓库:<https://github.com/weixiaoyi/mcp-web-print-pdf>
|
|
602
|
+
- 更新日志:[CHANGELOG.md](https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/CHANGELOG.md)
|
|
603
|
+
- 面向 AI 的说明:[llms.txt](https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/llms.txt)
|
|
604
|
+
|
|
605
|
+
## 贡献
|
|
606
|
+
|
|
607
|
+
Issue、PR、文档纠错都欢迎,先看 [CONTRIBUTING.md](https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/CONTRIBUTING.md)。
|
|
608
|
+
|
|
609
|
+
如果这个项目帮你省了时间,点个 ⭐ 能让更多找「MCP 打印」的人看到它。
|
|
466
610
|
|
|
467
611
|
## License
|
|
468
612
|
|
package/README_EN.md
CHANGED
|
@@ -1,21 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<p align="center"><img src="https://raw.githubusercontent.com/weixiaoyi/mcp-web-print-pdf/master/assets/logo.svg" width="96" height="96" alt="mcp-web-print-pdf logo"></p>
|
|
2
|
+
|
|
3
|
+
<h1 align="center">mcp-web-print-pdf</h1>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<b>Let AI agents print HTML / web pages / PDFs / images straight to a local printer</b><br>
|
|
7
|
+
<sub>MCP server for silent printing · Claude Desktop · Cursor · Claude Code · VS Code · Cline · Codex · dsh</sub>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://www.npmjs.com/package/mcp-web-print-pdf"><img src="https://img.shields.io/npm/v/mcp-web-print-pdf?logo=npm&logoColor=white&label=npm&color=cb3837" alt="npm version"></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/mcp-web-print-pdf"><img src="https://img.shields.io/npm/dm/mcp-web-print-pdf?logo=npm&logoColor=white&label=downloads&color=cb3837" alt="npm downloads"></a>
|
|
13
|
+
<a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-compatible-6f42c1" alt="MCP compatible"></a>
|
|
14
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/package.json"><img src="https://img.shields.io/badge/node-%E2%89%A518-339933?logo=node.js&logoColor=white" alt="node >=18"></a>
|
|
15
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/LICENSE"><img src="https://img.shields.io/github/license/weixiaoyi/mcp-web-print-pdf?color=2b9348" alt="license MIT"></a>
|
|
16
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/actions/workflows/test.yml"><img src="https://github.com/weixiaoyi/mcp-web-print-pdf/actions/workflows/test.yml/badge.svg?branch=master" alt="CI"></a>
|
|
17
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/stargazers"><img src="https://img.shields.io/github/stars/weixiaoyi/mcp-web-print-pdf?style=social" alt="GitHub stars"></a>
|
|
18
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen" alt="PRs welcome"></a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/README.md">中文</a> · <b>English</b> ·
|
|
23
|
+
<a href="https://webprintpdf.com/">Website</a> ·
|
|
24
|
+
<a href="https://webprintpdf.com/docs/mcp-print/">MCP guide</a> ·
|
|
25
|
+
<a href="https://webprintpdf.com/downloadApp/">Download client</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
In one line: **install one MCP server and the model can "say it once, print it once"** — no screenshots,
|
|
31
|
+
no browser pop-ups, no asking the user to hit Ctrl+P.
|
|
6
32
|
|
|
7
33
|
It does **not** modify the Web Print Expert client or the `web-print-pdf` browser library — it simply
|
|
8
34
|
adds another client to the existing `ws://127.0.0.1:16794/websocket/standard` endpoint and maps the
|
|
9
|
-
public `web-print-pdf@2.x` API one-to-one onto MCP tools.
|
|
10
|
-
|
|
11
|
-
- Website: <https://webprintpdf.com/>
|
|
12
|
-
- Underlying npm package: [web-print-pdf](https://www.npmjs.com/package/web-print-pdf)
|
|
13
|
-
- Docs: <https://webprintpdf.com/docs/>
|
|
35
|
+
public `web-print-pdf@2.x` API one-to-one onto 16 MCP tools.
|
|
14
36
|
|
|
15
37
|
```
|
|
16
|
-
Claude / dsh ──stdio──> mcp-web-print-pdf ──ws──> Web Print Expert client ──> printer
|
|
38
|
+
Claude / Cursor / Cline / dsh ──stdio──> mcp-web-print-pdf ──ws──> Web Print Expert client ──> printer
|
|
17
39
|
```
|
|
18
40
|
|
|
41
|
+
## Why this one
|
|
42
|
+
|
|
43
|
+
| What you want | Usual approach | With mcp-web-print-pdf |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| Have the model print an invoice / report | screenshot → open it → Ctrl+P | model calls `printHtml`, silent output |
|
|
46
|
+
| Print 100 shipping labels | loop over pages, confirm each one | one `batchPrint` with mixed tasks |
|
|
47
|
+
| 80mm thermal receipts | `window.print()` mangles the layout | `pdf_options` controls width / margin / watermark |
|
|
48
|
+
| Print a local PDF | upload it, then download it again | `printFile` reads it by path |
|
|
49
|
+
| Labels and dot-matrix forms | needs a vendor SDK | system print driver + `print_options` |
|
|
50
|
+
|
|
51
|
+
Compared with Playwright / Puppeteer printing, this is not "headless browser saves a PDF": it **drives the
|
|
52
|
+
printer driver already installed on the machine**. Thermal, dot-matrix and label printers work, driver-level
|
|
53
|
+
options (tray, duplex, scaling, sharpening) are reachable, and there is no Chromium download.
|
|
54
|
+
|
|
55
|
+
## Quick start (30 seconds)
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"webprint": {
|
|
61
|
+
"command": "npx",
|
|
62
|
+
"args": ["-y", "mcp-web-print-pdf"]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
1. Install and start the [Web Print Expert client](https://webprintpdf.com/downloadApp/) (listens on `ws://127.0.0.1:16794/websocket/standard`)
|
|
69
|
+
2. Paste the JSON above into your host config (locations below)
|
|
70
|
+
3. Ask the model to call `getConnectStatus`, then `printHtml` a test page
|
|
71
|
+
|
|
72
|
+
> The first `npx` run downloads and caches the package; pin it with `npx -y mcp-web-print-pdf@0.2.3`.
|
|
73
|
+
|
|
74
|
+
## Contents
|
|
75
|
+
|
|
76
|
+
- [Why this one](#why-this-one) · [Quick start](#quick-start-30-seconds) · [Supported hosts](#supported-hosts)
|
|
77
|
+
- [Prerequisites](#prerequisites) · [Installation](#installation) · [Configuration](#configuration)
|
|
78
|
+
- [Tools](#tools) · [Parameters](#parameters) · [Examples](#examples)
|
|
79
|
+
- [FAQ](#faq)
|
|
80
|
+
- [Printing large files](#printing-large-files) · [Implementation notes](#implementation-notes)
|
|
81
|
+
- [Local development](#local-development) · [Known limitations](#known-limitations) · [Links](#links)
|
|
82
|
+
|
|
83
|
+
## Supported hosts
|
|
84
|
+
|
|
85
|
+
| Host | Config location | Top-level key |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| [Claude Desktop](#claude-desktop) | `claude_desktop_config.json` | `mcpServers` |
|
|
88
|
+
| [Cursor](#cursor) | `.cursor/mcp.json`, `~/.cursor/mcp.json` | `mcpServers` |
|
|
89
|
+
| [Claude Code](#claude-code) | `claude mcp add` or `.mcp.json` | `mcpServers` |
|
|
90
|
+
| [VS Code + Copilot](#vs-code--github-copilot) | `.vscode/mcp.json` | `servers` |
|
|
91
|
+
| [DeepSeek Harness (dsh)](#deepseek-harness-dsh) | `cordis.patch.yml` | — |
|
|
92
|
+
| [Codex CLI](#openai-codex-cli) | `~/.codex/config.toml` | `[mcp_servers.…]` |
|
|
93
|
+
| [Cline / Roo / Kilo](#cline--roo-code--kilo-code) | `cline_mcp_settings.json` | `mcpServers` |
|
|
94
|
+
| [Cherry Studio](#cherry-studio) · [Trae](#trae) | GUI | `mcpServers` |
|
|
95
|
+
| [Other hosts](#other-hosts) | see table | `mcpServers` |
|
|
96
|
+
|
|
19
97
|
## Prerequisites
|
|
20
98
|
|
|
21
99
|
- Install and start the [Web Print Expert client](https://webprintpdf.com/downloadApp/) (Windows 10/11, macOS 11+, Linux / Kylin / UOS)
|
|
@@ -386,6 +464,71 @@ Batch of mixed tasks:
|
|
|
386
464
|
> Every task's `extraOptions.action` must be the same (the client validates after a shallow merge), so
|
|
387
465
|
> do not mix `print` and `preview` per task; control it with the top-level `dry_run` instead.
|
|
388
466
|
|
|
467
|
+
## FAQ
|
|
468
|
+
|
|
469
|
+
### What is MCP, and why route printing through it?
|
|
470
|
+
|
|
471
|
+
MCP (Model Context Protocol) is the common protocol models use to call external tools. Once printing is
|
|
472
|
+
an MCP server, Claude, Cursor, Cline and dsh share one integration instead of each writing its own.
|
|
473
|
+
|
|
474
|
+
### Does it need a network connection?
|
|
475
|
+
|
|
476
|
+
No. Every request goes to the local `ws://127.0.0.1:16794/websocket/standard`; only the first `npx`
|
|
477
|
+
download needs the network.
|
|
478
|
+
|
|
479
|
+
### Do I need a separate license?
|
|
480
|
+
|
|
481
|
+
Previews (`extra_options.action = "preview"` / `dry_run: true`) render without printing and skip the
|
|
482
|
+
license check. Real output is validated by the Web Print Expert client; without a license it returns
|
|
483
|
+
`Not allowed to use, please purchase authorization`.
|
|
484
|
+
|
|
485
|
+
### Will it "secretly" print and waste paper?
|
|
486
|
+
|
|
487
|
+
`dry_run: false` really prints, matching the server-side API semantics. While building a layout pass
|
|
488
|
+
`dry_run: true`, then flip it to `false` once the preview looks right.
|
|
489
|
+
|
|
490
|
+
### Do thermal receipt and label printers work?
|
|
491
|
+
|
|
492
|
+
Yes. Thermal, dot-matrix and label printers all go through the system driver: shape the page with
|
|
493
|
+
`pdf_options.width` / `height`, pick the driver paper name with `print_options.paperFormat`, and add
|
|
494
|
+
`sharp: true` + `dpi` for crisper small text.
|
|
495
|
+
|
|
496
|
+
### How is this different from Playwright / Puppeteer printing?
|
|
497
|
+
|
|
498
|
+
Playwright renders in headless Chromium and then prints, which means downloading a browser engine and
|
|
499
|
+
losing driver-level controls (tray, sharpening, duplex flipping). This project hands the options to the
|
|
500
|
+
already-installed client and driver — closer to "actually printing on this machine".
|
|
501
|
+
|
|
502
|
+
### Does it work on macOS / Linux / domestic OSes?
|
|
503
|
+
|
|
504
|
+
The client supports Windows 10/11, macOS 11+, and Linux / Kylin / UOS. This MCP server is a plain Node
|
|
505
|
+
process (Node ≥ 18), so anywhere the client runs, it runs.
|
|
506
|
+
|
|
507
|
+
### Why does a preview only return a URL?
|
|
508
|
+
|
|
509
|
+
Previews return `pdfUrl` / `printPreviewUrl`; the MCP channel carries no image bytes. To let the model
|
|
510
|
+
"see" the page you need to convert the PDF to PNG first.
|
|
511
|
+
|
|
512
|
+
### Why do large files or large HTML payloads fail?
|
|
513
|
+
|
|
514
|
+
MCP's stdio transport caps a single message at 10MB by default, and Base64 inflates by ~4/3. Use
|
|
515
|
+
`printFile` (reads locally) or host the file and use `printPdfByUrl` / `printImageByUrl`.
|
|
516
|
+
|
|
517
|
+
### What if the client runs on a non-default port?
|
|
518
|
+
|
|
519
|
+
Set `WEBPRINT_PORT`; set `WEBPRINT_TIMEOUT` (milliseconds) for the request timeout. Pass both through the
|
|
520
|
+
host config's `env`.
|
|
521
|
+
|
|
522
|
+
### Can the ChatGPT or claude.ai web app use it?
|
|
523
|
+
|
|
524
|
+
Not yet. Those only accept remote HTTP MCP servers, so a local stdio server needs an HTTP bridge (not
|
|
525
|
+
provided here).
|
|
526
|
+
|
|
527
|
+
### Output is blank or clipped — why?
|
|
528
|
+
|
|
529
|
+
Usually the paper size does not match the content: pass `paper_format` or `pdf_options.width` / `height`
|
|
530
|
+
explicitly, and enable `printBackground: true` (backgrounds are not printed by default).
|
|
531
|
+
|
|
389
532
|
## Printing large files
|
|
390
533
|
|
|
391
534
|
MCP's stdio channel has a default **10MB** per-message limit (the SDK's `ReadBuffer`), so:
|
|
@@ -493,6 +636,14 @@ check that a preview appears.
|
|
|
493
636
|
- Client download: <https://webprintpdf.com/downloadApp/>
|
|
494
637
|
- web-print-pdf (npm): <https://www.npmjs.com/package/web-print-pdf>
|
|
495
638
|
- This repository: <https://github.com/weixiaoyi/mcp-web-print-pdf>
|
|
639
|
+
- Changelog: [CHANGELOG.md](https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/CHANGELOG.md)
|
|
640
|
+
- AI-readable summary: [llms.txt](https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/llms.txt)
|
|
641
|
+
|
|
642
|
+
## Contributing
|
|
643
|
+
|
|
644
|
+
Issues, PRs and doc fixes are welcome — see [CONTRIBUTING.md](https://github.com/weixiaoyi/mcp-web-print-pdf/blob/master/CONTRIBUTING.md).
|
|
645
|
+
|
|
646
|
+
If this saved you time, a ⭐ helps other people searching for "MCP printing" find it.
|
|
496
647
|
|
|
497
648
|
## License
|
|
498
649
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-web-print-pdf",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "MCP server for Web打印专家 / web-print-pdf
|
|
3
|
+
"version": "0.2.4",
|
|
4
|
+
"description": "MCP server for Web打印专家 / web-print-pdf: let AI agents print HTML, web pages, PDFs and images to local printers — silent printing, thermal receipts, labels, batch jobs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"mcp-web-print-pdf": "bin/mcp.js"
|
|
@@ -28,15 +28,23 @@
|
|
|
28
28
|
},
|
|
29
29
|
"keywords": [
|
|
30
30
|
"mcp",
|
|
31
|
+
"mcp-server",
|
|
31
32
|
"model-context-protocol",
|
|
32
33
|
"print",
|
|
33
34
|
"printer",
|
|
34
|
-
"
|
|
35
|
+
"printing",
|
|
35
36
|
"silent-print",
|
|
36
37
|
"html-to-pdf",
|
|
38
|
+
"print-html",
|
|
39
|
+
"web-print-pdf",
|
|
37
40
|
"thermal",
|
|
41
|
+
"thermal-printer",
|
|
38
42
|
"receipt",
|
|
39
|
-
"label"
|
|
43
|
+
"label",
|
|
44
|
+
"claude",
|
|
45
|
+
"cursor",
|
|
46
|
+
"ai-agent",
|
|
47
|
+
"llm"
|
|
40
48
|
],
|
|
41
49
|
"homepage": "https://webprintpdf.com/",
|
|
42
50
|
"repository": {
|