Skip to main content
Glama
swmr71

TepraMCP

by swmr71
README.md
# TepraMCP

キングジムのラベルプリンター **「テプラ」PRO SR5900P** を Wi-Fi/LAN 経由で操作する MCP サーバーです。
Claude などの MCP クライアントから、日本語テキスト・QRコード・画像を載せたラベルを直接印刷できます。

```
tepra_discover  … ネットワーク上のテプラを探す
tepra_status    … 電源・カバー・装着テープ幅を確認
tepra_preview   … 印刷せずにラベル画像を返す(テープを無駄にしない)
tepra_print     … 実際に印刷する
```

## 動作原理

SR5900P は UDP/9100 を制御チャネル、TCP/9100 をラスターデータの転送に使う独自プロトコルを話します。
本実装はその解析結果([Mine02C4](https://github.com/Mine02C4/TEPRA_PRO_SR5900P_analysis) /
[hikalium/sr5900p](https://github.com/hikalium/sr5900p))に基づく **非公式** の再実装です。
公式ドライバやテプラクリエイターのインストールは不要ですが、本体ファームウェアの更新で
動かなくなる可能性がある点はご承知おきください。

印刷解像度は 360dpi。ラベルは 1bpp に二値化され、テープ送り方向に 1 列ずつ転送されます。

## セットアップ

```bash
npm install && npm run build
```

MCP クライアントの設定に追加します(`claude_desktop_config.json` や `.mcp.json`):

```json
{
  "mcpServers": {
    "tepra": {
      "command": "node",
      "args": ["C:/Users/swmr7/Documents/GitHub/TepraMCP/dist/index.js"],
      "env": {
        "TEPRA_PRINTER_IP": "192.168.1.50"
      }
    }
  }
}
```

`TEPRA_PRINTER_IP` を設定しておくと毎回 IP を指定せずに済みます。未設定の場合は各ツールの
`printer` 引数で渡すか、まず `tepra_discover` で探してください。

### 環境変数

| 変数 | 用途 |
| --- | --- |
| `TEPRA_PRINTER_IP` | プリンターの IP アドレス(既定値) |
| `TEPRA_FONT` | 使用フォントの CSS スタック。未設定ならシステムの日本語フォントを自動選択 |
| `TEPRA_FONT_DIR` | 日本語フォントを持たない環境(コンテナ等)でフォントを読み込むディレクトリ |

## 使い方

自然言語で頼めば十分です。

> 「会議室A / 3F 北側」って2行のラベルを18mmテープで印刷して

> このURLのQRコード付きラベルをプレビューして

### ラベルの指定項目

| 引数 | 説明 |
| --- | --- |
| `text` | 行の配列。テープ幅いっぱいになるよう自動で文字サイズを決定 |
| `qr` | 左端に置く QR コードの内容 |
| `imagePath` / `imageBase64` | 貼り込む PNG/JPEG |
| `tapeWidthMm` | 4/6/9/12/18/24/36。省略時はプリンターから自動検出 |
| `lengthMm` / `minLengthMm` | ラベル長の固定/最低長の指定 |
| `align` | ラベルに余白がある場合の寄せ方向 |
| `marginMm` | 前後の余白(既定 2mm) |
| `bold` | 太字(既定 true) |
| `halfCut` | ハーフカット(`tepra_print` のみ、既定 true) |
| `copies` | 同一ラベルの連続印刷枚数(`tepra_print` のみ) |

## 制限

- 印刷は 1 行レイアウト([QR][画像][テキスト])に固定です。枠線や複雑な組版は未対応。
- テープカートリッジの色は判別しません(プリンターが幅しか返さないため)。
- `tepra_discover` は mDNS を使うため、プリンターと同一サブネットにいる必要があります。

## ライセンス

Apache-2.0

TDQS

A4.3/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clear, distinct purpose: discovery, status checking, preview, and printing. There is no overlap; an agent can easily choose the right tool for the task.

Naming Consistency5/5

All tool names follow a consistent pattern of 'tepra_' followed by a verb (discover, status, preview, print). This makes the tool set predictable and easy to navigate.

Tool Count5/5

Four tools is a well-scoped count for a printer control server. Each tool serves a necessary function in the label printing workflow, and none are redundant.

Completeness5/5

The tool set covers the full workflow: discovering printers, checking status, previewing the label, and printing. There are no obvious missing operations for the domain.

Maintenance

ActivitySlowing
ResponsivenessNo issues