mcp-data-summary
Enables LLMs to generate visual summary reports from CSV datasets using MCP Resources, Tools, and Prompts, without exposing raw data to the model.
README
mcp-data-summary
A learning project for building an MCP server with the official Python SDK.
The server lets an LLM produce a visual summary report from CSV datasets without ever loading raw data into the model's context. It simulates a REST API (fake GET/POST), exposes data schemas as MCP Resources, provides chart and document generation as MCP Tools, and guides the whole workflow with an MCP Prompt.
What it demonstrates
| MCP concept | File | What it does |
|---|---|---|
| Resources | resources/datasets.py |
Expose dataset schemas via fake GET endpoints |
| Tools | tools/chart_tools.py |
Generate bar, line, histogram, pie charts, dataset subset |
| Tools | tools/stats_tools.py |
Descriptive stats + correlation matrix + scatter plot |
| Tools | tools/document_tools.py |
Build HTML report + export PDF via fake POST |
| Prompts | prompts/summary_prompt.py |
7-step guided workflow for the LLM |
| Fake API | api/fake_client.py |
Simulated REST client backed by local CSV and JSON files |
| Schemas | api/schemas.py |
Pydantic models for all API responses |
How it works
The LLM never sees raw tabular data. Instead it follows this pipeline:
GET /datasets → discover available datasets
GET /datasets/{name} → inspect a plot-friendly schema (columns, dtypes, sample values)
tool: get_summary_statistics → understand distributions and correlations
tool: generate_*_chart → produce PNG charts saved to output/ and feedbacks to understand the charts
tool: build_html_report → render a Jinja2 HTML report from the chart paths
tool: export_pdf_report → convert HTML to PDF and POST it back to the fake API
Project structure
mcp-data-summary/
├── data/ # Sample CSV files and JSON dataset descriptions (auto-discovered)
│ ├── descriptions.json
│ ├── sales.csv
│ └── users.csv
├── output/ # Generated charts, HTML and PDF reports
├── scripts/
│ └── run_pipeline.py # End-to-end pipeline runner (no LLM needed)
├── tests/
│ ├── conftest.py # Shared pytest fixtures
│ ├── test_fake_client.py # Unit tests for the API layer
│ ├── test_chart_tools.py # Tests for all chart tools
│ └── test_stats_and_docs.py # Tests for stats tool + HTML builder
├── src/
│ └── mcp_data_summary/
│ ├── server.py # Entry point — wires everything together
│ ├── api/
│ │ ├── fake_client.py # Simulates GET /datasets and POST /reports
| | ├── json_encoder.py # Custom JSON encoder
│ │ └── schemas.py # Pydantic models for API responses
│ ├── resources/
│ │ └── datasets.py # MCP Resources: dataset list + schema
│ ├── tools/
│ │ ├── chart_tools.py # Bar, line, histogram, pie chart tools
│ │ ├── stats_tools.py # Summary statistics + scatter plot
│ │ └── document_tools.py # HTML report builder + PDF exporter
│ └── prompts/
│ └── summary_prompt.py # Guided 7-step workflow prompt
└── pyproject.toml
Quick start
1. Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
2. Install dependencies
uv sync
3. Verify everything works (no LLM required)
Run the pipeline script — it simulates the full LLM workflow end-to-end:
uv run python scripts/run_pipeline.py
# Restrict to a single dataset
uv run python scripts/run_pipeline.py --datasets sales
Charts and a report will appear in output/.
4. Run the test suite
uv run pytest
5. Open the MCP Inspector (browser-based debug UI)
uv run mcp dev src/mcp_data_summary/server.py
This lets you browse Resources, call Tools manually, and inspect request/response payloads
6. Example - Connect to Claude Desktop
Add this block to your claude_desktop_config.json
(~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows):
{
"mcpServers": {
"data-summary": {
"command": "uv",
"args": [
"--directory", "/absolute/path/to/mcp-data-summary",
"run", "mcp-data-summary"
]
}
}
}
Restart Claude Desktop, then load the data_summary_workflow prompt. The LLM will discover datasets, inspect schemas, generate charts, and produce a PDF report autonomously.
Available tools
| Tool | Input | Output |
|---|---|---|
get_summary_statistics |
dataset name | JSON with describe + correlation |
generate_bar_chart |
dataset, x/y columns, optional group_by |
PNG path and chart data |
generate_line_chart |
dataset, x/y columns, optional group_by |
PNG path and chart data |
generate_histogram |
dataset, column, bins | PNG path and chart data |
generate_pie_chart |
dataset, category + value columns | PNG path and chart data |
generate_scatter_plot |
dataset, x/y columns, optional color_by |
PNG path and chart data |
build_subset_dataset |
dataset, filters | Subset name, path and schema |
build_html_report |
title, chart paths, captions, summary | HTML path |
export_pdf_report |
HTML path, report name | JSON with pdf path + report_id |
Available resources
| URI | Returns |
|---|---|
datasets://list |
JSON array of available dataset names |
datasets://{name}/schema |
Plot-friendly schema: columns, dtypes, n_unique, sample values |
Adding your own CSV
Drop any .csv file into data/. The server auto-discovers it on startup. Add a description in data/descriptions.json:
{
"your_file": "Description the LLM will see when reading the schema.",
}
Date columns are auto-detected if their name contains "date".
System dependencies for PDF export
WeasyPrint (used by export_pdf_report) requires Cairo and Pango to be installed at the OS level. The HTML report and all charts work without them.
# Ubuntu / Debian
sudo apt install libpango-1.0-0 libcairo2 libpangocairo-1.0-0
# macOS
brew install pango cairo
# Windows — follow the WeasyPrint install guide:
# https://doc.courtbouillon.org/weasyprint/stable/first_steps.html
Next steps
- Support multi-dataset joins before charting
- Introduce a simple auth token to the fake API layer
- Stream chart generation progress back to the client using MCP notifications
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。