HWP-MCP 是一个 Model Context Protocol (MCP) 服务器,它允许像 Claude 这样的AI模型控制韩文文字处理器 (HWP)。此项目为AI提供了自动创建、编辑和操作韩文文档的功能。
git clone https://github.com/jkf87/hwp-mcp.git
cd hwp-mcp
pip install -r requirements.txt
pip install mcp
在 Claude 桌面设置文件中注册 HWP-MCP 服务器如下:
{
"mcpServers": {
"hwp": {
"command": "python",
"args": ["路径/hwp-mcp/hwp_mcp_stdio_server.py"]
}
}
}
hwp_create()
hwp_insert_text("输入您想要的文本。")
# 创建表格
hwp_insert_table(rows=5, cols=2)
# 填充表格数据
hwp_fill_table_with_data([
["月", "销售量"],
["1月", "120"],
["2月", "150"],
["3月", "180"],
["4月", "200"]
], has_header=True)
# 在表中填充连续数字
hwp_fill_column_numbers(start=1, end=10, column=1, from_first_cell=True)
hwp_save("路径/文档名.hwp")
hwp_batch_operations([
{"operation": "hwp_create"},
{"operation": "hwp_insert_text", "params": {"text": "标题"}},
{"operation": "hwp_set_font", "params": {"size": 20, "bold": True}},
{"operation": "hwp_save", "params": {"path": "路径/文档名.hwp"}}
])
hwp-mcp/
├── hwp_mcp_stdio_server.py # 主服务器脚本
├── requirements.txt # 依赖包列表
├── hwp-mcp-结构说明.md # 项目结构说明文档
├── src/
│ ├── tools/
│ │ ├── hwp_controller.py # 控制韩文的核心控制器
│ │ └── hwp_table_tools.py # 专门处理表格功能的模块
│ ├── utils/ # 工具函数
│ └── __tests__/ # 测试模块
└── security_module/
└── FilePathCheckerModuleExample.dll # 安全模块
默认情况下,韩文程序在外部访问文件时会显示安全警告。为了绕过这一点,我们使用了 FilePathCheckerModuleExample.dll 模块。即使安全模块注册失败,功能仍然可以工作,但在打开/保存文件时可能会出现安全对话框。
如果韩文程序未运行,则可能无法建立连接。请确保韩文程序已安装且正常运行。
在向表格输入数据时,光标位置有时会与预期不同,但当前版本已经解决了这个问题。现在可以准确地将数据输入到表格的所有单元格中。
hwp_table_tools.py)hwp_fill_column_numbers 函数中增加了 from_first_cell 选项本项目根据 MIT 许可证发布。详情请参阅 LICENSE 文件。
有关项目的问题,请通过 GitHub Issues 或 柯南老师 联系我们。