Live AI agent + MCP tools for a Selangor snack distributor
Challenge: Malaysian FMCG distributors operate on thin margins (20β25% gross) with long reseller tails β one distributor might service 200β400 outlets across supermarkets, minimarkets, petrol stations, and sundry shops, spread across 9 Selangor districts from Sabak Bernam to Sepang. The data exists (every order line is captured in the invoicing system) but it never turns into insight. The boss asks "which outlets are slipping?" and the spreadsheet takes hours to answer.
Solution: Hoo Tim Analytics Agent is a live AI agent that answers distribution questions in seconds. The user brings their own Gemini API key, the agent selects from a catalog of 5 MCP tools, queries pre-aggregated distribution data, and writes a grounded answer with tables and recommendations in plain Malaysian English. Unlike static demos, every answer is generated live β no hardcoded responses.
Why this matters: Existing producer-distributor transitions (e.g. Apollo's FY26Q1 "distribution network reconfiguration") show that Malaysian snack producers are actively rethinking their partners. A distributor that can demonstrate live SKU performance, outlet-level health, and delivery reliability β not just ship-and-forget β becomes the kind of "robust and agile distributor" producers want to keep.
Notice: Hoo Tim Biscuits is a fictional Malaysian snack distributor created for portfolio purposes. The dataset is synthetic. No affiliation with any real brand.
The agent picks tools based on the question β each tool runs deterministic queries against the pre-aggregated dataset in the browser, then hands the result to Gemini for narrative synthesis.
get_aggregate(dim) β Group-by aggregation over district / channel / category / SKU (revenue, cost, margin, quantity).
get_top_n(dim, n, direction) β Top or bottom N by a metric. Powers "top 10 SKUs" and "slow movers".
get_cross_tab(row_dim, col_dim) β 2D breakdowns (district Γ channel, category Γ channel).
get_delivery_performance(group_by) β On-time / slightly late / very late percentages by district or channel.
get_time_series(period) β Daily trend or ChristmasβNew Year campaign window (15β31 Dec vs 1β14 Dec).
Organised by analytical focus area β each one answerable from the dataset.
Paste a Gemini API key at the top of the demo. It stays in the browser session only β never sent anywhere except directly to Google's Gemini API. Free tier works fine for testing.
The agent uses keyword-based dispatch to pick relevant MCP tools from the catalog of 5. The MCP panel highlights the active tools; a dark terminal line logs the actual tool call with arguments and row counts.
Each tool runs deterministic queries against 129KB of pre-aggregated JSON β real numbers, not a sample. Results are always truthful to the underlying 6,074-row dataset.
Gemini 2.0 Flash receives the tool outputs, the user's question, and strict grounding rules ("do not invent figures"). It writes a markdown answer with a table, a 1-sentence Insight, and a Recommendation bullet.
Two-panel brown/gold layout. Left: persona and business context. Right: API key bar, tool catalog, 15 quick-ask buttons grouped by focus area, and a chat thread showing tool trace + agent answer.
Single static HTML page + data.js, hosted on GitHub Pages. Zero server cost, zero API key management on the site side. A portfolio demo that works indefinitely without maintenance.