PaperSprocket

io.github.inde-xv1.0.0更新于 Oct 1, 2026

EU-hosted HTML-to-PDF rendering for agents and MCP clients. Temporary document processing.

已验证STDIO仅桌面Developer ToolsFiles & Storage

概览

AI 生成的概览

通过托管的 PaperSprocket API 将 HTML 渲染为 PDF,并查询账户的预付费余额。

功能
仅提供两个工具。render_html_to_pdf 接收 HTML 字符串和可选的页面设置(A4 或 Letter、纵向或横向、页边距、是否打印背景),返回 application/pdf 资源、可写时的本地文件路径,以及 render_id、page_count、charged_cents、balance_cents 等渲染元数据。check_balance 返回所配置账户的 account_id、balance_cents、currency 和 page_price_cents。
适用场景
适合需要把生成的 HTML 或 CSS 转成 PDF 文档的场景,例如发票、报告或格式化导出,也适合在渲染前后查看预付费余额。它是精简的渲染与余额查询服务,不是文档管理系统。
运行要求
需要 Node.js 20 或更高版本,以 stdio 方式在本地运行,可通过 npx papersprocket-mcp 或源码检出启动。需要 PaperSprocket 账户和 API 密钥,通过环境变量 PAPERSPROCKET_API_KEY 或服务器的 .env 文件提供。可选设置 PAPERSPROCKET_BASE_URL 和 PAPERSPROCKET_MCP_OUTPUT_DIR。需要访问 PaperSprocket API 的网络连接。
安装前请注意
渲染按每页 0.02 美元从预付费余额中扣费,重复渲染会产生费用;服务器会返回 charged_cents 和 balance_cents。PAPERSPROCKET_API_KEY 是密钥,从服务器端配置读取并作为 Authorization 请求头发送,不要写入客户端配置或提交到仓库。渲染出的 PDF 还可能写入本地输出目录,且你发送的 HTML 会由第三方托管服务处理。

安装

在 SourceWeft 中

  1. 打开 控制台中的 PaperSprocket,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

PaperSprocket MCP server

A Model Context Protocol (MCP) server that gives MCP clients direct access to the PaperSprocket API. It exposes exactly two tools:

ToolDescription
render_html_to_pdf(html, page?)Render HTML to a PDF through the PaperSprocket API. Returns the PDF as an application/pdf MCP resource (base64 blob), a local file path when the server can write one, and render metadata (render_id, page_count, charged_cents, balance_cents). Billed to the configured account.
check_balance(account_id)Read the prepaid balance of the configured PaperSprocket account. Returns account_id, balance_cents, currency, and page_price_cents.

This is a minimal native MCP server built directly on @modelcontextprotocol/sdk. No top-up tools, no API-key-management tools — just render and balance-check.

What is PaperSprocket?

PaperSprocket is a hosted API that turns HTML into PDFs. You send it HTML, it returns a well-formed PDF. There is no business-field schema to learn: you control the layout with your own HTML and CSS, PaperSprocket handles the PDF processing. See the official documentation.

Requirements

  • Node.js >= 20
  • A PaperSprocket API key. The server reads it from server-side config only (environment or .env) — it is never a caller-supplied tool argument, and is never embedded in source, examples, or this document.

Install

Run via npx (primary)

bash
npx -y papersprocket-mcp

The package papersprocket-mcp is published to npm and registered in the official MCP Registry under identity io.github.inde-x/papersprocket (active, version 1.0.0). Point your MCP client at npx -y papersprocket-mcp and provide PAPERSPROCKET_API_KEY in the client's environment (the server reads it server-side only).

From source (optional / development)

bash
git clone https://github.com/inde-x/papersprocket-mcp.gitcd papersprocket-mcpnpm cicp .env.example .env   # then set PAPERSPROCKET_API_KEY (see Configuration)

Configuration

The server loads <serverdir>/.env at startup (it does not override already-set environment variables). .env is gitignored.

VariableRequiredDefaultPurpose
PAPERSPROCKET_API_KEYyes—Your PaperSprocket API key. Secret/config state — never a tool argument.
PAPERSPROCKET_BASE_URLnohttps://papersprocket.com/apiAPI base URL. Fixed/config state.
PAPERSPROCKET_MCP_OUTPUT_DIRno./outputDirectory where rendered PDFs are also written (best-effort) for filesystem-local clients.

Example .env (replace the placeholder — never commit a real key):

bash
PAPERSPROCKET_API_KEY=psk_your_api_key_here# PAPERSPROCKET_BASE_URL=https://papersprocket.com/api# PAPERSPROCKET_MCP_OUTPUT_DIR=./output

Run (stdio)

bash
node server.js                 # MCP over stdionode server.js --list-tools    # print tool schemas, then exit

Connect an MCP client

Point your MCP client at a stdio server:

# primary — published npm distribution:Command:   npxArguments: -y papersprocket-mcp
# or a local source checkout:Command:   nodeArguments: /path/to/papersprocket-mcp/server.js

PAPERSPROCKET_API_KEY is provided via the server .env or environment — never in the client configuration.

MCP Inspector

bash
npx @modelcontextprotocol/inspector node /path/to/papersprocket-mcp/server.js

List tools → confirm exactly two: render_html_to_pdf and check_balance.

Tool schemas

render_html_to_pdf

json
{  "html": { "type": "string", "description": "HTML to render (non-empty)." },  "page": {    "properties": {      "size":            { "enum": ["A4", "Letter"] },      "orientation":     { "enum": ["portrait", "landscape"] },      "margin_mm":       { "top|right|bottom|left": { "type": "number", "minimum": 0, "maximum": 50 } },      "print_background": { "type": "boolean" }    }  }}
  • html — required, non-empty string.
  • page — optional. Defaults mirror the service's closed v1 schema: size A4, orientation portrait, margin_mm 10 on all sides, print_background true. Unknown fields are rejected.

Result (two MCP content blocks):

  1. text — metadata JSON: tool, format, render_id, page_count, charged_cents, balance_cents, bytes, file_path, idempotency_key.
  2. resource — application/pdf blob (base64) with a file:// (or urn:) URI.

check_balance

json
{ "account_id": { "type": "string" } }
  • account_id — required, non-empty string.

Result: { account_id, balance_cents, currency, page_price_cents } (text block).

Idempotency

  • A fresh random idempotency key is generated for each logical render.
  • On a transient network failure the server retries up to 2× reusing the same key, so a retry of one logical render cannot double-charge.
  • Server-side, PaperSprocket dedupes on (Idempotency-Key, request hash), so a true replay returns the original result without a second debit.

Security / secret boundary

  • PAPERSPROCKET_API_KEY is read from .env / environment — it is not a field in any tool input schema.
  • PAPERSPROCKET_BASE_URL is fixed/config state, not an agent-controlled argument.
  • The key is sent only as the Authorization HTTP header. No other credentials exist.
  • Rendered PDFs written to output/ are your own content; the directory is gitignored.

Pricing

  • $10 initial prepaid credit
  • $10 top-ups
  • $0.02 / page

Getting a key

Create a PaperSprocket account to get your API key and prepaid credit:

License

MIT — see LICENSE.

来源:README.md,提交 a021f7a

工具

0
工具元数据尚未被收录。

版本历史

1
  1. v1.0.0最新Oct 1, 2026