AI Agent + MCP Server for E-Commerce Analytics
Challenge: The base SME Business Advisor loads data directly into memory — tightly coupling the agent to a specific CSV file. Changing the data source means rewriting the agent code.
Solution: This version connects the same AI agent to data through MCP (Model Context Protocol). An MCP server sits between the agent and the data, exposing 7 tools. The data source is now swappable — CSV today, Google Sheets tomorrow — without touching the agent.
A live status panel in the UI shows the MCP server connection state, data source path, total row count, and a list of all 7 available tools — giving full transparency into what the agent can access.
mcp_read_orders, mcp_get_sales_summary, mcp_get_profit_summary, mcp_get_discount_comparison, mcp_get_return_rates, mcp_get_customer_segments, mcp_get_delivery_times — each exposed as a callable MCP resource.
Every response displays which MCP tools were invoked to generate the answer. Users see the full chain of tool calls — building trust in the agent's reasoning process.
The MCP server abstracts the data layer from the agent layer. Switch from a local CSV to Google Sheets or a database — the agent code stays exactly the same.
Data is fetched through the MCP protocol at query time. The agent always works with the current state of the data source — no stale snapshots or manual reloads needed.
The underlying Gemini 2.0 Flash agent is identical to the base version. Same analytical reasoning, same recommendation quality — only the data access layer has changed.
Google ADK manages the agent orchestration while MCP handles the data access layer. The two protocols work together — ADK routes questions to tools, MCP serves the data those tools need.
The data layer is fully decoupled from the agent layer. The MCP server owns all data access logic — reading, filtering, aggregating — while the agent focuses purely on reasoning and recommendations.
The same Gemini model powers reasoning and recommendation generation. It interprets MCP tool outputs and synthesises them into clear business advice.
The MCP server runs in-process with the FastAPI application — no external service to manage. Simple deployment while maintaining clean architectural separation.