Skip to main content

一个AI驱动的动态文档生成服务,可将文本转换为设计精美的图片。

Project description

DocGenius - AI驱动的动态文档生成服务

DocGenius 是一个基于模型上下文协议(MCP)的智能服务,能够接收用户的自然语言指令和文本内容,自主选择合适的文档模板,将文本内容渲染成设计精美的HTML,并输出为图片。

🚀 特性

  • 动态模板发现: AI能够自动扫描并发现可用的文档模板
  • 智能模板选择: 根据用户需求自动选择最合适的模板
  • 多种模板支持: 支持简历、知识卡片等多种文档类型
  • 高质量渲染: 使用Playwright进行精确的HTML到图片转换
  • 按模板分类存储: 自动按模板类型组织输出文件
  • 基于FastMCP: 使用现代化的MCP框架构建

📁 项目结构

card-creator-mcp/
├── templates/              # 模板文件目录
│   ├── resume.md          # 简历模板
│   └── knowledge_card.md  # 知识卡片模板
├── pic/                   # 输出图片目录(自动创建)
├── main_service.py        # 主服务文件
├── requirements.txt       # 项目依赖
└── README.md             # 项目文档

🛠️ 安装依赖

首先确保你已安装Python 3.10+,然后安装项目依赖:

pip install -r requirements.txt

安装Playwright浏览器:

playwright install chromium

🏃‍♂️ 运行服务

启动DocGenius MCP服务:

python main_service.py

或使用FastMCP CLI:

fastmcp run main_service.py

🎯 可用工具

1. list_available_templates()

列出所有可用的文档模板。

返回: 包含模板名称和描述的列表

2. get_template_details(template_name: str)

获取指定模板的详细信息,包括元数据和提示词。

参数:

  • template_name: 模板名称

返回: 包含模板详细信息的字典

3. create_image_from_html(html_content: str, template_name: str, file_name: str, width: int, height: int)

将HTML内容渲染为图片并保存。

参数:

  • html_content: HTML代码字符串
  • template_name: 使用的模板名称
  • file_name: 输出文件名(不含扩展名)
  • width: 图片宽度
  • height: 图片高度

返回: 任务执行结果字符串

📋 模板格式

模板文件采用Markdown格式,包含YAML Frontmatter:

---
description: "模板描述"
width: 800
height: 600
---
这里是提示词内容,使用 {user_text} 作为用户输入的占位符。

🔧 技术栈

  • FastMCP: MCP服务框架
  • Playwright: 无头浏览器自动化
  • python-frontmatter: YAML frontmatter解析
  • aiofiles: 异步文件操作

📝 使用示例

  1. 列出可用模板:

    templates = await client.call_tool("list_available_templates")
    
  2. 获取模板详情:

    details = await client.call_tool("get_template_details", {"template_name": "resume"})
    
  3. 生成图片:

    result = await client.call_tool("create_image_from_html", {
        "html_content": "<html>...</html>",
        "template_name": "resume",
        "file_name": "my_resume",
        "width": 827,
        "height": 1169
    })
    

🚧 开发状态

该项目目前处于1.1版本,包含核心功能实现。未来计划增加更多模板类型和自定义选项。

📄 许可证

本项目采用MIT许可证开源。

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

docgenius_service-2.0.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

docgenius_service-2.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file docgenius_service-2.0.0.tar.gz.

File metadata

  • Download URL: docgenius_service-2.0.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for docgenius_service-2.0.0.tar.gz
Algorithm Hash digest
SHA256 0ebe76dc7dfa7989cab319a821736a0f98ed08717a7efb75d07aba3f73607b9d
MD5 47f8f1461d78470cb3417ce082b0a951
BLAKE2b-256 c97118d86697d4c97b90a71499eea00a64c3bb8c241b32d5753f2fd80b189ce6

See more details on using hashes here.

File details

Details for the file docgenius_service-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for docgenius_service-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a54eee4b9f678444abca67171199c97a9c6adb0a9673c8a740dfe6d3c892588
MD5 99f51888ef603ccc8a46fa20dd6cf990
BLAKE2b-256 f9e99d26b17d612fd9da72b27287a533fd8e52992af966f8251b9f9efa920fbb

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