docgen mcp
MCP服务器,用于生成具有结构化格式的专业文档——Word(.docx)和Google Docs。
特性
- Word文档生成 来自模板(简报、备忘录、提案等)
- 谷歌文档生成 通过结构化JSON部分
- 富文本格式:粗体、斜体、下划线、颜色、链接、代码
- 文档元素:标题、段落、列表、表格、标注、代码块
- 图像支持:通过驱动器上传公共URL或本地文件
- 页眉/页脚 具有对齐选项
- 嵌套的列表 具有多种编号样式
- 表格单元格样式:每个单元格的背景、粗体和对齐方式
- 两种情况:TMA(咨询)或PWP(内部)
先决条件
- Node.js 18+
- 对于Google Docs:启用了Docs和Drive API的Google Cloud项目
- OAuth 2.0凭据(与gmail mcp共享令牌)
安装
git clone https://github.com/mideliberto/docgen-mcp.git
cd docgen-mcp
npm install
npm run build配置
环境变量(适用于Google Docs)
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your-secret
TOKEN_ENCRYPTION_KEY=your-32-byte-base64-key
TOKEN_STORAGE_PATH=~/gmail_mcp_tokens/tokens.jsonClaude桌面配置
添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"docgen": {
"command": "node",
"args": ["/path/to/docgen-mcp/dist/index.js"],
"env": {
"GOOGLE_CLIENT_ID": "...",
"GOOGLE_CLIENT_SECRET": "...",
"TOKEN_ENCRYPTION_KEY": "...",
"TOKEN_STORAGE_PATH": "~/gmail_mcp_tokens/tokens.json"
}
}
}
}快速开始
谷歌文档(create_Google_doc)
{
"title": "My Document",
"config": "pwp",
"sections": [
{ "type": "heading", "level": 1, "text": "Introduction" },
{ "type": "paragraph", "content": "Hello, world!" },
{ "type": "bullet_list", "items": ["First item", "Second item"] }
]
}退货: { "id": "...", "webViewLink": "https://docs.google.com/..." }
Word文档(generate_document)
{
"doc_type": "brief",
"context": "tma",
"title": "Cloud Migration Strategy",
"content": {
"executive_summary": "Migrate to Azure over 6 months.",
"recommendation": "Proceed with phased migration.",
"next_steps": ["Inventory systems", "Select pilot workloads"]
}
}返回:生成的.docx文件的路径
工具
| 工具 | 说明 |
|---|---|
create_google_doc | 从结构化部分创建Google文档 |
generate_document | 从模板创建Word文档 |
get_section_schema | 获取Google Docs部分的架构 |
list_document_types | 列出Word文档类型 |
get_template_schema | 获取Word文档类型的架构 |
文档
- 用法.md -完整的API参考
create_google_doc - Word文档架构 -请参阅下文
generate_document内容模式
Word文档类型
| 类型 | 描述 |
|---|---|
brief | 附有建议的执行简报 |
memo | 内部备忘录 |
proposal | 带范围/时间表的项目建议书 |
meeting_notes | 会议纪要 |
project_summary | 状态报告 |
assessment | IT评估及其结果 |
risk_register | 风险跟踪表 |
runbook | 操作程序 |
已知限制
- 谷歌文档中没有页码:REST API不支持自动图文集
- 无书签:REST API缺少
createBookmark - 本地图片:自动上传到驱动器,需要公开共享
看 docs/api-quirks.md 适用于Google Docs API限制。
发展
npm run dev # Watch mode
npm run build # Production build
npm start # Run server许可证
麻省理工学院
