Skip to main content
Glama
Mavline

docx_mcp_server_ts

by Mavline

DOCX MCP Server

완전한 OOXML 지원으로 범용 DOCX 처리를 제공하는 TypeScript 기반의 포괄적인 MCP(Model Context Protocol) 서버입니다. 텍스트, 표, 이미지, 머리글/바닥글, SDT, 주석 등을 지원하며 Word 문서를 프로그래밍 방식으로 처리할 수 있습니다.

기능

  • 완전한 OOXML 액세스: 전체 네임스페이스 지원과 함께 ZIP 수준에서 DOCX 파트를 읽고 씁니다.

  • 텍스트 작업: 최소 diff 보존으로 텍스트를 추출, 찾기 및 바꿉니다.

  • 표 관리: 행 삽입/삭제, 셀 수정, 병합/분할 작업

  • 이미지 처리: EMU 기반 크기 조정으로 인라인/위치 지정 이미지 추가

  • 구조화된 데이터 태그(SDT): 태그 또는 별칭으로 콘텐츠 컨트롤에 액세스

  • 머리글/바닥글: 섹션 머리글과 바닥글 나열 및 수정

  • 변경 내용 추적: 수정 사항 수락/거부, 삽입/삭제 처리

  • 주석: 문서 주석 관리

  • 메타데이터: 핵심(core) 및 앱(app) 속성 읽기/쓰기

  • LRU 캐싱: 파트 캐싱을 통한 효율적인 메모리 관리

  • 무손실 XML: fast-xml-parser로 문서 구조 보존

Related MCP server: mcp-office-parser

설치

npm install
npm run build

빠른 시작

서버 시작

npm start

서버는 stdin/stdout에서 MCP 프로토콜 메시지를 수신 대기합니다.

설치 및 구성

Claude Code CLI

claude mcp install docx \
  --command node \
  --args /full/path/to/docx_mcp_server_ts/dist/index.js \
  --env LOG_LEVEL=INFO

~/.claude.json (Claude Code용)

~/.claude.json을 편집하고 "projects" 섹션에 추가하십시오:

{
  "projects": {
    "/full/path/to/docx_mcp_server_ts": {
      "mcpServers": {
        "docx": {
          "command": "node",
          "args": ["/full/path/to/docx_mcp_server_ts/dist/index.js"],
          "env": {
            "LOG_LEVEL": "INFO"
          }
        }
      }
    }
  }
}

Linux/WSL용 예시:

{
  "projects": {
    "/mnt/c/Users/pavelk/Desktop/Projects/MCP-servers/docx_mcp_server_ts": {
      "mcpServers": {
        "docx": {
          "command": "node",
          "args": ["/mnt/c/Users/pavelk/Desktop/Projects/MCP-servers/docx_mcp_server_ts/dist/index.js"],
          "env": {
            "LOG_LEVEL": "INFO"
          }
        }
      }
    }
  }
}

MCP 도구

문서 관리

docx.open

파일 또는 base64 버퍼에서 DOCX 문서를 엽니다.

입력:

{
  "path": "/path/to/document.docx",
  "bufferBase64": "..."  // OR provide base64 data
}

출력:

{
  "docId": "uuid-string",
  "parts": ["word/document.xml", ...],
  "props": { "core": {}, "app": {} }
}

docx.close

문서를 닫고 리소스를 해제합니다.

입력: { "docId": "uuid" }

docx.save

문서를 파일로 저장하거나 base64로 반환합니다.

입력:

{
  "docId": "uuid",
  "path": "/output/path.docx",  // optional
  "returnBase64": true  // optional
}

docx.list_parts

문서의 모든 파트를 나열합니다.

docx.part_read / docx.part_write

저수준 액세스를 위해 개별 XML 파트를 읽고 씁니다.

텍스트 작업

docx.get_text

문서에서 모든 텍스트를 추출합니다.

입력: { "docId": "uuid", "scope": "document|headers|footers|all" }

docx.replace_text

run 구조를 보존하면서 텍스트를 바꿉니다.

입력:

{
  "docId": "uuid",
  "match": "search text",
  "replace": "replacement",
  "mode": "literal|regex",
  "where": "document|headers|footers|all"
}

출력: { "replaced": 5 }

docx.find

컨텍스트와 함께 텍스트를 찾습니다.

출력:

{
  "hits": [
    {
      "text": "found text",
      "context": "...found text...",
      "offset": 150
    }
  ]
}

