Egile MCP报告员
MCP服务器,用于生成多种格式的专业报告,并支持数据可视化。
特性
- 多种输出格式:
- PDF:通过WeasyPrint(HTML)提供高质量的PDF报告→带CSS的PDF) - 幻灯片:使用python pptx进行专业演示 - 超文本标记语言:带有图表和样式的交互式报告 - 标记语言:清除格式化的markdown文档
- 数据可视化:
- 带有排序和样式的表格 - 图表和图形(条形图、折线图、饼图、散点图) - 通过Plotly进行交互式绘图 - 支持pandas DataFrames
- 专业造型:
- 预构建的报告模板 - HTML/PDF的自定义CSS - PowerPoint主题和布局 - 响应式HTML设计
- 灵活的内容:
- 自动转换的Markdown输入 - 结构化数据(JSON、字典、DataFrames) - 图像和媒体嵌入 - 多节报告
安装
快速安装(推荐)
视窗:
.\install.batLinux/Mac:
chmod +x install.sh
./install.sh手动安装
# Install from source
pip install -e .开发安装
# Install with dev dependencies
pip install -e ".[dev]"配置
创建一个 .env 文件基于 .env.example:
# Output configuration
DEFAULT_FORMAT=pdf
OUTPUT_DIR=./reports
# PDF settings
PDF_PAGE_SIZE=A4
PDF_MARGINS=20mm
# PowerPoint settings
PPTX_THEME=default
PPTX_SLIDE_WIDTH=10
PPTX_SLIDE_HEIGHT=7.5
# Chart settings
CHART_THEME=plotly_white
CHART_DPI=300用法
作为MCP服务器
服务器公开了以下工具:
1. create_report
从结构化数据生成完整的报告。
{
"title": "Q4 Investment Report",
"format": "pdf", # pdf, pptx, html, markdown
"sections": [
{
"title": "Portfolio Summary",
"type": "text",
"content": "Portfolio performance overview..."
},
{
"title": "Holdings",
"type": "table",
"data": [...], # List of dicts or DataFrame
"columns": ["Ticker", "Shares", "Value", "P/L"]
},
{
"title": "Performance Chart",
"type": "chart",
"chart_type": "bar",
"data": {...}
}
],
"output_path": "reports/investment_report.pdf"
}2. markdown_to_pdf
将markdown内容转换为PDF。
{
"markdown": "# Report Title\n\nContent...",
"output_path": "report.pdf",
"title": "My Report",
"styles": {...} # Optional CSS overrides
}3. markdown_to_pptx
将markdown转换为PowerPoint演示文稿。
{
"markdown": "# Slide 1\n\nContent...\n\n## Slide 2\n\nMore content...",
"output_path": "presentation.pptx",
"title": "My Presentation"
}4. create_data_visualization
生成独立图表/图形。
{
"data": {"labels": [...], "values": [...]},
"chart_type": "bar", # bar, line, pie, scatter, etc.
"output_path": "chart.png",
"title": "Performance Chart"
}5. combine_reports
将多个报告合并为一个。
{
"reports": ["report1.pdf", "report2.pdf"],
"output_path": "combined.pdf",
"format": "pdf"
}程序化使用
from egile_mcp_reporter.server import mcp
# Run via FastMCP
mcp.run(transport="stdio")直接服务使用
from egile_mcp_reporter.report_service import ReportService
service = ReportService()
# Create PDF report
report = service.create_pdf_report(
title="Investment Report",
sections=[
{"type": "text", "content": "Overview..."},
{"type": "table", "data": holdings_data}
],
output_path="report.pdf"
)
# Create PowerPoint
presentation = service.create_pptx_report(
title="Quarterly Review",
sections=sections,
output_path="presentation.pptx"
)
# Generate chart
chart = service.create_chart(
data={"x": [1, 2, 3], "y": [10, 20, 15]},
chart_type="line",
output_path="chart.png"
)报告模板
投资报告模板
{
"template": "investment",
"data": {
"portfolio_summary": {...},
"holdings": [...],
"recommendations": [...]
}
}业务报告模板
{
"template": "business",
"data": {
"executive_summary": "...",
"metrics": {...},
"insights": [...]
}
}MCP集成
添加到MCP客户端配置中:
{
"mcpServers": {
"reporter": {
"command": "python",
"args": ["-m", "egile_mcp_reporter.server"]
}
}
}例子
看 tests/ 综合示例目录:
test_pdf_generation.py-PDF报告示例test_pptx_generation.py-PowerPoint示例test_chart_generation.py-数据可视化test_templates.py-使用预构建的模板
建筑
egile-mcp-reporter/
├── src/egile_mcp_reporter/
│ ├── server.py # FastMCP server
│ ├── report_service.py # Core report generation
│ ├── pdf_generator.py # PDF creation (WeasyPrint)
│ ├── pptx_generator.py # PowerPoint creation
│ ├── html_generator.py # HTML reports
│ ├── chart_service.py # Data visualization
│ ├── templates/ # Report templates
│ │ ├── pdf/
│ │ ├── pptx/
│ │ └── html/
│ └── utils/
│ ├── markdown.py # Markdown processing
│ └── styling.py # CSS/theme management
└── tests/许可证
MIT许可证-有关详细信息,请参阅许可证文件。
