diff --git a/mcp_docx_server.py b/mcp_docx_server.py index 4d5b2d8..03a6d8a 100644 --- a/mcp_docx_server.py +++ b/mcp_docx_server.py @@ -2,11 +2,9 @@ """ 基于 mcp_docx.py 封装的 MCP 服务器。 -暴露主要 MCP 工具: +暴露两个主要 MCP 工具: - list_docx_images:列出 DOCX 中的图片信息 - -另外提供一个普通函数 `edit_docx`(供 Python 代码直接调用),支持: -- 进行文本替换 / 关键字上色 / 图片替换 +- edit_docx: 进行文本替换 / 关键字上色 / 图片替换 额外提供 HTTP 文件接口(仅在 http 模式下可用): - POST /upload: 上传文件到服务器 @@ -315,7 +313,8 @@ async def list_docx_images(docx_url: str) -> List[Dict[str, Any]]: imgs = get_images_info(_download_to_temp(docx_url, suffix=".docx")) return imgs -def edit_docx( +@mcp.custom_route("/edit_docx", methods=["POST"]) +async def edit_docx( input_docx_path: str, replacements: List[Dict[str, str]] = None, image_replacements: Optional[List[Dict[str, Any]]] = None,