MCP CSV Sales Analyzer
Analyzes sales CSV data to filter records, compute KPIs, and generate AI-powered insights and recommendations using OpenAI.
README
MCP CSV Sales Analyzer (With OpenAI)
A course project featuring an MCP server that analyzes sales CSV data and provides:
- Data filtering capabilities
- KPI calculation tools
- OpenAI-powered insights, summaries, and recommendations based on KPIs
Project Structure
mcp-server/
├─ data/
│ └─ Online Sales Data.csv
├─ src/
│ ├─ server.py
│ └─ client.py
├─ images/
├─ .windsurf/
│ └─ workflows/
│ └─ insights.md
├─ analysis.md
├─ csv-sales-analyzer.pbix
├─ requirements.txt
└─ README.md
Requirements
- Python 3.10+
- Node.js (only if using the Inspector)
- OpenAI API Key (set as environment variable)
Setup (Windows PowerShell)
1) Create Virtual Environment and Install Dependencies
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
2) Set OpenAI API Key
setx OPENAI_API_KEY "sk-..."
Running the Application
1) Start MCP Server
Run from the project root:
cd C:\Users\<yourname>\repos\mcp-server
.\.venv\Scripts\Activate.ps1
python .\src\server.py
The server will be available at:
http://127.0.0.1:8000/mcp
Note: The endpoint requires SSE, so browser access will return 406 (this is expected).
Optional: MCP Inspector (Manual Tool Testing)
In a new terminal:
npx -y @modelcontextprotocol/inspector
Connection details:
- Transport:
streamable-http - URL:
http://127.0.0.1:8000/mcp
Available Tools (MCP)
The server exposes 3 main tools:
filter_sales_data(filters)
- Returns filtered records preview and total count
compute_sales_kpis(filters)(Computational Tool)
- Returns KPIs: revenue, units, orders, averages, breakdown by category/region, and top products
openai_generate_insights(kpis, question)(Uses OpenAI)
- Processes KPIs (not raw CSV) and returns:
- Insights (list)
- Summary (short text)
- Recommendations (list)
Client Script
The src/client.py script:
- Calls
compute_sales_kpis - Passes results to
openai_generate_insights - Prints Insights, Summary, and Recommendations
To run:
.\.venv\Scripts\Activate.ps1
python .\src\client.py
Configuration (Optional)
Customize model and temperature via environment variables:
$env:OPENAI_MODEL="gpt-4o-mini"
$env:OPENAI_TEMPERATURE="0.2"
Example Output
Sample output from running client.py:
=== INSIGHTS ===
1. Total revenue generated is approximately $80,567.85 from 240 orders, indicating an average revenue per order of about $335.69.
2. The average unit price weighted is $155.54, while the average unit price simple is significantly higher at $236.40, suggesting a disparity in pricing strategies or product mix.
3. Electronics category leads in revenue with $34,982.41, accounting for 43.4% of total revenue, followed by Home Appliances at 23.1%.
4. North America generated the highest revenue at $36,844.34, representing 45.7% of total revenue, while Asia contributed $22,455.45 (27.8%) and Europe $21,268.06 (26.5%).
5. The top product by revenue is the Canon EOS R5 Camera, generating $3,899.99 from a single unit sold, indicating a high-value item in the inventory.
=== SUMMARY ===
The analysis reveals strong revenue generation primarily from the Electronics category and North America region. There is a notable difference between average unit prices, indicating potential pricing strategy adjustments. The top products are high-value items, suggesting a focus on premium offerings could be beneficial.
=== RECOMMENDATIONS ===
1. Consider increasing marketing efforts for the Electronics category, which is the highest revenue generator, to further capitalize on its success.
2. Evaluate pricing strategies to align the average unit price simple and weighted, potentially adjusting prices to improve overall sales volume without sacrificing revenue.
3. Explore opportunities to expand product offerings in the North American region, as it shows the highest revenue contribution, while also assessing potential growth in the Asia and Europe markets.
Results Analysis
See: analysis.md
PowerBI Dashboard
A PowerBI dashboard (csv-sales-analyzer.pbix) is included for visual data exploration and analysis.
Windsurf Workflows
The project includes custom workflows in .windsurf/workflows/:
insights.md: Automated workflow for generating sales insights using MCP tools
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。