一个通过模型上下文协议(Model Context Protocol)提供读取、写入和编辑微软Word(docx)文件工具的服务器,允许进行整篇文档读取、内容创建、目标段落编辑以及文本插入等操作。
5.0k 查看 · 2026-07-07 更新
简介
一个通过模型上下文协议(Model Context Protocol)提供读取、写入和编辑微软Word(docx)文件工具的服务器,允许进行整篇文档读取、内容创建、目标段落编辑以及文本插入等操作。
简介
一个通过模型上下文协议(Model Context Protocol)提供读取、写入和编辑微软Word(docx)文件工具的服务器,允许进行整篇文档读取、内容创建、目标段落编辑以及文本插入等操作。
MCP Server Office
提供 Microsoft Word (docx) 文件读写工具的模型上下文协议 (MCP) 服务器。
使用方法
使用 pip 安装:
pip install mcp-server-office
然后,启动 MCP 服务器:
mcp-server-office
或者使用 uv,只需:
uvx mcp-server-office
可用工具
-
read_docx: 读取 docx 文件的完整内容,包括表格和图片。- 输入:
path(字符串) - 目标文件的绝对路径 - 注意: 图片将被转换为 [Image] 占位符,并且不会显示修订记录
- 输入:
-
write_docx: 使用给定的内容创建一个新的 docx 文件。- 输入:
path(字符串) - 目标文件的绝对路径content(字符串) - 要写入文件的内容
- 注意: 使用双换行表示新段落,并使用带有 | 分隔符的 [Table] 标签来表示表格
- 输入:
-
edit_docx_paragraph: 在指定的 docx 文件段落中进行文本替换。- 输入:
path(字符串) - 要编辑的文件的绝对路径edits(数组) - 包含搜索/替换文本和段落索引的字典列表paragraph_index(数字) - 要编辑的段落的基于0的索引search(字符串) - 在指定段落内查找的文本replace(字符串) - 替换文本
- 注意: 每个搜索字符串在指定段落内必须精确匹配一次
- 输入:
-
edit_docx_insert: 向 docx 文件中插入新的段落。- 输入:
path(字符串) - 要编辑的文件的绝对路径inserts(数组) - 包含文本和可选段落索引的字典列表text(字符串) - 作为新段落插入的文本paragraph_index(数字, 可选) - 在其之前插入的新段落的基于0的索引。如果未指定,则在末尾插入。
- 输入:
需求
- Python >= 3.12
- 依赖项:
- mcp[cli] >= 1.2.0
- python-docx >= 1.1.2
MCP Server Office (日本語)
Microsoft Word (docx) ファイルの読み書きを提供するModel Context Protocol (MCP) サーバーです。
使用方法
pipを使用してインストール:
pip install mcp-server-office
MCPサーバーの起動:
mcp-server-office
または、uvを使う場合:
uvx mcp-server-office
利用可能なツール
-
read_docx: docxファイルの内容を表やイメージを含めて完全に読み取ります。- 入力:
path(文字列) - 対象ファイルの絶対パス - 注意: 画像は[Image]というプレースホルダーに変換され、変更履歴は表示されません
- 入力:
-
write_docx: 新しいdocxファイルを指定された内容で作成します。- 入力:
path(文字列) - 作成するファイルの絶対パスcontent(文字列) - ファイルに書き込む内容
- 注意: 段落は2つの改行で区切り、表は[Table]タグと|区切りを使用します
- 入力:
-
edit_docx_paragraph: docxファイル内の指定された段落のテキストを置換します。- 入力:
path(文字列) - 編集するファイルの絶対パスedits(配列) - 検索/置換テキストと段落インデックスを含む辞書のリストparagraph_index(数値) - 編集する段落の0ベースのインデックスsearch(文字列) - 指定された段落内で検索するテキストreplace(文字列) - 置換するテキスト
- 注意: 各検索文字列は指定された段落内で一度だけマッチする必要があります
- 入力:
-
edit_docx_insert: docxファイルに新しい段落を挿入します。- 入力:
path(文字列) - 編集するファイルの絶対パスinserts(配列) - テキストとオプションの段落インデックスを含む辞書のリストtext(文字列) - 新しい段落として挿入するテキストparagraph_index(数値, オプション) - 挿入する位置の段落の0ベースのインデックス。指定しない場合は末尾に挿入されます。
- 入力:
動作要件
- Python >= 3.12
- 依赖包:
- mcp[cli] >= 1.2.0
- python-docx >= 1.1.2
工具列表
-
read_docx: Read complete contents of a docx file including tables and images.Use this tool when you want to read file endswith '.docx'.Paragraphs are separated with two line breaks.This tool convert images into placeholder [Image].'--- Paragraph [number] ---' is indicator of each paragraph.
-
edit_docx_paragraph: Make text replacements in specified paragraphs of a docx file. Accepts a list of edits with paragraph index and search/replace pairs. Each edit operates on a single paragraph and preserves the formatting of the first run. Returns a git-style diff showing the changes made. Only works within allowed directories.
-
write_docx: Create a new docx file with given content.Editing exisiting docx file with this tool is not recomended.
-
edit_docx_insert: Insert new paragraphs into a docx file. Accepts a list of inserts with text and optional paragraph index. Each insert creates a new paragraph at the specified position. If paragraph_index is not specified, the paragraph is added at the end. When multiple inserts target the same paragraph_index, they are inserted in order. Returns a git-style diff showing the changes made.
来源
- 来源:github
- 链接:https://github.com/famano/mcp-server-office