Skip to main content
Glama
label-pop-mcp
by kntys

label-pop-mcp

CSVとテンプレート(JSON)から、名入れラベルと店頭POPのPDFを一括生成する MCP サーバーです。 「CSVの名簿から名札ラベルを全員分まとめて作る」「商品リストからPOPを一括で作る」のような、 単純だけど件数が多くて手作業だと辛い仕事を、AIクライアント(Claude Code / Claude Desktop など)から 呼び出せる形にしたサンプルです。

名入れラベルの出力例 POPの出力例

できること

  • preview_layout — テンプレートのレイアウト確認(ページ・ラベル寸法、列×行、1ページの枚数、収まりチェック)

  • generate_pdf — CSVの各行をテンプレートに流し込んでPDFを生成

    • テキスト内の {列名} がCSVの値に置き換わります

    • 文字がブロック幅に収まらない場合は自動で縮小します(収まらなかった場合は警告を返します)

    • CSVは UTF-8 / Shift_JIS 対応。列の過不足や重複ヘッダーはエラーとして報告します

同梱テンプレート:

  • templates/name_label.json — 名入れラベル(A4・90×55mm・2列×5段、ガイド線つき)

  • templates/pop.json — 店頭POP(A4・1枚もの)

Related MCP server: niimbot-mcp

セットアップ

pip install -r requirements.txt
python server.py            # stdio で起動
python smoke_test.py        # 動作確認(MCPクライアントとして接続し、生成まで検証)

日本語フォントについて

PDFへの日本語描画にはフォントファイルが必要です。以下の順で探します。

  1. テンプレートJSONの font_path

  2. 環境変数 LABEL_POP_FONT(太字は LABEL_POP_FONT_BOLD)

  3. OSの既定候補(Noto Sans CJK / ヒラギノ角ゴシック / Yu Gothic など)

見つからない場合は、その旨のエラーを返します。

MCPクライアントへの登録例

Claude Code:

claude mcp add label-pop -- python /path/to/mcp-label-pop-sample/server.py

Claude Desktop(claude_desktop_config.json):

{
  "mcpServers": {
    "label-pop": {
      "command": "python",
      "args": ["/path/to/mcp-label-pop-sample/server.py"]
    }
  }
}

登録後は、たとえば次のように頼めます。

samples/people.csv を templates/name_label.json でPDFにして、out/labels.pdf に出して

テンプレートの書き方

座標はすべて mm、原点はラベルの左上です。

{
  "name": "名入れラベル(A4・90x55mm・2列5段)",
  "page":  { "width_mm": 210, "height_mm": 297 },
  "label": { "width_mm": 90,  "height_mm": 55 },
  "grid":  { "columns": 2, "rows": 5, "margin_x_mm": 15, "margin_y_mm": 11, "gap_x_mm": 0, "gap_y_mm": 0 },
  "guides": true,
  "blocks": [
    { "text": "{company}", "x_mm": 5, "y_mm": 6,  "width_mm": 80, "size": 10, "align": "center" },
    { "text": "{name}",    "x_mm": 5, "y_mm": 15, "width_mm": 80, "size": 26, "align": "center", "bold": true },
    { "text": "{title}",   "x_mm": 5, "y_mm": 38, "width_mm": 80, "size": 11, "align": "center" }
  ]
}
  • blocks[].text の {列名} がCSVの列と対応します(固定の文字列だけでも構いません)

  • align は left / center / right、bold: true で太字フォントを使います

  • guides: true でラベルの外枠(切り取りガイド)を描きます

注意

  • このサーバーはローカルで動く stdio サーバーです。ツールに渡すパスは自分のPC上のファイルを指し、 サーバーは実行ユーザーの権限でファイルを読み書きします。信頼できるクライアントからのみ使ってください。

  • 出力先に同名ファイルがある場合は上書きされます。

ライセンス

MIT


English summary

A small sample MCP server (Python + FastMCP + PyMuPDF) that batch-generates name-label and point-of-purchase (POP) PDFs from a CSV file and a JSON layout template. Tools: preview_layout (validate a template) and generate_pdf (fill {column} placeholders per CSV row, auto-shrink text to fit, grid layout across pages). Japanese fonts are resolved from the template, the LABEL_POP_FONT env var, or common OS locations.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables printing text, QR codes, and images directly to NIIMBOT B1 BLE label printers without vendor apps or cloud, with orientation control, fit validation, and local preview tools.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables creating PDFs from text, Markdown, or tabular data and editing existing ones through metadata and page operations, with support for CJK font embedding, tagged PDF/PDF-UA, and PDF/A archival output.
      20
      264 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables printing labels whose layout adapts to the roll reported by a CUPS/IPP label printer, as well as PDF, Markdown, and HTML documents, with preview, copies, duplex, page ranges, and print-job management.
      7
      MIT