FMCG Sales Forecasting MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
FMCG Multi-Branch Sales Forecasting & LLM Protocol Layer
End-to-end demand forecasting pipeline, authenticated FastAPI REST service, interactive Streamlit executive dashboard, and read-only Model Context Protocol (MCP) integration layer built on public Kaggle retail/FMCG distribution data.
Dataset Source: FMCG Daily Sales Data (2022–2024) (beatafaron/fmcg-daily-sales-data-to-2022-2024) — 190,757 daily transactions across 3 regional branches (PL-Central, PL-North, PL-South), 5 product categories, 13 segments, 14 brands, and 30 SKUs.
Architecture Overview
flowchart LR
subgraph Data Layer
A[Kaggle FMCG Dataset\n190,757 Daily Rows] --> B[Unified Item Mapping\nConnected Components Union-Find]
B --> C[Data Cleaning & Aggregation\nsrc/aggregation.py]
end
subgraph Forecasting Engine
C --> D[Multi-Model Backtesting\nNaive, SES, Holt, Prophet]
D --> E[Model Selection by WAPE]
E --> F[Precalculated Forecast Store\nJSON / CSV / Parquet]
end
subgraph Serving & Applications
F --> G[FastAPI REST Service\nHTTP Basic Auth]
G --> H[Streamlit Dashboard\nsrc/dashboard.py]
G --> I[LLM Protocol Layer MCP\nsrc/protocol.py]
end
subgraph Enterprise LLM
I --> J[Grounded LLM Tool Execution\nRead-Only Audit Trail]
endRelated MCP server: mcp-ai-assistant
Pipeline Highlights
Public Data Ingestion (
src/fetch_data.py): FetchesFMCG_2022_2024.csvviakagglehuband exports a compressed Parquet snapshot (data/sales_data.parquet, 1.27 MB) and field schema (data/field_schema.json).Unified Item Mapping (
src/item_mapping.py): Uses Disjoint-Set Union-Find acrosssku,brand, andsegmentto merge 30 SKUs, 14 Brands, and 13 Segments into 7 canonical product families (ITEM-JU-021,ITEM-MI-002,ITEM-MI-006,ITEM-RE-004,ITEM-RE-007,ITEM-SN-010,ITEM-YO-001) with zero alias collisions.Data Quality Audit & Cleaning (
src/aggregation.py):Excludes 3 corrupted operational records containing negative
units_sold,delivered_qty, andstock_available(logged indata/data_quality_issues.csv).Excludes partial opening month
2022-01(only 11 observed days) so models train on complete monthly baselines (2022-02to2024-12).Audits 3,857 stockout zero-demand events (
stock_available == 0andunits_sold == 0) indata/stockout_audit_summary.csv.Builds 42 continuous monthly time series (
3 branches × 7 unified items × 2 metrics:revenueand integerquantity).
3-Fold Rolling-Origin Backtesting (
src/forecast_modeling.py): Evaluates Naive, SES, Holt (Damped Trend), and Prophet across 3 rolling validation folds (3-month horizon per fold) using WAPE:Holt (Damped): Wins 15 series
Naive: Wins 15 series
Prophet: Wins 12 series
Generates 10-month forecasts (
2025-01–2025-10) with 80% prediction intervals bounded at>= 0and strictly integer unit quantities.
Quickstart
1. Environment Setup
For running the Dashboard, FastAPI service, and tests:
python -m venv venv
# Windows PowerShell: .\venv\Scripts\Activate.ps1
# macOS/Linux: source venv/bin/activate
pip install -r requirements.txtTo re-run offline Kaggle data ingestion & Prophet model training, install pipeline dependencies:
pip install -r requirements-pipeline.txtOptional .env configuration for API Basic Auth (defaults to admin / admin):
API_USERNAME=admin
API_PASSWORD=admin2. Run Data Pipeline & Forecasting
# 1. Fetch public Kaggle FMCG dataset
python -m src.fetch_data
# 2. Run exploratory data audit
python -m src.eda
# 3. Unify product families via Union-Find
python -m src.item_mapping
# 4. Clean anomalies and aggregate continuous monthly series
python -m src.aggregation
# 5. Verify series readiness
python -m src.forecast_readiness
# 6. Run 3-fold backtesting & generate 10-month forecasts
python -m src.forecast_modeling3. Run Automated Tests
python -m pytest tests/ -vValidates 19 unit tests covering /health, HTTP Basic Auth (401), 404 unknown branch/item, 422 invalid metric parameter, 10-month forecast horizon, integer quantity enforcement, alias resolution, MCP envelope metadata, and JSONL audit logging.
4. Start FastAPI REST Service
python -m uvicorn src.api:app --reload --port 8000Interactive Swagger UI:
http://localhost:8000/docsInteractive ReDoc:
http://localhost:8000/redoc
5. Launch Interactive Streamlit Dashboard
streamlit run src/dashboard.py --server.port 8501Open browser at:
http://localhost:8501
REST API Documentation & Curl Examples
Authentication uses HTTP Basic Auth (admin / admin by default).
1. Health Status (Public, no auth)
curl -X GET http://localhost:8000/health{
"status": "healthy",
"version": "2.0.0",
"forecasts_cached": 42,
"branches": ["PL-Central", "PL-North", "PL-South"]
}2. List Available Branches
curl -u admin:admin -X GET http://localhost:8000/branches3. Search Unified Items (SKU, Brand, or Segment Alias)
curl -u admin:admin -X GET "http://localhost:8000/items?search=MiBrand4"4. Get Unified Item Mapping
curl -u admin:admin -X GET http://localhost:8000/items/ITEM-MI-006/mapping{
"item_id": "ITEM-MI-006",
"category": "Milk",
"skus": ["MI-006", "MI-008", "MI-011", "MI-022", "MI-023", "MI-026"],
"brands": ["MiBrand1", "MiBrand3", "MiBrand4"],
"segments": ["Milk-Seg2", "Milk-Seg3"],
"record_count": 39528
}5. Get 10-Month Demand Forecast
# Revenue forecast
curl -u admin:admin -X GET "http://localhost:8000/forecast?branch=PL-Central&item_id=ITEM-YO-001&metric=revenue"
# Unit quantity forecast using raw SKU alias (MI-026 -> ITEM-MI-006)
curl -u admin:admin -X GET "http://localhost:8000/forecast?branch=PL-North&item_id=MI-026&metric=quantity"6. Error Handling
Invalid Credentials (
401):curl -u admin:wrong http://localhost:8000/branchesUnknown Branch (
404):curl -u admin:admin "http://localhost:8000/forecast?branch=UNKNOWN&item_id=ITEM-MI-006&metric=revenue"Invalid Metric (
422):curl -u admin:admin "http://localhost:8000/forecast?branch=PL-Central&item_id=ITEM-MI-006&metric=profit"
LLM Protocol Layer (MCP)
Exposes 5 strictly typed, read-only tools in src/protocol.py:
Tool Name | Parameters | Description |
| None | Lists regional branches ( |
|
| Searches unified items and resolves SKU/Brand/Segment aliases. |
|
| Returns all merged SKUs, brands, and segments for a canonical item. |
|
| Returns precalculated 10-month forecast with 80% bounds. |
|
| Retrieves historical raw daily records from |
Every response returns a standard governance envelope (source, tool, generated_at, data_as_of, model, is_stale, stale_warning, data) and logs calls to data/audit_log.jsonl.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
A read-only verified record of agent-operable GTM tools: search, fetch, compare, track changes.
Bounded tools for rendering, extraction, RAG, enrichment, local discovery and review analysis.
Public web tools for agents: product extraction, claim checks, webpage QA and ranked audits.
Governed retail, FMCG, and CPG operational tools: runs, cases, approvals, audit-ready execution.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables LLM clients to access governed data platform metrics and schema descriptions through exactly three read-only, authenticated, validated, bounded, and audited tools.-
- AlicenseNot gradedqualityBmaintenanceEnables read- or write-scoped access to synthetic enterprise orders, inventory, support tickets, and metrics via schema-validated JSON-RPC tools over stdio and HTTP, with permission allow-lists and audit logging. It also exposes enterprise resources and prompt templates for grounded, cited, multi-step assistant workflows.MIT
- AlicenseNot gradedqualityCmaintenanceEnables an AI assistant to answer inventory and order-status questions from read-only SQLite or CSV data through narrow tools with strict input validation, audit logging, and prompt-injection-safe output.MIT
- AlicenseNot gradedqualityCmaintenanceEnables LLM clients to explore and query a local SQLite database through read-only, typed tools for table listing, schema inspection, ad-hoc SQL, customer lookup, and sales summaries.MIT