print-blocks
Enables printing structured documents to ESC/POS thermal printers via a CUPS queue, with tools for printer info, print jobs, and template management.
README
print-blocks
print-blocks is a small TypeScript service that prints structured documents to ESC/POS thermal printers.
It has an API endpoint /print that accepts a JSON payload describing a document as an array of blocks, renders them to ESC/POS bytes with react-thermal-printer, and submits the resulting bytes to a CUPS printer with lp.
The service has no UI. It exposes:
POST /printfor authenticated print jobs.GET /healthzfor unauthenticated liveness checks.GET /openapi.jsonfor generated OpenAPI JSON.GET /docsfor an interactive Scalar API reference whenEXPOSE_DOCS=true.GET /llms.txtfor LLM-friendly Markdown API documentation whenEXPOSE_LLMS_TXT=true.ALL /mcpfor authenticated MCP clients whenEXPOSE_MCP=true.
Requirements
- Node.js 24 and pnpm 10 for local development.
- CUPS configured on the host.
- A CUPS printer queue that accepts raw/native ESC/POS data.
- The CUPS client command
lpavailable wherever the app runs.
The production container installs cups-client, so lp is available inside the image.
Configuration
Copy the example environment file and edit it:
cp .env.example .env
Note:
- Documentation endpoints are disabled by default. Set
EXPOSE_DOCS=trueto enable/docsandEXPOSE_LLMS_TXT=trueto enable/llms.txt. - The MCP endpoint is disabled by default. Set
EXPOSE_MCP=trueand provide a separateMCP_TOKENwith at least 32 characters to enable/mcp. PRINTER_WIDTHconfigures the printer text width in characters and defaults to48.PRINTER_DOT_WIDTHconfigures the raster width used for image-like blocks and defaults to576dots. Set it explicitly when your printer mode uses a different raster width, such as384dots.- Image blocks accept base64-encoded data through the
dataproperty. Supported image formats are JPEG, PNG, WebP, and SVG. Remote image URLs are disabled by default. SetALLOW_REMOTE_IMAGE_URLS=trueto allow image blocks to use an HTTPSurlinstead. Remote image fetching is intentionally strict: only HTTPS URLs with public domain hostnames are accepted, direct IP addresses and credentials are rejected, redirects are not followed, downloaded bytes are limited byMAX_REMOTE_IMAGE_BYTES, fetches time out afterREMOTE_IMAGE_TIMEOUT_MS, and decoded image input is limited byMAX_IMAGE_INPUT_PIXELS. These restrictions are in place to prevent abuse and security issues, but enabling remote image URLs is only recommended in trusted environments.
Development
Install dependencies:
pnpm install
Run the dev server:
pnpm dev
SVG-backed block previews are available in development at:
http://localhost:3000/preview
Run checks:
pnpm typecheck
pnpm lint
pnpm format:check
pnpm test
pnpm build
API
POST /print
Headers:
Content-Type: application/json
Authorization: Bearer <API_TOKEN>
Body:
{
"blocks": [
{
"type": "text",
"content": "Hello from print-blocks",
"align": "center",
"bold": true
}
]
}
Success response:
{
"ok": true
}
GET /healthz
Returns:
{
"ok": true
}
GET /openapi.json
Returns the OpenAPI specification for the API.
GET /docs
Returns an interactive API reference backed by Scalar and /openapi.json. This endpoint is only registered when EXPOSE_DOCS=true.
GET /llms.txt
Returns Markdown API documentation generated from the OpenAPI specification. This endpoint is only registered when EXPOSE_LLMS_TXT=true.
ALL /mcp
Serves a stateless MCP server over streamable HTTP. This endpoint is only registered when EXPOSE_MCP=true and requires Authorization: Bearer <MCP_TOKEN>.
Available tools:
get_inforeturns printer settings, service limits, supported blocks, and templates.printrenders print instructions and submits them to the configured printer.list_templateslists examplary print templates that can be used as starting points or inspiration for print requests.get_templatereturns Markdown instructions and the template's JSON structure for a given template id.
Manual smoke test
After the app is running:
curl -X POST "http://localhost:3000/print" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_TOKEN" \
--data '{"blocks":[{"type":"text","content":"Hello from print-blocks","align":"center"}]}'
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。