TianshangScribe
TianshangScribe
開発者、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 --helppipx(スタンドアロンCLI):
pipx install tianshang-scribe
tianshang-scribe --helpPython 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グローバルオプション
パラメータ | 説明 |
| 入力文書パス( |
| Word文書を処理 |
| Excelワークブックを処理 |
| PowerPointプレゼンテーションを処理 |
| 出力ファイルパス |
| 既存ファイルの上書きを許可 |
| PDFとして出力 |
| 標準入力から読み取り |
| 標準出力へ書き出し |
-w/-e/-pが省略された場合、文書タイプは入力ファイルの拡張子から推測されます。
操作
オプション | 説明 | 例 |
| 空の文書を作成 |
|
| テキストを追加 |
|
|
|
|
| 検索して置換 |
|
| コンテンツを削除 |
|
| コンテンツ/書式/リンクをクリア |
|
| コンテンツを変更 |
|
| スタイルを設定 |
|
| テンプレート入力 |
|
| データを抽出( |
|
| プロパティを設定 |
|
| LaTeX解析を有効化 | |
| 数式を追加(Word) |
|
| 数式解析方式(office/mathtype) |
|
| OMML数式フォント(デフォルト:Cambria Math) |
|
| MathType OLEオブジェクトとして埋め込む(MTEF) |
|
| 見出しを追加(Word) |
|
| 正規表現モード |
|
| ファイルを結合 |
|
| 文書を分割(Excelのみ: |
|
| コメントを追加(Word)/ ノートを追加(PPT) |
|
| 表を追加(Word) |
|
| グラフを追加(Excel) |
|
| バッチモード |
|
| バッチ用グロブパターン |
|
| スケジュール用SQLite DBパス |
|
| スケジュールを登録 |
|
| スケジュールを削除 |
|
| スケジュールを一覧表示 |
|
| スケジュールを今すぐ実行 |
|
| 実行期限が来たスケジュールをすべて実行 |
|
| スクリプトをサンドボックスで実行 |
|
| 標準入力から読み取り | |
| 標準出力へ書き出し |
Word固有オプション
オプション | 説明 | 例 |
| 見出しを追加 |
|
| 数式を追加 |
|
| LaTeXマークアップを有効化 | |
| 目次を生成 |
|
| セクション区切りを挿入 |
|
| ページヘッダーを設定 |
|
| ページフッターを設定 |
|
| テキスト透かし |
|
| Markdownに変換 |
|
| HTMLに変換 |
|
Excel固有オプション
オプション | 説明 | 例 |
| ワークシートを追加 |
|
| ワークシートを削除 |
|
| ワークシート名を変更 |
|
| 列幅を設定 |
|
| 行の高さを設定 |
|
| セル数式を設定 |
|
| CSVデータをインポート |
|
| 範囲を並べ替え |
|
| グラフを追加 |
|
| パスワードを設定 |
|
| パスワードを解除 |
|
| CSVとしてエクスポート | |
| JSONとしてエクスポート | |
| HTMLとしてエクスポート |
LaTeX風マークアップ
--addコンテンツに以下のマークアップを埋め込みます。--latex-styleで有効化。ネストに対応。
構文 | 効果 |
| 太字 |
| 斜体 |
| スモールキャップス |
| 下線 |
| ローマン体(セリフ) |
| サンセリフ |
| 等幅 |
| 特定フォント |
| フォントサイズ(pt) |
| 色(16進) |
| 中央揃え *— |
| 左揃え *— |
| 右揃え *— |
| 行間 *— |
| インデント *— |
| 見出しを挿入 |
| 改ページ |
| 画像を挿入 |
*— 段落レベルの書式設定(新しい段落を作成します)。
フォント設定
コマンド | 効果 |
| デフォルトの欧文フォント |
| デフォルトのCJKフォント |
| サンセリフフォント |
| CJKサンセリフフォント |
| 等幅フォント |
| 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 が読み戻すのと同じ形式です。出力はリリース間でバイト単位で安定しています(ゴールデンスナップショット回帰テストスイートで保護されています)。
対応構文
カテゴリ | コマンド |
分数 |
|
根号 |
|
上付き/下付き |
|
総和/積分 |
|
極限 |
|
名前付き関数 |
|
ギリシャ文字 |
|
記号 |
|
関係演算子 |
|
矢印 |
|
アクセント |
|
括弧 |
|
数式フォント |
|
数式タイポグラフィ
主流の数学ジャーナル標準(AMS、Elsevier、Springer)に準拠:
内容 | スタイル | 例 |
単文字変数 | イタリック |
|
数字 | 直立 |
|
名前付き関数 | 直立 |
|
小文字ギリシャ文字 | イタリック |
|
大文字ギリシャ文字 | 直立 |
|
自動検出
--add テキスト内のコマンドは、$...$ で囲まなくても自動的に数式として認識されます:
引数付き:
\frac\sqrt\sum\int\prod\limアクセント:
\hat{x}\bar{x}\vec{x}など単項演算子:
\sin\cos\tan\log\lnなどプレーンテキスト内の
H_{2}Oとm^{2}はUnicodeの下付き/上付き文字(H₂O / m²)になります
スタイル構文
--style はカンマ区切りのキーと値のペアを使用します:
--style "font=Times New Roman,size=14,bold,italic,color=FF0000,align=center"キー | エイリアス | 値 | 説明 |
|
| フォント名 | 欧文フォント |
|
| フォント名 | CJKフォント |
|
| pt | フォントサイズ |
| フラグ | 太字 | |
| フラグ | イタリック | |
| フラグ | 下線 | |
|
|
| 16進カラー |
|
|
| 配置 |
ブールキー(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オプション |
シート管理 |
|
列/行サイズ |
|
数式 |
|
データインポート |
|
データエクスポート |
|
並べ替え |
|
グラフ |
|
保護 |
|
PPT機能
機能 | 説明 |
スライド管理 | スライドの追加、削除、並べ替え( |
レイアウト | 名前またはインデックスでスライドレイアウトを適用( |
発表者ノート | 発表者ノートを追加( |
数式 |
|
トランジション | スライドトランジションを設定 —フェード、プッシュ、ワイプなど( |
エクスポート | スライドを画像として保存( |
メディア圧縮 | 画像を圧縮( |
保護 | パスワードの設定/解除( |
終了コード
コード | 意味 |
| 成功 |
| 一般エラー |
| 引数エラー |
| 未実装 |
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)
ツール | 説明 |
| 構造化コンテンツブロックで .docx / .xlsx / .pptx を作成 |
| 既存ドキュメントへの置換、削除、変更、スタイル設定、追加操作 |
| データで |
| 形式間の変換(docx↔pdf/md/html、xlsx↔csv/json) |
| メタデータ、全文、またはドキュメント構造を抽出 |
| 埋め込み前にテンプレートのプレースホルダーをデータと照合 |
| 2つの .docx ファイル間の段落レベル差分 |
機能
機能 | 詳細 |
プロトコル | MCP 2024-11-05 · stdio + SSE · JSON-RPC 2.0 |
リソース |
|
プロンプト | 5つの組み込みワークフローテンプレート( |
進捗 | PDF変換および長時間操作中の |
レスポンス | マルチタイプ |
スキーマ | すべてのパラメータに |
本番環境(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}}) |
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 formulasCLIコンプライアンステスト:
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
Maintenance
Related MCP Servers
- AlicenseBqualityDmaintenanceA universal MCP server for document processing, conversion, and automation. Handle PDF, DOCX, HTML, Markdown, and more through a unified API and toolset.1333139MIT
- AlicenseAqualityDmaintenanceMCP server for Word document (.docx) creation and manipulation — the production-grade document automation tool for AI agents.938MIT
- AlicenseAqualityBmaintenanceMCP server for reading, writing, editing, formatting, and exporting Microsoft Office documents (Word, Excel, PowerPoint) via stdio JSON-RPC, with 47 tools and cross-platform support.47MIT
- AlicenseCqualityDmaintenanceA unified MCP server for document processing that enables creating, editing, and converting Word documents (DOCX), PDFs, Markdown, and images, with support for templates, formatting, and batch operations.100MIT
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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