표 작업

docx.tables_list

모든 표를 크기와 함께 나열합니다.

출력:

{
  "tables": [
    {
      "tableXPath": "//w:tbl[1]",
      "rows": 5,
      "colsApprox": 3
    }
  ]
}

docx.table_edit

표 작업을 수행합니다.

입력:

{
  "docId": "uuid",
  "tableXPath": "//w:tbl[1]",
  "op": {
    "kind": "setCellText",
    "row": 0,
    "col": 0,
    "text": "new value"
  }
}

지원되는 작업:

  • { "kind": "setCellText", "row": number, "col": number, "text": string }

  • { "kind": "insertRow", "at": number }

  • { "kind": "deleteRow", "at": number }

  • { "kind": "insertCol", "at": number }

  • { "kind": "deleteCol", "at": number }

구조화된 데이터 태그(SDT)

docx.sdt_get

콘텐츠 컨트롤의 내용을 가져옵니다.

입력: { "docId": "uuid", "tagOrAlias": "control_tag" }

출력:

{
  "xml": "<w:p>...</w:p>",
  "textPreview": "Control content..."
}

docx.sdt_put

콘텐츠 컨트롤을 업데이트합니다.

입력:

{
  "docId": "uuid",
  "tagOrAlias": "control_tag",
  "xmlFragment": "<w:p>...</w:p>"
}

이미지 작업

docx.images_list

모든 이미지를 메타데이터와 함께 나열합니다.

출력:

{
  "images": [
    {
      "rId": "rId4",
      "path": "word/media/image1.png",
      "sizeEMU": { "cx": 914400, "cy": 914400 }
    }
  ]
}

docx.image_add

이미지를 인라인 또는 고정(anchored) 방식으로 삽입합니다.

입력:

{
  "docId": "uuid",
  "target": {
    "afterParagraphXPath": "//w:p[1]",
    "sdtTagOrAlias": "imageControl"  // OR use SDT
  },
  "image": {
    "path": "/local/image.png",
    "base64": "...",  // OR base64 data
    "filename": "image.png",
    "contentType": "image/png"
  },
  "placement": {
    "kind": "inline"  // OR { "kind": "anchor", "xEMU": 0, "yEMU": 0 }
  },
  "size": {
    "widthMM": 50,
    "heightMM": 50
  },
  "altText": "Description"
}

docx.image_update_position

고정(anchored) 이미지의 위치/크기를 업데이트합니다.

고급 작업

docx.styles_get / docx.styles_set

styles.xml 읽기/쓰기

docx.numbering_get / docx.numbering_set

numbering.xml 읽기/쓰기

docx.headers_footers_list

머리글과 바닥글을 섹션 정보와 함께 나열합니다.

docx.headers_footers_get / docx.headers_footers_set

특정 머리글 또는 바닥글을 읽고 씁니다.

docx.comments_list / docx.comments_add / docx.comments_delete

문서 주석을 관리합니다.

docx.changes_accept_all

모든 변경 내용 추적을 수락합니다(w:del 제거, w:ins 래핑 해제).

출력: { "removedDel": 3, "flattenedIns": 5 }

docx.metadata_get / docx.metadata_set

문서 속성(core.xml, app.xml)을 읽고 씁니다.

크기 변환

서버는 EMU(English Metric Unit) 변환을 내부적으로 처리합니다:

  • 1인치 = 914,400 EMU

  • 1 mm ≈ 36,000 EMU

  • 1포인트 ≈ 12,700 EMU

예제

텍스트 추출 및 바꾸기

// Open document
const openResult = await client.call('docx.open', {
  path: '/tmp/document.docx'
});
const docId = openResult.docId;

// Get text
const textResult = await client.call('docx.get_text', { docId });
console.log(textResult.text);

// Replace text
await client.call('docx.replace_text', {
  docId,
  match: 'old text',
  replace: 'new text',
  mode: 'literal'
});

// Save
await client.call('docx.save', {
  docId,
  path: '/tmp/document-modified.docx'
});

// Close
await client.call('docx.close', { docId });

표 수정

// List tables
const tablesResult = await client.call('docx.tables_list', { docId });
const tableXPath = tablesResult.tables[0].tableXPath;

// Update cell
await client.call('docx.table_edit', {
  docId,
  tableXPath,
  op: {
    kind: 'setCellText',
    row: 0,
    col: 0,
    text: 'Updated Value'
  }
});

