Skip to main content

LuLab Convert MCP Server - A document conversion server supporting DOCX to multiple formats

Project description

LuLab Convert MCP Server

一个用于在 MCP 环境中进行 Word 文档转换的服务器,支持将 DOCX 转换为多种格式。

🚀 现已支持所有兼容MCP协议的AI客户端!

支持的AI客户端包括但不限于:

  • Claude Desktop
  • Cline (VS Code扩展)
  • 其他支持MCP协议的AI工具

📦 安装方式

方法 1: 从 PyPI 安装 (推荐)

最简单的方式!无需克隆代码库

# 使用 pip 安装
pip install lulab-convert-mcp-server

# 或使用 uv 安装
uv pip install lulab-convert-mcp-server

MCP 客户端配置 (Claude Desktop):

{
  "mcpServers": {
    "lulab-convert-mcp-server": {
      "command": "uvx",
      "args": [
        "lulab-convert-mcp-server"
      ],
      "env": {
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

📖 详细的 PyPI 使用指南: 请查看 PYPI_USAGE.md

方法 2: 本地开发安装

  1. 克隆或下载此项目
  2. 安装依赖:pip install -r requirements.txt
  3. 在您的AI客户端配置文件中添加MCP服务器配置(参考下方json配置示例)

功能特性

  • DOCX → PDF(使用 docx2pdf 或 LibreOffice)
  • DOCX → TXT(提取纯文本)
  • DOCX → HTML(使用 mammoth 进行语义化 HTML 转换)
  • DOCX → Markdown(先转 HTML,再用 markdownify 转为 Markdown)
  • DOCX → RTF(通过 LibreOffice 转换)
  • DOCX → ODT(通过 LibreOffice 转换)
  • DOCX → DOC(通过 LibreOffice 转换)
  • DOC → DOCX(通过 LibreOffice 转换)
  • TXT/ODT/RTF/DOC → PDF(通过 LibreOffice 转换)
  • HTML ↔ Markdown(markdownifymarkdown
  • HTML → PDF(通过 LibreOffice soffice --convert-to pdf
  • HTML → DOCX(通过 LibreOffice 转换)
  • Markdown → PDF(先转 HTML,再用 LibreOffice 转 PDF)
  • Markdown → DOCX(先转 HTML,再用 LibreOffice;无LibreOffice时回退为简易解析)
  • TXT → DOCX(使用 python-docx 生成文档)
  • ODT/RTF → DOCX(通过 LibreOffice 转换)

客户端配置示例:Claude Desktop

在Claude Desktop配置文件中添加:

{
  "mcpServers": {
    "office-word-mcp-server": {
      "command": "python",
      "args": [
        "-m",
        "word_document_server.main"
      ],
      "env": {
        "PYTHONPATH": "e\\mcp-sever",
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

MCP 工具列表

  • convert_to_pdf(input_path, output_path=None)
  • convert_to_txt(input_path, output_path=None)
  • convert_to_html(input_path, output_path=None)
  • convert_to_markdown(input_path, output_path=None)
  • convert_to_rtf(input_path, output_path=None)
  • convert_to_odt(input_path, output_path=None)
  • convert_to_doc(input_path, output_path=None)
  • convert_doc_to_docx(input_path, output_path=None)
  • convert_html_to_markdown(input_path, output_path=None)
  • convert_markdown_to_html(input_path, output_path=None)
  • convert_html_to_pdf(input_path, output_path=None)
  • convert_markdown_to_pdf(input_path, output_path=None)
  • convert_txt_to_pdf(input_path, output_path=None)
  • convert_odt_to_pdf(input_path, output_path=None)
  • convert_rtf_to_pdf(input_path, output_path=None)
  • convert_html_to_docx(input_path, output_path=None)
  • convert_markdown_to_docx(input_path, output_path=None)
  • convert_txt_to_docx(input_path, output_path=None)
  • convert_odt_to_docx(input_path, output_path=None)
  • convert_rtf_to_docx(input_path, output_path=None)

说明:

  • input_path 为输入文件的绝对路径。(如 e\\mcp-sever\\docs\\sample.docx
  • output_path 可选;不提供时将自动生成与输入同名的目标文件(扩展名分别为 .pdf/.txt/.html/.md/.rtf/.odt/.doc/.docx)。
  • Windows/macOS/Linux:若需要 rtf/odt/dochtml/md/txt → docx/pdf 功能,请安装 LibreOffice;否则部分功能将降级或返回安装提示。

使用提示:

  • convert_to_doc(input_path) 将 DOCX 转为旧版 .doc 格式,建议仅在兼容旧系统时使用。
  • convert_doc_to_docx(input_path).doc 升级为现代 .docx,便于后续处理与版本控制。
  • convert_*_to_pdf(input_path) 系列统一通过 LibreOffice 生成 PDF,输出路径不提供时默认与输入同目录。

备注

  • 进行 PDF 转换时,若系统未安装 LibreOffice,HTML→PDFMarkdown→PDF 会提示安装需求。
  • 部分受保护/加密的文档可能需要额外处理;工具会尽力提取文本并给出错误信息。
  • 转换结果质量依赖源文档结构与样式;HTML/Markdown 转换倾向保持语义结构而非原始布局。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lulab_convert_mcp_server-1.1.13.tar.gz (41.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lulab_convert_mcp_server-1.1.13-py3-none-any.whl (63.1 kB view details)

Uploaded Python 3

File details

Details for the file lulab_convert_mcp_server-1.1.13.tar.gz.

File metadata

File hashes

Hashes for lulab_convert_mcp_server-1.1.13.tar.gz
Algorithm Hash digest
SHA256 1aabaae77533b53cca85861fa3e9c4ba28c9c543acfa810a8ba057447751c371
MD5 3e4f317e11c1a0d6f2a91345239a1ef0
BLAKE2b-256 d891f40feb42205d983f7605b596710bc8386089d37c3c5b43c9768299e5c40b

See more details on using hashes here.

File details

Details for the file lulab_convert_mcp_server-1.1.13-py3-none-any.whl.

File metadata

File hashes

Hashes for lulab_convert_mcp_server-1.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 4c4898e54325aed6b848b203498564be4b905a393606c224793504477b3e7e99
MD5 a2876b88b1eb3a5761bcd4ea199b1d32
BLAKE2b-256 e8e8e33d0acefcc2b6ae2ccfeb7c9d6d468c7051cd06ca3a28a4ec85d828bc8d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page