word-latex-mcp
将 Word 文档中的 LaTeX 公式批量转换为原生数学公式的 MCP (Model Context Protocol) 工具。
✨ 功能特性
- ✅ 一键批量转换 - 将
$...$和$$...$$格式的 LaTeX 公式转换为 Word 原生公式 - ✅ 多区域支持 - 支持正文、表格、页眉页脚、脚注、批注、文本框等
- ✅ 自动备份 - 转换前自动创建备份,安全可靠
- ✅ 智能识别 - 跳过金额(如
$100$)等误判场景 - ✅ 风险评估 - 6 种文档类型预设,适配不同场景
- ✅ 零配置运行 - 通过
uvx按需下载运行,无需预装
📋 系统要求
| 项目 | 要求 |
|---|---|
| 操作系统 | Windows 10/11 |
| Microsoft Word | 2016 或更高版本 |
| Python | 3.10+ |
⚠️ 注意:由于使用 Windows COM 自动化,此工具仅支持 Windows 平台。
🚀 快速开始
1. 配置 Cursor MCP
将以下配置添加到 Cursor 的 MCP 配置文件:
Windows 配置文件位置:%APPDATA%\Cursor\User\globalStorage\cursor.mcp\config.json
{
"mcpServers": {
"word-latex": {
"command": "uvx",
"args": ["word-latex-mcp"]
}
}
}
2. 重启 Cursor
配置完成后,重启 Cursor 以加载 MCP 工具。
3. 使用
- 打开 Word 文档 - 在 Microsoft Word 中打开包含 LaTeX 公式的文档
- 调用工具 - 在 Cursor 中告诉 AI:
"帮我把这个 Word 文档中的 LaTeX 公式转换为 Word 公式"
- 查看结果 - AI 会调用
convert_latex工具并返回转换报告
📖 工具参数
convert_latex
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
mode |
string | "quick" |
运行模式 |
backup |
bool | true |
是否自动备份 |
work_on_copy |
bool | false |
是否在副本上操作 |
skip_money_patterns |
bool | true |
是否跳过金额模式 |
profile |
string | "balanced" |
文档类型预设 |
selection |
string | "all" |
选择策略 |
运行模式 (mode)
| 值 | 说明 |
|---|---|
quick |
仅转换正文区域(含表格),速度最快 |
full |
转换全部区域(含页眉页脚、脚注、批注等) |
scan |
仅扫描统计,不做任何转换 |
文档类型预设 (profile)
| 值 | 说明 | 适用场景 |
|---|---|---|
balanced |
平衡模式 | 通用文档(默认) |
paper |
论文模式 | 学术论文,更激进识别 |
engineering |
工程模式 | 工程计算文档 |
strict |
严格模式 | 减少误转换 |
contract |
合同模式 | 避免金额误判 |
finance |
财务模式 | 最保守,强金额保护 |
💡 使用示例
快速转换正文
用户:把这个文档的 LaTeX 公式转换一下
AI:我来帮您转换。[调用 convert_latex(mode='quick')]
扫描预览
用户:先看看文档里有多少公式
AI:我来扫描一下。[调用 convert_latex(mode='scan')]
全区域转换
用户:把所有区域的公式都转换,包括页眉页脚
AI:好的。[调用 convert_latex(mode='full')]
保守转换(合同类文档)
用户:这是份合同,帮我转换公式,但别把金额搞错了
AI:我用合同模式来处理。[调用 convert_latex(profile='contract')]
🔧 备选安装方式
方式一:pipx 运行
{
"mcpServers": {
"word-latex": {
"command": "pipx",
"args": ["run", "word-latex-mcp"]
}
}
}
方式二:全局安装后运行
pip install word-latex-mcp
{
"mcpServers": {
"word-latex": {
"command": "word-latex-mcp"
}
}
}
❓ 常见问题
Q: 提示"无法连接到 Word 应用程序"
A: 请确保:
- Microsoft Word 已安装并能正常打开
- 有一个 Word 文档处于打开状态
Q: 转换后公式显示异常
A: 可能原因:
- LaTeX 语法在 Word 中不支持 - 工具会保留原文本不破坏
- Word 版本过低 - 建议使用 Word 2016 或更高版本
Q: 某些公式被跳过了
A: 默认会跳过:
- 疑似金额的模式(如
$100$) - 过长的片段
- 高风险内容
可使用 skip_money_patterns=false 关闭金额跳过,或使用 selection='all' 转换全部识别到的内容。
📄 许可证
MIT License - 详见 LICENSE 文件
🤝 贡献
欢迎提交 Issue 和 Pull Request!
Made with ❤️ for Word users who love LaTeX
Metadata
Release files for word-latex-mcp 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| word_latex_mcp-0.4.1.tar.gz | 35.9 kB | Without provenance | Details for word_latex_mcp-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| word_latex_mcp-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for word_latex_mcp-0.4.1-py3-none-any.whl |
Total release size: 78.7 kB
Release files / word_latex_mcp-0.4.1.tar.gz
| Download URL | word_latex_mcp-0.4.1.tar.gz |
|---|---|
| Size | 35.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
248a8a18e736faf118196d55fd475417b64a382af4b6d8800bbe5c91512bc867
|
|
BLAKE2b-256 checksum How to use checksums |
5c7169d9f11aecde3d01384c59d596ee7c7636a1aaf4708f1c2bf51cc18dd1bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Release files / word_latex_mcp-0.4.1-py3-none-any.whl
| Download URL | word_latex_mcp-0.4.1-py3-none-any.whl |
|---|---|
| Size | 42.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b25a776c799d43bccc274eed03d168e478bf5010a38207acb70851b69d1b17c4
|
|
BLAKE2b-256 checksum How to use checksums |
1b5a9c4b6d640a872f813a02c33637a5dac1d686a8fcbb5e5c0eb27ab00e361d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Security for word-latex-mcp 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.