Content
# KPI Dashboard MCP Server
Built with FastAPI and FastMCP, providing an intelligent KPI dashboard service.
Supports local data analysis and intelligent agent interaction, suitable for enterprise operations, business monitoring, intelligent analysis, and more.
## 🌟 Project Highlights
- ✅ Built with FastAPI for lightweight and high-performance HTTP interfaces
- 🤖 Integrated with FastMCP Server, supporting intelligent conversations with MCP clients (e.g., Cherry Studio)
- 📊 Built-in data analysis module, no external database or CSV files required
- 🔧 Supports local development debugging and VS Code plugin usage
## 📁 Project Structure
```
kpi-dashboard-mcp-server/
│
├── api.py # Provides data analysis-related APIs
├── helper.py # Data analysis utility functions (e.g., KPI calculations)
├── main.py # Starts MCP Server service
├── data.py # Built-in simulated data, replacing CSV loading
├── requirements.txt # Required Python dependencies
└── README.md # Project documentation
```
## 🚀 Quick Start
### 1. Clone Repository
```bash
git clone https://github.com/aicoting/mcp_demo.git
cd mcp_demo
```
### 2. Create Virtual Environment (optional)
```bash
python -m venv venv
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activate
```
### 3. Install Dependencies
```bash
pip install -r requirements.txt
```
## ▶️ Start Service
### Start API Service (default port `8000`)
```bash
python api.py
```
Access documentation address:
* [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
### Start MCP Server Service (default port `8080`)
```bash
python main.py
```
After starting, output:
```
FastMCP Server is running at http://localhost:8080
```
> Example screenshots
> 
> 
## 🔗 Connect MCP Server in Cherry Studio
1. Open Cherry Studio
2. Go to settings → Add MCP service configuration
3. Use the following content:
```json
{
"name": "KPI Analysis Agent",
"command": "D:\\Anaconda\\envs\\mcp\\python.exe",
"args": [
"D:/Users/Desktop/mcp_demo/main.py"
],
"env": {
"PYTHONUNBUFFERED": "1"
}
}
```
After successful connection, you can chat with the agent through Cherry.
> 
## 📡 API Interface Description
### `GET /kpi/summary`
Returns KPI summary results.
#### Example Response:
```json
{
"total_sales": 150000,
"conversion_rate": 0.035,
"active_users": 3421
}
```
## 💡 Example: Adding New KPI Analysis Logic
Add in `helper.py`:
```python
def calculate_average_order_value(sales_data):
return sum(s["amount"] for s in sales_data) / len(sales_data)
```
Then use it in `api.py`'s `/kpi/summary` interface.
## 📚 Tech Stack
* [FastAPI](https://fastapi.tiangolo.com/)
* [FastMCP](https://github.com/zhplus/fastmcp)
* Python 3.8+
## 📌 FAQ
### Q: Visiting `http://127.0.0.1:8000/` shows 404?
A: Directly accessing the root path will return 404. Please use the following paths:
* [http://127.0.0.1:8000/kpi/summary](http://127.0.0.1:8000/kpi/summary)
* [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
## 🧑💻 Developer Suggestions
* You can replace `data.py` with a database or external interface data source
* MCP Server supports extended context memory, chart output, and multi-turn Q&A
* Can be used to build embedded knowledge bases, BI platforms, customer operation analysis systems, etc.
## 📄 License
MIT License