Skip to main content
Glama

TianshangScribe

中文版

PyPI CI ライセンス TianshangScribe MCPサーバー

開発者、CLI自動化、AIエージェント向けのクロスプラットフォームOffice文書処理。Word(.docx)、Excel(.xlsx)、PowerPoint(.pptx)文書の作成、編集、テンプレート入力、変換に対応。LaTeX風マークアップ、ネイティブOMML数式、テンプレートエンジン({{placeholders}}、{{#each}}ループ、{{#if}}条件)を搭載。stdio、SSE、Streamable HTTPトランスポート上で7つのツール(作成、編集、テンプレート入力、変換、抽出、検証、比較)を備えたMCPサーバーを同梱。ベアラートークン認証とレート制限に対応。

警告:不安定なAPI \u2014 破壊的変更の可能性あり

このプロジェクトはプレリリース版(0.x)です。CLIオプション、MCPツールのシグネチャ、テンプレート構文、出力形式は固定されておらず、予告なく変更される場合があります。 互換性のコミットメント:破壊的変更は、少なくとも1リリース前にCHANGELOGで告知され、移行ガイドが添付されます。 本番環境で使用する場合は、特定のバージョンに固定し、アップグレード前にCHANGELOGを確認してください。

インストール

pip install tianshang-scribe

# Or from source:
git clone https://github.com/Tianshang301/TianshangScribe.git
cd TianshangScribe
pip install -e ".[dev]"

Linuxデプロイメント

Docker(Streamable HTTP上のMCPサーバーに推奨):

git clone https://github.com/Tianshang301/TianshangScribe.git
cd TianshangScribe
docker compose up -d
# Streamable HTTP MCP Server at http://localhost:8080/mcp
# (override transport / auth / rate limits via TIANSHANG_SCRIBE_* env vars)

.debパッケージ(Debian / Ubuntu):

# Download from GitHub Releases
sudo dpkg -i tianshang-scribe_0.7.1_all.deb
tianshang-scribe --help

pipx(スタンドアロンCLI):

pipx install tianshang-scribe
tianshang-scribe --help

Python 3.10以上が必要です。python-docx・openpyxl・python-pptx・typer・rich・lxml

Related MCP server: docx-forge-mcp

クイックスタート

# Create a Word document
tianshang-scribe -w --create -a "Hello World" -o hello.docx

# Replace text (--regex for regex mode)
tianshang-scribe input.docx -r "old" --replace-new "new" -o output.docx

# LaTeX markup with nesting
tianshang-scribe -w --create --latex-style \
  -s "font=Times New Roman,size=14" \
  -a "\bfseries{\itshape{bold italic}} \fontsize{24}{Heading} \color{FF0000}{red}" \
  -o styled.docx

# Math formulas —auto-converted to native Word OMML
tianshang-scribe -w --create \
  --math "x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}" \
  --math "\sum_{i=0}^{n} i^2" \
  -o formulas.docx

# Template filling (JSON / CSV / YAML →{{placeholder}})
tianshang-scribe template.docx -t data.json -o filled.docx

# Convert to PDF (office2pdf ~2MB, or LibreOffice fallback)
tianshang-scribe input.docx --topdf -o output.pdf

# MCP Server —stdio mode (Claude Code / Cursor)
python -m tianshang_scribe.mcp.server

# MCP Server —SSE mode (Dify / Coze / FastGPT)
python -m tianshang_scribe.mcp.server --transport sse --port 8080

# Excel: import CSV, sort, export JSON
tianshang-scribe -e --create --from-csv data.csv --sort "A1:A10 asc" --to-json -o out.json

# Excel: add formula, protect workbook
tianshang-scribe budget.xlsx --formula "B10 =SUM(B2:B9)" --protect "p@ss" -o protected.xlsx

グローバルオプション

パラメータ

説明

input_file

入力文書パス(--create時は省略)

-w --word

Word文書を処理

-e --excel

Excelワークブックを処理

-p --ppt

PowerPointプレゼンテーションを処理

-o --output

出力ファイルパス

--force

既存ファイルの上書きを許可

--topdf

PDFとして出力

--stdin

標準入力から読み取り

--stdout

標準出力へ書き出し

-w/-e/-pが省略された場合、文書タイプは入力ファイルの拡張子から推測されます。

操作

オプション

説明

-cr --create

空の文書を作成

--create -w

-a --add

テキストを追加

-a "Hello"

--column

--addの対象列

--column 2

-r --replace

検索して置換

-r "foo" --replace-new "bar"

-d --delete

コンテンツを削除

-d "keyword"

-cl --clear

コンテンツ/書式/リンクをクリア

--clear formats

-m --modify

コンテンツを変更

-m "old" --modify-new "new"

-s --style

スタイルを設定

-s "font=Times,size=14,bold"

-t --template

テンプレート入力

-t data.json

-x --extract

データを抽出(math/latexなど)

-x latex

--meta

プロパティを設定

--meta "title=Report,author=John"

--latex-style

LaTeX解析を有効化

--math

数式を追加(Word)

--math "\frac{a}{b}"

--math-style

数式解析方式(office/mathtype)

--math-style mathtype

--math-font

OMML数式フォント(デフォルト:Cambria Math)

--math-font "Times New Roman"

--math-mtef

MathType OLEオブジェクトとして埋め込む(MTEF)

--math "\frac{a}{b}" --math-mtef

--heading

見出しを追加(Word)

--heading "level:1 text:Intro"

--regex

正規表現モード

--replace/--deleteと併用

--merge

ファイルを結合

--merge "a.docx,b.docx"

--split

文書を分割(Excelのみ:--split by-sheet

--split by-sheet

--comment

コメントを追加(Word)/ ノートを追加(PPT)

--comment "2 Note text"

--add-table

表を追加(Word)

--add-table "H1,H2|a1,a2"

--chart-add

グラフを追加(Excel)

--chart-add "type=bar data=B1:C10"

--batch

バッチモード

--batch

--files

バッチ用グロブパターン

--files "reports/*.docx"

--schedule-db

スケジュール用SQLite DBパス

--schedule-db ~/.tianshang-scribe/schedules.db

--schedule-add

スケジュールを登録

--schedule-add "daily|0 9 * * *|echo hi"

--schedule-rm

スケジュールを削除

--schedule-rm daily

--schedule-list

スケジュールを一覧表示

--schedule-list

--schedule-run

スケジュールを今すぐ実行

--schedule-run daily

--schedule-run-all

実行期限が来たスケジュールをすべて実行

--schedule-run-all

--run-script

スクリプトをサンドボックスで実行

--run-script build.py

--stdin

標準入力から読み取り

--stdout

標準出力へ書き出し

Word固有オプション

オプション

説明

--heading

見出しを追加

--heading "level:1 text:Intro"

--math

数式を追加

--math "\frac{a}{b}"

--latex-style

LaTeXマークアップを有効化

--toc

目次を生成

--toc

--section-break

セクション区切りを挿入

--section-break

--header

ページヘッダーを設定

--header "Chapter 1"

--footer

ページフッターを設定

--footer "Page X"

--watermark

テキスト透かし

--watermark "DRAFT"

--tomd

Markdownに変換

--tomd

--tohtml

HTMLに変換

--tohtml

Excel固有オプション

オプション

説明

--sheet-add

ワークシートを追加

--sheet-add "Q1"

--sheet-delete

ワークシートを削除

--sheet-delete "Sheet2"

--sheet-rename

ワークシート名を変更

--sheet-rename "Old New"

--column-width

列幅を設定

--column-width "2=20"

--row-height

行の高さを設定

--row-height "3=30"

--formula

セル数式を設定

--formula "A1 =SUM(B1:B10)"

--from-csv

CSVデータをインポート

--from-csv data.csv

--sort

範囲を並べ替え

--sort "A1:A10 asc"

--chart-add

グラフを追加

--chart-add "type=bar data=B1:C10"

--protect

パスワードを設定

--protect "p@ss"

--unprotect

パスワードを解除

--unprotect

--to-csv

CSVとしてエクスポート

--to-json

JSONとしてエクスポート

--to-html

HTMLとしてエクスポート

LaTeX風マークアップ

--addコンテンツに以下のマークアップを埋め込みます。--latex-styleで有効化。ネストに対応。

構文

効果

\bfseries{text}

太字

\itshape{text}

斜体

\scshape{text}

スモールキャップス

\underline{text}

下線

\rmfamily{text}

ローマン体(セリフ)

\sffamily{text}

サンセリフ

\ttfamily{text}

等幅

\fontfamily{Arial}{text}

特定フォント

\fontsize{18}{text}

フォントサイズ(pt)

\color{FF0000}{text}

色(16進)

\centering{...}

中央揃え *

\raggedright{...}

左揃え *

\raggedleft{...}

右揃え *

\linespread{1.5}{...}

行間 *

\indent{...} / \noindent{...}

インデント *

\heading{2}{Title}

見出しを挿入

\newpage

改ページ

\includegraphics{path}

画像を挿入

* 段落レベルの書式設定(新しい段落を作成します)。

フォント設定

コマンド

効果

\setmainfont{Name}

デフォルトの欧文フォント

\setCJKmainfont{Name}

デフォルトのCJKフォント

\setsansfont{Name}

サンセリフフォント

\setCJKsansfont{Name}

CJKサンセリフフォント

\setmonofont{Name}

等幅フォント

\setCJKmonofont{Name}

CJK等幅フォント

Word OOXMLはネイティブにw:ascii(欧文)とw:eastAsia(CJK)フォントを分離しており、混在テキストでの自動フォント切り替えを実現します。

数式

--math によるLaTeX数式は、ネイティブなWord OMML(Office Math Markup Language)に変換されます。コンバーターは、ネストした不変トークンツリー(分数、根号、N項演算、上付き/下付き、アクセント、スタイル付き、区切りトークン)を処理する手書きの再帰下降パーサー(式 → 項 → 因子 → 原子)であり、プリコンパイル済み正規表現とゼロコピーの引数スライシングを備えたO(1)コマンドテーブルでディスパッチされます。--math-font "Times New Roman" を使用すると、WordのデフォルトのCambria Math(<m:mathPr><m:mathFont>)の代わりに、MathTypeスタイルのセリフフォントで数式をレンダリングできます。--math-style mathtype は、MathType互換性のためのLaTeX解析方言を切り替えます。--math-mtef を使用すると、数式を実際のMathType OLEオブジェクト(MTEFバイナリ)として埋め込むことができます。これはレガシーなMathType(6.x以前)で編集可能で、--extract math が読み戻すのと同じ形式です。出力はリリース間でバイト単位で安定しています(ゴールデンスナップショット回帰テストスイートで保護されています)。

対応構文

カテゴリ

コマンド

分数

\frac{分子}{分母}

根号

\sqrt{内容} \sqrt[n]{内容}

上付き/下付き

x^{2} x_{i} x_{i}^{n}

総和/積分

\sum \int \oint \prod \coprod \bigcup \bigcap \bigvee \bigwedge

極限

\lim_{x \to 0} \max \min \sup \inf

名前付き関数

\sin \cos \tan \cot \sec \csc \log \ln \det \Pr \gcd \deg \dim \hom \ker \arg

ギリシャ文字

\alpha \beta \gamma\Gamma \Delta \Theta

記号

\pm \times \div \cdot \infty \partial \nabla \forall \exists

関係演算子

\leq \geq \neq \approx \equiv \propto \subset \supset \in

矢印

\to \rightarrow \leftarrow \mapsto \uparrow

アクセント

\hat{x} \bar{x} \tilde{x} \dot{x} \ddot{x} \vec{x} \widehat{x} \widetilde{x}

括弧

\left( \right) \left[ \right] \left\{ \right\}

数式フォント

\mathrm{abc} \mathbf{abc} \mathit{abc} \mathcal{ABC} \mathbb{ABC} \mathsf{abc} \mathtt{abc}

数式タイポグラフィ

主流の数学ジャーナル標準(AMS、Elsevier、Springer)に準拠:

内容

スタイル

単文字変数

イタリック

a b x y

数字

直立

0 1 2

名前付き関数

直立

\sin \cos \log

小文字ギリシャ文字

イタリック

\alpha \beta \gamma

大文字ギリシャ文字

直立

\Gamma \Delta \Theta

自動検出

--add テキスト内のコマンドは、$...$ で囲まなくても自動的に数式として認識されます:

  • 引数付き: \frac \sqrt \sum \int \prod \lim

  • アクセント: \hat{x} \bar{x} \vec{x} など

  • 単項演算子: \sin \cos \tan \log \ln など

  • プレーンテキスト内の H_{2}Om^{2} はUnicodeの下付き/上付き文字(H₂O / m²)になります

スタイル構文

--style はカンマ区切りのキーと値のペアを使用します:

--style "font=Times New Roman,size=14,bold,italic,color=FF0000,align=center"

キー

エイリアス

説明

font

font_name, font-family

フォント名

欧文フォント

cjk-font

cjk_font_name, cjk-font-family

フォント名

CJKフォント

size

font_size, font-size

pt

フォントサイズ

bold

フラグ

太字

italic

フラグ

イタリック

underline

フラグ

下線

color

font_color, font-color

FF0000

16進カラー

align

alignment

left/center/right/justify

配置

ブールキー(bold italic underline)は、存在する場合 True になります。

テンプレート埋め込み

JSON、CSV、YAMLデータソースに対応しています。ドキュメント内の {{placeholder}} を置換します。ネストしたオブジェクトはドット記法で展開されます。ループはリスト値を反復処理します。条件文はブロックを表示/非表示にします。

{
  "name": "John Doe",
  "date": "2026-07-28",
  "user": { "city": "Beijing" },
  "show": true,
  "paid": false,
  "items": [
    { "product": "Widget", "price": "10" },
    { "product": "Gadget", "price": "20" }
  ]
}
{{name}}              → John Doe
{{user.city}}         → Beijing
{{#each items}}       → repeats the block for each item
  {{product}}: {{price}}
{{/each}}
{{#if show}}          → shown only when show is truthy
  Confidential content
{{/if}}
{{#if role=admin}}    → shown only when role equals "admin"
  Admin dashboard
{{/if}}
{{#unless paid}}      → shown only when paid is falsy
  Payment required
{{/unless}}

Excel機能

機能

CLIオプション

シート管理

--sheet-add --sheet-delete --sheet-rename

列/行サイズ

--column-width --row-height

数式

--formula "A1 =SUM(B1:B10)"

データインポート

--from-csv

データエクスポート

--to-csv --to-json --to-html

並べ替え

--sort "A1:A10 asc"

グラフ

--chart-add "type=bar data=B1:C10"

保護

--protect --unprotect

PPT機能

機能

説明

スライド管理

スライドの追加、削除、並べ替え(--slide-add--slide-delete--slide-move

レイアウト

名前またはインデックスでスライドレイアウトを適用(--layout

発表者ノート

発表者ノートを追加(--notes

数式

$...$ / $$...$$ をネイティブOMMLとしてレンダリング

トランジション

スライドトランジションを設定 —フェード、プッシュ、ワイプなど(--transition

エクスポート

スライドを画像として保存(--toimg)、PDFに変換(--topdf

メディア圧縮

画像を圧縮(--compress-media "1920,80"

保護

パスワードの設定/解除(--protect--unprotect

終了コード

コード

意味

0

成功

1

一般エラー

2

引数エラー

3

未実装

MCPサーバー

TianshangScribeにはMCP(Model Context Protocol)サーバーが含まれています —AIエージェントはOfficeドキュメントの作成、編集、テンプレート埋め込み、変換、データ抽出ができます。

クイック接続

stdio(Claude Code、Cursor):

{"mcpServers": {"tianshang-scribe": {
  "command": "python", "args": ["-m", "tianshang_scribe.mcp.server"]
}}}

SSE(Dify、Coze、FastGPT):

python -m tianshang_scribe.mcp.server --transport sse --host 0.0.0.0 --port 8080
{"mcpServers": {"tianshang-scribe": {
  "url": "http://localhost:8080/sse", "transport": "sse"
}}}

ツール(7)

ツール

説明

create_office_document

構造化コンテンツブロックで .docx / .xlsx / .pptx を作成

edit_office_document

既存ドキュメントへの置換、削除、変更、スタイル設定、追加操作

fill_template

データで {{placeholders}} を埋める; {{#each}} / {{#if}} に対応

convert_document

形式間の変換(docx↔pdf/md/html、xlsx↔csv/json)

extract_document_data

メタデータ、全文、またはドキュメント構造を抽出

validate_template

埋め込み前にテンプレートのプレースホルダーをデータと照合

compare_documents

2つの .docx ファイル間の段落レベル差分

機能

機能

詳細

プロトコル

MCP 2024-11-05 · stdio + SSE · JSON-RPC 2.0

リソース

resources/list + resources/read —ドキュメントを読み取り可能なURIとして公開

プロンプト

5つの組み込みワークフローテンプレート(prompts/list + prompts/get

進捗

PDF変換および長時間操作中の notifications/progress

レスポンス

マルチタイプ content[]: テキストメッセージ + リソース(ファイルURI、MIMEタイプ、サイズ)

スキーマ

すべてのパラメータに enumdefaultexamplesminimum/maximum 制約

本番環境(SSEのみ)

# With authentication
TIANSHANG_SCRIBE_AUTH_TOKEN="secret" \
python -m tianshang_scribe.mcp.server --transport sse --host 0.0.0.0 --port 8080

# Health check
curl http://localhost:8080/health
# {"status":"ok","version":"0.7.1","uptime_seconds":3600,"active_sessions":3,"tools_available":7}

# CORS whitelist
python -m tianshang_scribe.mcp.server --transport sse --cors-origins "https://coze.com,https://dify.ai"

エンドポイント: GET /health · GET /sse · POST /message?session_id=X

完全なドキュメント: docs/mcp/README.md

python tests/integration/mcp/mcp_stdio_smoke.py     # 9/9 quick tests (stdio)
python tests/integration/mcp/test_sse.py        # 3/3 SSE transport tests
python tests/integration/mcp/mcp_agent_sim.py      # 11-scenario Agent simulation

アーキテクチャ

src/
└── tianshang_scribe/    # importable package (tianshang_scribe.*)
    ├── cli/               # Typer CLI entry
    │  ├── main.py        # Command parsing & dispatch
    │  └── global_opts.py # File path / type inference
    ├── core/              # Document engine abstraction
    │  ├── document.py    # DocumentABC unified interface
    │  ├── word_engine.py # Word engine (python-docx)
    │  ├── excel_engine.py# Excel engine (openpyxl)
    │  └── ppt_engine.py  # PPT engine (python-pptx)
    ├── rendering/         # Style & formula rendering
    │  ├── styles.py      # TextStyle dataclass
    │  ├── latex_parser.py # LaTeX markup parser
    │  ├── math_omml.py   # LaTeX →OMML math converter
    │  └── template.py    # Template filling engine
    ├── transform/         # Format conversion
    │  └── pdf.py         # PDF export (office2pdf + LibreOffice)
    ├── mcp/                    # MCP Server (official mcp SDK 2.x)
    │  ├── server.py           # build_server + entry (stdio / SSE / Streamable HTTP)
    │  ├── transport.py        # transport wiring + ASGI middleware
    │  ├── schemas.py          # pydantic models + as_dict
    │  ├── auth.py             # Bearer token auth
    │  ├── rate_limit.py       # token bucket rate limiting
    │  ├── metrics.py          # Prometheus-style metrics
    │  ├── security.py         # read-only / destructive classification
    │  ├── prompts.py          # 5 prompt workflows
    │  ├── tools/              # 7 Agent tools
    │  │  ├── _registry.py    # tool registry (schemas auto-derived)
    │  │  ├── create.py / edit.py / template.py / convert.py
    │  │  ├── validate.py / compare.py
    │  └── errors.py           # structured error codes + fixes
    └── utils/             # Utility functions
        └── file_utils.py

技術スタック

コンポーネント

テクノロジー

CLI

Typer + Rich

Word

python-docx

Excel

openpyxl

PPT

python-pptx

数式

手書きの再帰下降パーサー → OMML XML(不変トークンツリー、コマンドディスパッチテーブル)

テンプレート

カスタムエンジン({{placeholder}}、{{#each}}、{{#if}})

PDF

office2pdf(~2MB Rustバイナリ、依存関係ゼロ)+ LibreOfficeフォールバック

品質

pytest(936テスト) · ruff · mypy

EXEのビルド

pip install pyinstaller
pyinstaller --onefile --name tianshang-scribe --hidden-import openpyxl.cell._writer --hidden-import openpyxl.cell.read_only --hidden-import openpyxl.styles --hidden-import openpyxl.chart --hidden-import openpyxl.comments src/tianshang_scribe/cli/main.py
# dist/tianshang-scribe.exe (~35 MB)

デモ

python -m demo.generate_demos
# demo/demo_word.docx   —LaTeX + math + TOC + watermark
# demo/demo_excel.xlsx  —CSV import + formulas + chart + protection
# demo/demo_ppt.pptx    —slides + notes + transitions + math formulas

CLIコンプライアンステスト:

python demo/test_cli.py

開発

git clone https://github.com/Tianshang301/TianshangScribe.git
cd TianshangScribe
pip install -e ".[dev]"

pytest tests/ -v        # Run tests
ruff check src/tianshang_scribe/ tests/  # Lint
mypy src/tianshang_scribe/               # Type check

ライセンス

Apache-2.0

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Generate PDF/DOCX/XLSX/PPTX from templates+JSON. Convert Office/HTML/MD to PDF. Universal templating

  • Use your own Word templates to convert Markdown → DOCX/PDF/HTML from any MCP-compatible AI.

  • Markdown in, any format out. PDFs merged, split, watermarked. Runs on our own doc engines.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Tianshang301/TianshangScribe'

If you have feedback or need assistance with the MCP directory API, please join our Discord server