HWPX文档处理服务

基于Model Context Protocol的HWPX文档读取、编辑和创建服务,支持文档生命周期管理、内容提取和格式化操作。

  • by DaveDev42
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 DaveDev42/hwpx-mcp

使用说明

hwpx mcp

MCP服务器,用于读取、编辑和创建 HWPX documents(Hancomoffice XML format)。

建立在 python hwpx 和那个 模型上下文协议.

安装

# Run directly with uvx (no install needed)
uvx hwpx-mcp

# Or install with uv
uv tool install hwpx-mcp

Claude桌面配置

添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "hwpx": {
      "command": "uvx",
      "args": ["hwpx-mcp"]
    }
  }
}

要限制对特定目录的文件访问,请执行以下操作:

{
  "mcpServers": {
    "hwpx": {
      "command": "uvx",
      "args": ["hwpx-mcp", "--allowed-dirs", "/path/to/documents"]
    }
  }
}

Claude代码配置

添加 .mcp.json:

{
  "mcpServers": {
    "hwpx": {
      "command": "uvx",
      "args": ["hwpx-mcp"]
    }
  }
}

工具

文档生命周期

工具 说明
open_document 打开一个.hwpx文件,返回一个 doc_id
create_document 创建新的空文档
save_document 保存到磁盘(原始路径或新路径)
close_document 关闭并从记忆中释放
list_open_documents 列出所有打开的文档

阅读

工具 说明
get_document_text 将内容导出为文本、HTML或Markdown
get_document_info 结构摘要(章节、段落计数)
list_paragraphs 列出带有索引和文本预览的段落

编辑

工具 说明
add_paragraph 添加一段
remove_paragraph 按索引删除段落
add_table 添加一个包含可选单元格数据的表
replace_text 在文档中查找和替换文本
set_header_footer 设置页眉和/或页脚文本

搜索

工具 说明
find_by_tag 按标记名称搜索XML元素

示例工作流程

  1. create_document → get doc_id
  2. add_paragraph(doc_id, "제목") → 添加标题
  3. add_table(doc_id, 3, 2, [["이름", "나이"], ["홍길동", "30"], ["김철수", "25"]]) → 添加表格
  4. set_header_footer(doc_id, header_text="보고서") → 设置标题
  5. save_document(doc_id, "/path/to/output.hwpx") → save
  6. close_document(doc_id) → 清理

许可证

该项目根据 MIT许可证.

关于python hwpx的说明

此服务器依赖于 python hwpxpython hwpx GitHub存储库和README声明MIT许可证,尽管PyPI分类器表示非商业许可证。请查看 python hwpx许可证 针对您的用例。