// Insert row
await client.call('docx.table_edit', {
  docId,
  tableXPath,
  op: {
    kind: 'insertRow',
    at: 1
  }
});

이미지 추가

const fs = require('fs').promises;

const imageBuffer = await fs.readFile('/path/to/image.png');
const base64 = imageBuffer.toString('base64');

await client.call('docx.image_add', {
  docId,
  target: {
    afterParagraphXPath: '//w:p[1]'
  },
  image: {
    base64,
    filename: 'image.png',
    contentType: 'image/png'
  },
  placement: {
    kind: 'inline'
  },
  size: {
    widthMM: 100,
    heightMM: 75
  },
  altText: 'My image'
});

아키텍처

src/
├── index.ts              # MCP server entry point
├── logger.ts             # Logging utility
├── errors.ts             # Error types and codes
├── ooxml/
│   ├── namespaces.ts     # OOXML constants and namespaces
│   ├── emu.ts            # Unit conversion utilities
│   ├── dom.ts            # XML DOM utilities (xmldom + fontoxpath)
│   ├── xmlParser.ts      # FXP parser with order preservation
│   ├── parts.ts          # ZIP part reading/writing
│   ├── rels.ts           # Relationship management
│   ├── text.ts           # Text operations with diff-match-patch
│   ├── tables.ts         # Table manipulation
│   ├── sdt.ts            # Structured Data Tags
│   ├── drawings.ts       # Image handling
│   ├── headersFooters.ts # Header/footer operations
│   ├── comments.ts       # Comment management
│   ├── changes.ts        # Track changes handling
│   ├── styles.ts         # Styles XML access
│   └── numbering.ts      # Numbering XML access
├── store/
│   ├── types.ts          # Store type definitions
│   └── docStore.ts       # Document store with LRU cache
└── mcp/
    └── tools.ts          # MCP tool implementations

성능

  • 메모리: LRU 캐시는 문서당 캐시 항목을 50개로 제한합니다.

  • 전체 크기: 최대 100MB의 문서를 메모리에서 지원합니다.

  • 부분 액세스: 요청된 파트만 ZIP에서 구문 분석됩니다.

  • 최소 Diff: 가능한 경우 텍스트 바꾸기가 run 구조를 보존합니다.

제한 사항

  • 페이지 레이아웃 계산은 수행되지 않습니다(Word의 렌더링 엔진 필요).

  • 고급 DrawingML 변환은 읽기 전용입니다.

  • VBA 매크로 및 포함된 OLE 개체는 지원되지 않습니다.

  • 매우 큰 문서(>500MB)는 스트리밍이 필요할 수 있습니다.

개발

# Install dependencies
npm install

# Type check
npm run type-check

# Build
npm run build

# Run dev server
npm run dev

# Debug with inspector
npm run dev:debug

로깅

환경 변수를 통해 로그 수준을 제어합니다:

LOG_LEVEL=DEBUG npm start     # Verbose
LOG_LEVEL=INFO npm start      # Default
LOG_LEVEL=WARN npm start      # Warnings only
LOG_LEVEL=ERROR npm start     # Errors only

프로토콜 지원

  • 전송: stdio

  • 프로토콜: MCP(Model Context Protocol)

  • 핸들러: @modelcontextprotocol/sdk

라이선스

MIT

리소스

Install Server
A
license - permissive license
C
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    B
    quality
    A
    maintenance
    An MCP server for reading, editing, and validating Microsoft Word documents with specialized support for track changes, comments, and footnotes. It enables structural auditing, heading extraction, and precise OOXML-level document manipulation through natural language tools.
    100
    42
    MIT
  • A
    license
    D
    quality
    D
    maintenance
    Enables reading, writing, editing, and converting Office documents (ODT, DOCX, ODS, XLSX, PDF, etc.) using MCP tools, with no external dependencies.
    11
    31
    MIT
  • A
    license
    C
    quality
    D
    maintenance
    A 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.
    100
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to generate, edit, validate, and render Word documents programmatically via MCP, ensuring correct OOXML structure and style.
    3
    MIT

View all related MCP servers

Related MCP Connectors

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

  • Google Docs MCP Pack — read, create, and edit Google Docs via OAuth.

  • Normalize and convert more than 400 file types via TweekIT's hosted MCP streamable HTTP endpoint.

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/Mavline/docx_mcp_server_ts'

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