Skip to main content
Glama

TianshangScribe

中文版

PyPI CI License TianshangScribe MCP server

개발자, CLI 자동화, AI 에이전트를 위한 크로스 플랫폼 Office 문서 처리 도구입니다. Word(.docx), Excel(.xlsx), PowerPoint(.pptx) 문서를 생성, 편집, 템플릿 채우기, 변환할 수 있으며, LaTeX 스타일 마크업, 네이티브 OMML 수식, 템플릿 엔진({{placeholders}}, {{#each}} 루프, {{#if}} 조건)을 지원합니다. stdio, SSE, Streamable HTTP 전송 방식으로 7가지 도구(create, edit, fill template, convert, extract, validate, compare)를 제공하는 MCP Server가 포함되어 있으며, bearer-token 인증과 rate limiting을 지원합니다.

경고: 불안정한 API — 호환성 변경 예정

이 프로젝트는 1.0 미만(0.x) 버전입니다. CLI 옵션, MCP 도구 시그니처, 템플릿 문법, 출력 형식은 고정되지 않았으며 사전 공지 없이 변경될 수 있습니다. 호환성 약속: 모든 호환성 변경 사항은 최소 한 릴리스 전에 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 Server에 권장):

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

배치용 Glob 패턴

--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}

색상(hex)

\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) 글꼴을 분리하여 저장하므로, 혼합 스크립트 텍스트에서 자동 글꼴 전환이 가능합니다.

수식

LaTeX 수학 공식은 --math를 통해 네이티브 Word OMML(Office Math Markup Language)로 변환됩니다. 변환기는 중첩된 불변 토큰 트리(분수, 근호, N-항, 위/아래 첨자, 강세, 스타일, 구분 기호 토큰)를 처리하는 수제 재귀 하강 파서(expression → term → factor → atom)이며, 사전 컴파일된 정규식과 제로 카피 인자 슬라이싱을 사용하는 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{num}{den}

근호

\sqrt{content} \sqrt[n]{content}

위/아래 첨자

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}는 유니코드 위/아래 첨자(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

두 .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 유형, 크기)

스키마

모든 매개변수에 enum, default, examples, minimum/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