PDF Report Generator MCP

PDF Report Generator MCP

Generates professional PDF reports with live Power BI dashboards, charts, and insights from plain-text prompts containing CSV data.

Category
访问服务器

README

PDF Report Generator MCP (with real Power BI dashboard)

FastMCP server that turns one plain-text prompt (with embedded CSV data) into: a live Power BI dashboard, chart images, executive summary, insights, recommendations, and a professional PDF report.

1. Install dependencies

python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt

2. Configure .env

AZURE_OPENAI_API_KEY=your_key_here
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini
AZURE_OPENAI_API_VERSION=2024-08-01-preview

POWERBI_CLIENT_ID=your_client_id_here
POWERBI_CLIENT_SECRET=your_client_secret_here
POWERBI_TENANT_ID=your_tenant_id_here
POWERBI_WORKSPACE_ID=your_workspace_id_here

LOG_LEVEL=INFO
GENERATED_DIR=generated

Getting the Power BI values

  • Client ID / Client Secret / Tenant ID: from the Azure AD app registration (Azure Portal -> App registrations). The app needs the Dataset.ReadWrite.All Power BI API permission, with admin consent granted.
  • Workspace ID: open your workspace at app.powerbi.com, copy the GUID from the URL: app.powerbi.com/groups/<WORKSPACE_ID>/list
  • The workspace's tenant must also have "Allow service principals to use Power BI APIs" enabled (Power BI Admin Portal -> Tenant settings), and the app should be added as a member of the target workspace.

3. Test without any MCP client

python test_local.py

This prints the executive summary, insights, recommendations, chart file paths, the live Power BI dashboard URL, and the PDF path.

4. Run as an MCP server

python server.py

5. Test with MCP Inspector (requires Node.js)

npx @modelcontextprotocol/inspector python server.py

Example client prompt

Generate a professional sales report from the following data.

OrderID,Region,Sales,Profit
101,North,12000,3000
102,South,9000,1800
103,East,15000,4500
104,West,7000,1200

Generate:
Bar Chart
Pie Chart
Power BI Dashboard
Professional PDF Report

Expected output (ReportResponse)

  • powerbi_dashboard_url -> live link to the dataset/report in app.powerbi.com
  • powerbi_dataset_id -> the push dataset's ID
  • chart_paths -> PNGs in generated/charts/ (embedded in the PDF)
  • pdf_path -> PDF in generated/reports/
  • executive_summary, insights, recommendations -> LLM-generated text

How the Power BI integration works

services/powerbi_service.py uses MSAL's client-credentials flow to get an app-only access token (no human login), then:

  1. Checks if a push dataset with this report's name already exists in the workspace; creates one if not, with a schema matching the DataFrame columns.
  2. Pushes all rows into that dataset via the REST API, in batches.
  3. Returns a URL to view it at app.powerbi.com.

If Power BI publishing fails (e.g. permission not yet active), the report still completes with charts/PDF/summary - the error is logged and powerbi_dashboard_url is left as null in the response.

Extending later

  • OneDrive upload: add services/onedrive_service.py using Microsoft Graph API (Files.ReadWrite permission on the same Azure AD app) to upload the finished PDF and return a shareable link.
  • Database/Excel input: swap PromptService._extract_dataframe for a DB/Excel loader - the rest of the pipeline doesn't change.

Project structure

pdf-report-powerbi-mcp/
    config/settings.py         # env-driven, typed settings
    models/                    # ReportRequest, ChartSpec, ReportResponse
    services/
        prompt_service.py      # raw text -> ReportRequest (CSV parsing)
        openai_service.py      # Azure OpenAI wrapper
        summary_service.py     # data profiling + summary/insights/recs
        chart_service.py       # matplotlib chart rendering (for the PDF)
        powerbi_service.py     # real Power BI push-dataset integration
        pdf_service.py         # ReportLab PDF assembly
    tools/generate_report.py   # orchestrates the full pipeline
    utils/                     # logger, helpers
    server.py                  # FastMCP entrypoint
    test_local.py              # test without an MCP client

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选