office-docs-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- office_docs_mcp-0.1.0/.env.example +1 -0
- office_docs_mcp-0.1.0/.github/workflows/ci.yml +41 -0
- office_docs_mcp-0.1.0/.github/workflows/release.yml +70 -0
- office_docs_mcp-0.1.0/.gitignore +33 -0
- office_docs_mcp-0.1.0/.python-version +1 -0
- office_docs_mcp-0.1.0/AGENTS.md +192 -0
- office_docs_mcp-0.1.0/CHANGELOG.md +52 -0
- office_docs_mcp-0.1.0/CONTRIBUTING.md +58 -0
- office_docs_mcp-0.1.0/LICENSE +21 -0
- office_docs_mcp-0.1.0/PKG-INFO +151 -0
- office_docs_mcp-0.1.0/README.md +125 -0
- office_docs_mcp-0.1.0/SECURITY.md +15 -0
- office_docs_mcp-0.1.0/config.toml +5 -0
- office_docs_mcp-0.1.0/pyproject.toml +63 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/__init__.py +13 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/common/__init__.py +29 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/common/config_manager.py +230 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/common/file_utils.py +56 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/excel/__init__.py +20 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/excel/reader.py +122 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/excel/writer.py +133 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/main.py +417 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/powerpoint/__init__.py +18 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/powerpoint/reader.py +94 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/powerpoint/writer.py +117 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/server.py +352 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/word/__init__.py +21 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/word/reader.py +122 -0
- office_docs_mcp-0.1.0/src/office_docs_mcp/word/writer.py +137 -0
- office_docs_mcp-0.1.0/tests/test_common.py +43 -0
- office_docs_mcp-0.1.0/tests/test_config_cli.py +192 -0
- office_docs_mcp-0.1.0/tests/test_excel.py +98 -0
- office_docs_mcp-0.1.0/tests/test_powerpoint.py +72 -0
- office_docs_mcp-0.1.0/tests/test_server.py +70 -0
- office_docs_mcp-0.1.0/tests/test_smoke.py +76 -0
- office_docs_mcp-0.1.0/tests/test_word.py +92 -0
- office_docs_mcp-0.1.0/uv.lock +1078 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
OFFICE_DOCS_MCP_LOGGING__LEVEL=INFO
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Install uv
|
|
19
|
+
uses: astral-sh/setup-uv@v3
|
|
20
|
+
with:
|
|
21
|
+
enable-cache: true
|
|
22
|
+
|
|
23
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
24
|
+
run: uv python install ${{ matrix.python-version }}
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
if [ -f uv.lock ]; then
|
|
29
|
+
uv sync --locked --group dev --python ${{ matrix.python-version }}
|
|
30
|
+
else
|
|
31
|
+
uv sync --group dev --python ${{ matrix.python-version }}
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
- name: Lint
|
|
35
|
+
run: uv run --python ${{ matrix.python-version }} ruff check .
|
|
36
|
+
|
|
37
|
+
- name: Format check
|
|
38
|
+
run: uv run --python ${{ matrix.python-version }} ruff format --check .
|
|
39
|
+
|
|
40
|
+
- name: Test
|
|
41
|
+
run: uv run --python ${{ matrix.python-version }} pytest -v
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
name: Run Tests
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v3
|
|
22
|
+
with:
|
|
23
|
+
enable-cache: true
|
|
24
|
+
|
|
25
|
+
- name: Set up Python
|
|
26
|
+
run: uv python install 3.12
|
|
27
|
+
|
|
28
|
+
- name: Install dependencies
|
|
29
|
+
run: |
|
|
30
|
+
if [ -f uv.lock ]; then
|
|
31
|
+
uv sync --locked --group dev
|
|
32
|
+
else
|
|
33
|
+
uv sync --group dev
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
- name: Lint
|
|
37
|
+
run: uv run ruff check .
|
|
38
|
+
|
|
39
|
+
- name: Format check
|
|
40
|
+
run: uv run ruff format --check .
|
|
41
|
+
|
|
42
|
+
- name: Test
|
|
43
|
+
run: uv run pytest -v
|
|
44
|
+
|
|
45
|
+
publish:
|
|
46
|
+
name: Publish to PyPI
|
|
47
|
+
needs: [test]
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
steps:
|
|
50
|
+
- name: Checkout
|
|
51
|
+
uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Install uv
|
|
54
|
+
uses: astral-sh/setup-uv@v3
|
|
55
|
+
with:
|
|
56
|
+
enable-cache: true
|
|
57
|
+
|
|
58
|
+
- name: Build distribution packages
|
|
59
|
+
run: uv build
|
|
60
|
+
|
|
61
|
+
- name: Publish package distributions to PyPI
|
|
62
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
63
|
+
with:
|
|
64
|
+
packages-dir: dist/
|
|
65
|
+
|
|
66
|
+
- name: Create GitHub Release
|
|
67
|
+
uses: softprops/action-gh-release@v2
|
|
68
|
+
with:
|
|
69
|
+
files: dist/*
|
|
70
|
+
generate_release_notes: true
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Virtual environment
|
|
2
|
+
.venv/
|
|
3
|
+
|
|
4
|
+
# Python byte-code and caches
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*$py.class
|
|
8
|
+
*.egg-info/
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
.coverage
|
|
12
|
+
htmlcov/
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
|
|
16
|
+
# Environment and secrets
|
|
17
|
+
.env
|
|
18
|
+
*.env.local
|
|
19
|
+
|
|
20
|
+
# Databases and data dirs
|
|
21
|
+
data/
|
|
22
|
+
*.db
|
|
23
|
+
*.sqlite3
|
|
24
|
+
|
|
25
|
+
# IDE / Editor configs
|
|
26
|
+
.vscode/
|
|
27
|
+
.idea/
|
|
28
|
+
*.swp
|
|
29
|
+
*.swo
|
|
30
|
+
|
|
31
|
+
# OS files
|
|
32
|
+
.DS_Store
|
|
33
|
+
Thumbs.db
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# AGENTS.md - Office Docs MCP Server
|
|
2
|
+
|
|
3
|
+
이 문서는 AI 에이전트와 개발자가 `office_docs_mcp` 프로젝트의 구조, 설계 원칙, TDD 개발 워크플로우를 이해하고 일관성 있게 협업할 수 있도록 돕는 지침서입니다.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. 프로젝트 개요 (Project Overview)
|
|
8
|
+
|
|
9
|
+
`office_docs_mcp`는 LLM(대형 언어 모델)이 오피스 문서(Excel, Word, PowerPoint)를 안정적이고 효율적으로 읽고 쓸 수 있도록 지원하는 **Model Context Protocol (MCP)** 서버입니다.
|
|
10
|
+
|
|
11
|
+
### 핵심 설계 철학
|
|
12
|
+
1. **LLM 친화적 인터페이스 (Token & Context Conscious)**:
|
|
13
|
+
- 전체 문서를 무작정 텍스트로 덤프하지 않고, **개요 조회(Outline/Metadata) -> 범위/페이징 읽기(Chunked Read) -> 정밀 쓰기(Precise Write)** 흐름을 제공합니다.
|
|
14
|
+
- 반환 데이터는 토큰 효율이 높고 가독성이 좋은 Markdown 테이블 또는 정형화된 JSON 형식을 취합니다.
|
|
15
|
+
2. **테스트 주도 개발 (TDD)**:
|
|
16
|
+
- 모든 기능은 요구사항 정의 -> 실패하는 테스트 작성(Red) -> 최소 구현(Green) -> 리팩토링(Refactor) 순서로 개발합니다.
|
|
17
|
+
- 실제 파일 IO 테스트는 `pytest`의 `tmp_path` 픽스처를 활용하여 독립적이고 빠르게 수행합니다.
|
|
18
|
+
3. **안전한 파일 조작 (Safe File I/O)**:
|
|
19
|
+
- 파일 유효성 검사(경로 존재 여부, 확장자 검사)를 철저히 수행합니다.
|
|
20
|
+
- 기존 파일 덮어쓰기 시 백업 또는 안전 장치를 제공합니다.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 2. 기술 스택 및 의존성 (Tech Stack)
|
|
25
|
+
|
|
26
|
+
- **Language Runtime**: Python >= 3.12
|
|
27
|
+
- **Package & Environment Manager**: `uv`
|
|
28
|
+
- **MCP Framework**: `mcp` (Official Python MCP SDK - FastMCP)
|
|
29
|
+
- **Office Document Libraries**:
|
|
30
|
+
- **Excel (`.xlsx`, `.xlsm`)**: `openpyxl` (표준, 셀 단위 조작, 수식 및 서식 지원)
|
|
31
|
+
- **Word (`.docx`)**: `python-docx` (단락, 표, 헤딩 조작 표준)
|
|
32
|
+
- **PowerPoint (`.pptx`)**: `python-pptx` (슬라이드, 셰이프, 텍스트, 표 조작 표준)
|
|
33
|
+
- **Linting & Formatting**: `ruff`
|
|
34
|
+
- **Testing**: `pytest`
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 3. 디렉토리 구조 (Directory Structure)
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
office_docs_mcp/
|
|
42
|
+
├── AGENTS.md # 에이전트용 개발 가이드 (본 문서)
|
|
43
|
+
├── README.md # 사용자용 프로젝트 설명서
|
|
44
|
+
├── CHANGELOG.md # 변경 이력 기록 (Keep a Changelog)
|
|
45
|
+
├── CONTRIBUTING.md # 기여 가이드
|
|
46
|
+
├── SECURITY.md # 보안 정책
|
|
47
|
+
├── LICENSE # 라이선스 (MIT)
|
|
48
|
+
├── pyproject.toml # uv 패키지 및 의존성 정의
|
|
49
|
+
├── config.toml # 런타임 설정 파일
|
|
50
|
+
├── src/
|
|
51
|
+
│ └── office_docs_mcp/
|
|
52
|
+
│ ├── __init__.py
|
|
53
|
+
│ ├── main.py # CLI 진입점 (serve 명령어 제공)
|
|
54
|
+
│ ├── server.py # FastMCP 서버 인스턴스 및 도구 바인딩
|
|
55
|
+
│ ├── common/ # 공통 유틸리티 (파일 검증, 페이징, 설정 관리 등)
|
|
56
|
+
│ │ ├── __init__.py
|
|
57
|
+
│ │ ├── config_manager.py
|
|
58
|
+
│ │ └── file_utils.py
|
|
59
|
+
│ ├── excel/ # Excel 전용 로직 (.xlsx)
|
|
60
|
+
│ │ ├── __init__.py
|
|
61
|
+
│ │ ├── reader.py
|
|
62
|
+
│ │ └── writer.py
|
|
63
|
+
│ ├── word/ # Word 전용 로직 (.docx)
|
|
64
|
+
│ │ ├── __init__.py
|
|
65
|
+
│ │ ├── reader.py
|
|
66
|
+
│ │ └── writer.py
|
|
67
|
+
│ └── powerpoint/ # PowerPoint 전용 로직 (.pptx)
|
|
68
|
+
│ ├── __init__.py
|
|
69
|
+
│ ├── reader.py
|
|
70
|
+
│ └── writer.py
|
|
71
|
+
└── tests/
|
|
72
|
+
├── __init__.py
|
|
73
|
+
├── test_smoke.py
|
|
74
|
+
├── test_config_cli.py # CLI config 서브명령어 테스트
|
|
75
|
+
├── test_excel.py # Excel 서비스 및 도구 단위 테스트
|
|
76
|
+
├── test_word.py # Word 서비스 및 도구 단위 테스트
|
|
77
|
+
├── test_powerpoint.py # PowerPoint 서비스 및 도구 단위 테스트
|
|
78
|
+
└── test_server.py # MCP 도구 등록 및 실행 통합 테스트
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 4. MCP 도구 명세 (Tool Specifications)
|
|
84
|
+
|
|
85
|
+
### 4.1 Excel 도구군 (`excel_*`)
|
|
86
|
+
- `excel_get_metadata(file_path: str)`: 시트 목록, 시트별 최대 행/열 수, 컬럼 헤더 요약.
|
|
87
|
+
- `excel_read_sheet(file_path: str, sheet_name: str | None = None, start_row: int = 1, end_row: int = 50, start_col: int = 1, end_col: int = 20, format: str = "markdown")`:
|
|
88
|
+
- 특정 시트의 지정된 행/열 범위를 읽어 반환 (기본 1-based 인덱스 사용, LLM 직관성 일치).
|
|
89
|
+
- `excel_write_cell(file_path: str, sheet_name: str, coordinate: str, value: Any)`:
|
|
90
|
+
- 예: `A1` 또는 행/열 번호로 단일 셀 값 변경.
|
|
91
|
+
- `excel_write_range(file_path: str, sheet_name: str, start_cell: str, data: list[list[Any]])`:
|
|
92
|
+
- 시작 셀(`A1` 등)부터 2차원 리스트 데이터를 연속 기입.
|
|
93
|
+
- `excel_append_rows(file_path: str, sheet_name: str, rows: list[list[Any]])`:
|
|
94
|
+
- 시트 맨 마지막 행 뒤에 새로운 행들 추가.
|
|
95
|
+
- `excel_create_workbook(file_path: str, sheet_names: list[str] | None = None)`:
|
|
96
|
+
- 빈 엑셀 파일 생성.
|
|
97
|
+
|
|
98
|
+
### 4.2 Word 도구군 (`word_*`)
|
|
99
|
+
- `word_get_outline(file_path: str)`: 문서의 헤딩(제목) 목록, 전체 단락 수, 표(Table) 개수 등 구조 요약.
|
|
100
|
+
- `word_read_paragraphs(file_path: str, start_idx: int = 0, count: int = 30)`:
|
|
101
|
+
- 단락 단위로 본문 텍스트 슬라이싱 읽기.
|
|
102
|
+
- `word_append_paragraph(file_path: str, text: str, style: str | None = None)`:
|
|
103
|
+
- 문서 끝에 새 단락 또는 헤딩 추가.
|
|
104
|
+
- `word_read_table(file_path: str, table_idx: int = 0, format: str = "markdown")`:
|
|
105
|
+
- 특정 순번의 표 내용을 Markdown 표나 2차원 배열로 읽기.
|
|
106
|
+
- `word_append_table_row(file_path: str, table_idx: int, row_data: list[str])`:
|
|
107
|
+
- 특정 표에 행 데이터 추가.
|
|
108
|
+
- `word_create_document(file_path: str, title: str | None = None)`:
|
|
109
|
+
- 빈 워드 문서 생성.
|
|
110
|
+
|
|
111
|
+
### 4.3 PowerPoint 도구군 (`ppt_*`)
|
|
112
|
+
- `ppt_get_outline(file_path: str)`: 전체 슬라이드 수, 각 슬라이드의 제목 및 포함된 셰이프 종류 요약.
|
|
113
|
+
- `ppt_read_slide(file_path: str, slide_idx: int)`:
|
|
114
|
+
- 특정 슬라이드의 모든 텍스트 상자 및 표 내용 추출.
|
|
115
|
+
- `ppt_add_slide(file_path: str, title: str, content: str | None = None, layout_idx: int = 1)`:
|
|
116
|
+
- 제목과 본문을 포함하는 새 슬라이드 생성.
|
|
117
|
+
- `ppt_update_slide_text(file_path: str, slide_idx: int, shape_idx: int, text: str)`:
|
|
118
|
+
- 특정 슬라이드의 지정된 셰이프 텍스트 수정.
|
|
119
|
+
- `ppt_create_presentation(file_path: str, title: str | None = None)`:
|
|
120
|
+
- 빈 프레젠테이션 파일 생성.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 5. TDD 워크플로우 (Test-Driven Development)
|
|
125
|
+
|
|
126
|
+
에이전트가 새로운 도구나 기능을 추가할 때는 **반드시** 다음 절차를 준수합니다:
|
|
127
|
+
|
|
128
|
+
1. **테스트 우선 작성 (`Red`)**:
|
|
129
|
+
- `tests/test_<format>.py`에 테스트 케이스를 먼저 작성합니다.
|
|
130
|
+
- 임시 파일은 반드시 pytest의 `tmp_path: pathlib.Path`를 사용하여 디스크 오염을 방지합니다.
|
|
131
|
+
- 예시:
|
|
132
|
+
```python
|
|
133
|
+
def test_excel_write_and_read(tmp_path):
|
|
134
|
+
file_path = tmp_path / "sample.xlsx"
|
|
135
|
+
excel_create_workbook(str(file_path))
|
|
136
|
+
excel_write_cell(str(file_path), "Sheet", "B2", "Hello MCP")
|
|
137
|
+
result = excel_read_sheet(
|
|
138
|
+
str(file_path), "Sheet", start_row=2, end_row=2, start_col=2, end_col=2
|
|
139
|
+
)
|
|
140
|
+
assert "Hello MCP" in result
|
|
141
|
+
```
|
|
142
|
+
2. **최소 코드 구현 (`Green`)**:
|
|
143
|
+
- `src/office_docs_mcp/<format>/` 하위에 비즈니스 로직을 구현합니다.
|
|
144
|
+
- `uv run pytest tests/test_<format>.py` 실행 후 테스트가 통과하는지 확인합니다.
|
|
145
|
+
3. **리팩토링 및 린트 (`Refactor`)**:
|
|
146
|
+
- 예외 처리(파일 누락, 인덱스 초과 등)를 강화합니다.
|
|
147
|
+
- `uv run ruff check .` 및 `uv run ruff format .`을 실행하여 컨벤션을 유지합니다.
|
|
148
|
+
4. **MCP 도구 등록 및 검증**:
|
|
149
|
+
- `server.py`에 `@mcp.tool()` 데코레이터를 추가하고 문서화 docstring을 작성합니다.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 6. 개발 필수 명령어 (Development Commands)
|
|
154
|
+
|
|
155
|
+
모든 작업은 `uv`를 통해 수행합니다:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# 가상환경 동기화 및 패키지 설치
|
|
159
|
+
uv sync --group dev
|
|
160
|
+
|
|
161
|
+
# 새로운 패키지 추가 (예: 의존성 추가 시)
|
|
162
|
+
uv add openpyxl python-docx python-pptx mcp
|
|
163
|
+
|
|
164
|
+
# 테스트 실행
|
|
165
|
+
uv run pytest
|
|
166
|
+
|
|
167
|
+
# 특정 테스트 파일 단독 실행
|
|
168
|
+
uv run pytest tests/test_excel.py -v
|
|
169
|
+
|
|
170
|
+
# 린트 및 포맷 검사
|
|
171
|
+
uv run ruff check .
|
|
172
|
+
uv run ruff format --check .
|
|
173
|
+
|
|
174
|
+
# MCP 서버 로컬 실행 (Stdio 모드)
|
|
175
|
+
uv run office-docs-mcp serve
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 7. 구현 시 주의사항 (Guidelines & Pitfalls)
|
|
181
|
+
|
|
182
|
+
1. **1-Based vs 0-Based 인덱스**:
|
|
183
|
+
- 엑셀은 사용자/LLM 친화적으로 **1-based** (행 1, 열 1 = A1)를 기본값으로 통일합니다.
|
|
184
|
+
- 워드/파워포인트의 인덱스(단락, 슬라이드, 표)는 API 설명서(docstring)에 기준(0-based)을 명확하게 명시합니다.
|
|
185
|
+
2. **Excel 수식(Formula) 처리**:
|
|
186
|
+
- `openpyxl`에서 `data_only=False`일 때는 수식 문자열(`=SUM(A1:A10)`), `data_only=True`일 때는 직전 저장된 계산값을 읽습니다.
|
|
187
|
+
- 읽기 도구 파라미터에 `evaluate_formulas: bool = True` 옵션을 두어 LLM이 필요에 따라 수식 자체 또는 계산값을 선택할 수 있게 합니다.
|
|
188
|
+
3. **대용량 파일 방어**:
|
|
189
|
+
- 기본 `read` 호출 시 반환 최대 행/단락 수에 상한선(`max_rows=100`, `max_paragraphs=50` 등)을 두고, 필요 시 페이징을 유도합니다.
|
|
190
|
+
4. **타입 힌트와 Docstring**:
|
|
191
|
+
- FastMCP는 함수의 Type Hint와 Docstring을 파싱하여 LLM 도구의 JSON Schema와 Description을 자동 생성합니다.
|
|
192
|
+
- 따라서 모든 도구 함수에는 **상세한 설명, 파라미터 의미, 사용 예시**를 반드시 Docstring에 기재합니다.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
> **Note on Versioning**: Version `0.y.z` indicates initial development. Public APIs and tool signatures may undergo refinements based on feedback before reaching `1.0.0`.
|
|
9
|
+
|
|
10
|
+
## [Unreleased]
|
|
11
|
+
|
|
12
|
+
## [0.1.0] - 2026-09-19
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- **MCP Server**: FastMCP server with Stdio and SSE transport support via `office-docs-mcp serve`.
|
|
16
|
+
- **Excel Tools (`excel_*`)**:
|
|
17
|
+
- `excel_get_metadata`: Inspect workbook structure, sheet names, dimensions, and column previews.
|
|
18
|
+
- `excel_read_sheet`: Range reading with 1-based indexing, formula toggle (`evaluate_formulas`), and markdown/raw output.
|
|
19
|
+
- `excel_write_cell`: Write values or formulas to specific cells.
|
|
20
|
+
- `excel_write_range`: Continuous 2D block data insertion.
|
|
21
|
+
- `excel_append_rows`: Append rows to sheet end.
|
|
22
|
+
- `excel_create_workbook`: Initialize blank workbook with custom sheet names.
|
|
23
|
+
- **Word Tools (`word_*`)**:
|
|
24
|
+
- `word_get_outline`: Document outline with heading tree, paragraph, and table counts.
|
|
25
|
+
- `word_read_paragraphs`: Chunked 0-based paragraph reading with style info.
|
|
26
|
+
- `word_read_table`: Read tables as Markdown or 2D matrix.
|
|
27
|
+
- `word_append_paragraph`: Append paragraphs or headings with automatic heading level parsing.
|
|
28
|
+
- `word_append_table_row`: Append rows to existing tables.
|
|
29
|
+
- `word_write_table_cell`: Update individual table cells.
|
|
30
|
+
- `word_create_document`: Create blank `.docx` documents with optional title heading.
|
|
31
|
+
- **PowerPoint Tools (`ppt_*`)**:
|
|
32
|
+
- `ppt_get_outline`: Slide count, titles, and shape statistics.
|
|
33
|
+
- `ppt_read_slide`: Extract text frames and table data from slides.
|
|
34
|
+
- `ppt_add_slide`: Add slide with title and content placeholder (with automatic fallback to text boxes).
|
|
35
|
+
- `ppt_update_slide_text`: Update text in designated slide shapes.
|
|
36
|
+
- `ppt_create_presentation`: Create blank `.pptx` presentations with optional title slide.
|
|
37
|
+
- **CLI Commands & Configuration**:
|
|
38
|
+
- `office-docs-mcp serve`: Launch the MCP server.
|
|
39
|
+
- `office-docs-mcp tools`: List registered tools with `--plain` and `--json` machine-readable output flags.
|
|
40
|
+
- `office-docs-mcp config show`: Display effective configuration or specific key (`--json`, `--toml`).
|
|
41
|
+
- `office-docs-mcp config init`: Initialize configuration with default values (`--force`, `--local`, `--path`).
|
|
42
|
+
- `office-docs-mcp config path`: Display active configuration file path (`--json`, `--local`).
|
|
43
|
+
- `office-docs-mcp config set <key> <value>`: Modify configuration keys with automatic type parsing and atomic writing.
|
|
44
|
+
- `office-docs-mcp config get <key>`: Retrieve specific configuration values by dotted path.
|
|
45
|
+
- Platform-standard configuration directory support (Linux XDG, macOS Application Support, Windows AppData).
|
|
46
|
+
- Persistent `--no-color` flag and shell completion generation (`completion <bash|zsh|fish>`).
|
|
47
|
+
- **Open-Source, Governance & CI/CD**:
|
|
48
|
+
- MIT License (`LICENSE`).
|
|
49
|
+
- Contribution guidelines (`CONTRIBUTING.md`).
|
|
50
|
+
- Security disclosure policy (`SECURITY.md`).
|
|
51
|
+
- GitHub Actions CI workflow with matrix testing across Python 3.12 and 3.13.
|
|
52
|
+
- GitHub Actions automated release pipeline (`release.yml`) for PyPI Trusted Publishing and GitHub Releases upon version tag push.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Contributing to office_docs_mcp
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to `office_docs_mcp`! This project follows a strict Test-Driven Development (TDD) workflow and high code-quality standards.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Development Setup
|
|
8
|
+
|
|
9
|
+
1. Ensure you have Python >= 3.12 and [`uv`](https://docs.astral.sh/uv/) installed.
|
|
10
|
+
2. Clone the repository and install dependencies:
|
|
11
|
+
```bash
|
|
12
|
+
uv sync --group dev
|
|
13
|
+
```
|
|
14
|
+
3. Run test suite and linters to verify your local environment:
|
|
15
|
+
```bash
|
|
16
|
+
uv run pytest
|
|
17
|
+
uv run ruff check .
|
|
18
|
+
uv run ruff format --check .
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Test-Driven Development (TDD) Workflow
|
|
24
|
+
|
|
25
|
+
All new features and bugfixes must follow the Red-Green-Refactor cycle:
|
|
26
|
+
|
|
27
|
+
1. **Red**: Write a failing unit or integration test under `tests/` using pytest's `tmp_path` fixture for safe file I/O.
|
|
28
|
+
2. **Green**: Implement the minimal code in `src/office_docs_mcp/` to make the test pass.
|
|
29
|
+
3. **Refactor**: Clean up the implementation, optimize performance, and ensure clean docstrings and type annotations.
|
|
30
|
+
4. **Lint & Format**:
|
|
31
|
+
```bash
|
|
32
|
+
uv run ruff check . --fix
|
|
33
|
+
uv run ruff format .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 3. Pull Request Guidelines
|
|
39
|
+
|
|
40
|
+
- Keep pull requests focused on a single change or feature.
|
|
41
|
+
- Ensure all CI checks pass.
|
|
42
|
+
- Update `CHANGELOG.md` under `[Unreleased]` with your changes.
|
|
43
|
+
- Update `README.md` and docstrings if public tool signatures or behavior change.
|
|
44
|
+
- Never commit binary files, credentials, or generated files.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 4. Release Process
|
|
49
|
+
|
|
50
|
+
1. Update the version in `pyproject.toml`, `src/office_docs_mcp/__init__.py`, and `src/office_docs_mcp/main.py`.
|
|
51
|
+
2. Move relevant unreleased notes in `CHANGELOG.md` to the new version heading with release date.
|
|
52
|
+
3. Commit and push changes to `main`.
|
|
53
|
+
4. Create and push a semver tag:
|
|
54
|
+
```bash
|
|
55
|
+
git tag v0.1.0
|
|
56
|
+
git push origin v0.1.0
|
|
57
|
+
```
|
|
58
|
+
5. GitHub Actions (`.github/workflows/release.yml`) will run tests, build distribution wheels, publish to PyPI using Trusted Publishing (OIDC), and create a GitHub Release.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Antigravity Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: office_docs_mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Model Context Protocol (MCP) server for reading and writing Office documents (Excel, Word, PowerPoint)
|
|
5
|
+
Author: Antigravity Team
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: excel,mcp,model-context-protocol,office,openpyxl,powerpoint,python-docx,python-pptx,word
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Office/Business :: Office Suites
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Requires-Python: >=3.12
|
|
18
|
+
Requires-Dist: mcp>=2.2.0
|
|
19
|
+
Requires-Dist: openpyxl>=3.1.5
|
|
20
|
+
Requires-Dist: python-docx>=1.2.0
|
|
21
|
+
Requires-Dist: python-pptx>=1.0.2
|
|
22
|
+
Requires-Dist: wpycli
|
|
23
|
+
Requires-Dist: wpyconf
|
|
24
|
+
Requires-Dist: wpylog
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# office_docs_mcp
|
|
28
|
+
|
|
29
|
+
[](https://github.com/wkqco33/office_docs_mcp/actions/workflows/ci.yml)
|
|
30
|
+
[](LICENSE)
|
|
31
|
+
[](pyproject.toml)
|
|
32
|
+
|
|
33
|
+
LLM(대형 언어 모델)이 오피스 문서(Excel, Word, PowerPoint)를 안정적이고 토큰 효율적으로 읽고 쓸 수 있도록 지원하는 **Model Context Protocol (MCP)** 서버입니다.
|
|
34
|
+
|
|
35
|
+
> **버전 안내**: 본 프로젝트는 현재 초기 개발 단계(`0.y.z`)이며, 사용자 피드백에 따라 도구 인터페이스가 지속적으로 개선되고 있습니다.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 주요 기능
|
|
40
|
+
|
|
41
|
+
- **Excel (`.xlsx`, `.xlsm`)**:
|
|
42
|
+
- `excel_get_metadata`: 시트 목록, 크기, 컬럼 요약 조회
|
|
43
|
+
- `excel_read_sheet`: 지정된 행/열 범위(1-based)를 Markdown 테이블 또는 2차원 배열로 읽기 (수식/값 토글 지원)
|
|
44
|
+
- `excel_write_cell`: 단일 셀(`A1` 등) 값/수식 쓰기
|
|
45
|
+
- `excel_write_range`: 시작 셀부터 2차원 데이터 연속 기입
|
|
46
|
+
- `excel_append_rows`: 시트 마지막 행 뒤에 데이터 추가
|
|
47
|
+
- `excel_create_workbook`: 새 빈 엑셀 파일 생성
|
|
48
|
+
- **Word (`.docx`)**:
|
|
49
|
+
- `word_get_outline`: 문서 헤딩(제목) 목록 및 단락/표 개수 조회
|
|
50
|
+
- `word_read_paragraphs`: 단락 슬라이싱 읽기 (0-based 페이징)
|
|
51
|
+
- `word_read_table`: 표 내용을 Markdown 테이블 또는 2차원 배열로 읽기
|
|
52
|
+
- `word_append_paragraph`: 문서 끝에 단락/헤딩 추가 (헤딩 레벨 자동 처리)
|
|
53
|
+
- `word_append_table_row`: 특정 표에 새 행 추가
|
|
54
|
+
- `word_write_table_cell`: 특정 표의 셀 텍스트 수정
|
|
55
|
+
- `word_create_document`: 새 워드 문서 생성
|
|
56
|
+
- **PowerPoint (`.pptx`)**:
|
|
57
|
+
- `ppt_get_outline`: 전체 슬라이드 수 및 각 슬라이드 제목/셰이프 요약 조회
|
|
58
|
+
- `ppt_read_slide`: 특정 슬라이드의 텍스트 상자 및 표 내용 추출
|
|
59
|
+
- `ppt_add_slide`: 제목과 본문을 포함하는 새 슬라이드 추가 (플레이스홀더 부재 시 자동 텍스트박스 폴백)
|
|
60
|
+
- `ppt_update_slide_text`: 슬라이드 내 특정 셰이프 텍스트 수정
|
|
61
|
+
- `ppt_create_presentation`: 새 프레젠테이션 파일 생성
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 시작하기
|
|
66
|
+
|
|
67
|
+
### 1. 요구 사항
|
|
68
|
+
- Python >= 3.12
|
|
69
|
+
- [uv](https://docs.astral.sh/uv/) 패키지 관리자
|
|
70
|
+
|
|
71
|
+
### 2. 설치 및 가상환경 동기화
|
|
72
|
+
```bash
|
|
73
|
+
uv sync --group dev
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. CLI 명령어
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# MCP 서버 실행 (기본 Stdio 트랜스포트)
|
|
80
|
+
uv run office-docs-mcp serve
|
|
81
|
+
|
|
82
|
+
# SSE 트랜스포트로 실행
|
|
83
|
+
uv run office-docs-mcp serve --transport sse
|
|
84
|
+
|
|
85
|
+
# 등록된 MCP 도구 목록 확인 (사람 가독형)
|
|
86
|
+
uv run office-docs-mcp tools
|
|
87
|
+
|
|
88
|
+
# 기계 판독용 단일 라인 목록
|
|
89
|
+
uv run office-docs-mcp tools --plain
|
|
90
|
+
|
|
91
|
+
# 기계 판독용 JSON 스키마 덤프
|
|
92
|
+
uv run office-docs-mcp tools --json
|
|
93
|
+
|
|
94
|
+
# 설정 관리 서브명령어 (각 플랫폼 기본 경로 표준 지원)
|
|
95
|
+
# - Linux: ~/.config/office_docs_mcp/config.toml ($XDG_CONFIG_HOME)
|
|
96
|
+
# - macOS: ~/Library/Application Support/office_docs_mcp/config.toml
|
|
97
|
+
# - Windows: %APPDATA%/office_docs_mcp/config.toml
|
|
98
|
+
uv run office-docs-mcp config show # 현재 병합된 설정 전체 확인 (JSON)
|
|
99
|
+
uv run office-docs-mcp config show --toml # TOML 형식으로 확인
|
|
100
|
+
uv run office-docs-mcp config init # 플랫폼 기본 경로에 config.toml 생성
|
|
101
|
+
uv run office-docs-mcp config init --local # 현재 작업 디렉토리에 ./config.toml 생성
|
|
102
|
+
uv run office-docs-mcp config path # 플랫폼 기본 설정 파일 경로 확인 (--json 지원)
|
|
103
|
+
uv run office-docs-mcp config path --local # 로컬 설정 파일 경로 확인
|
|
104
|
+
uv run office-docs-mcp config set logging.level DEBUG # 플랫폼 설정 파일 키 변경
|
|
105
|
+
uv run office-docs-mcp config set --local logging.level DEBUG # 로컬 설정 파일 키 변경
|
|
106
|
+
uv run office-docs-mcp config get logging.level # 특정 설정 값 조회
|
|
107
|
+
|
|
108
|
+
# 셸 자동완성 스크립트 생성
|
|
109
|
+
uv run office-docs-mcp completion bash > /etc/bash_completion.d/office-docs-mcp
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 4. Claude Desktop / MCP 클라이언트 연동 설정 예시
|
|
113
|
+
|
|
114
|
+
`claude_desktop_config.json` 등에 아래와 같이 추가합니다:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"mcpServers": {
|
|
119
|
+
"office-docs": {
|
|
120
|
+
"command": "uv",
|
|
121
|
+
"args": [
|
|
122
|
+
"--directory",
|
|
123
|
+
"/path/to/office_docs_mcp",
|
|
124
|
+
"run",
|
|
125
|
+
"office-docs-mcp",
|
|
126
|
+
"serve"
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 개발 및 테스트 (TDD)
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# 전체 단위 및 통합 테스트 실행
|
|
139
|
+
uv run pytest -v
|
|
140
|
+
|
|
141
|
+
# 린트 및 코드 스타일 검증
|
|
142
|
+
uv run ruff check .
|
|
143
|
+
uv run ruff format --check .
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
자세한 기여 방법 및 개발 가이드는 아래 문서를 참고하세요:
|
|
147
|
+
- [AGENTS.md](AGENTS.md): AI 에이전트 및 개발자를 위한 설계 원칙 및 TDD 지침
|
|
148
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md): 기여 가이드라인
|
|
149
|
+
- [CHANGELOG.md](CHANGELOG.md): 변경 이력
|
|
150
|
+
- [SECURITY.md](SECURITY.md): 보안 정책
|
|
151
|
+
- [LICENSE](LICENSE): MIT License
|