ecommerce-mcp-chat-server

ecommerce-mcp-chat-server

Exposes database queries (Users, Products, Orders) from a NestJS backend to AI agents via MCP, enabling real-time database interactions in chat sessions.

Category
Visit Server

README

Ecommerce MCP Chat Server Demo with Local LLM

A complete demonstration of connecting a local Large Language Model (LLM) to a NestJS database backend using the Model Context Protocol (MCP). This project allows an AI agent to autonomously execute tools to query a MySQL database in real-time during a chat session.

🚀 Features

  • NestJS Backend: A modular architecture managing Users, Products, and Orders.
  • Database Integration: Sequelize ORM connected to a local MySQL database.
  • MCP Server: Exposes database queries natively to AI agents using @nestjs-mcp/server.
  • Local AI Agent: A Node.js CLI chat interface powered by the Vercel AI SDK and Ollama (llama3.1:8b).
  • Agentic Tool Calling: The LLM autonomously decides when to query the database to answer user questions accurately.

📋 Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v24+)
  • MySQL (Running locally on port 3306)
  • Ollama (Running locally with the llama3.1:8b model pulled)

Note: To pull the required model, run ollama pull llama3.1:8b in your terminal.

🛠️ Installation & Setup

  1. Clone the repository and install dependencies:

    npm install
    
  2. Database Setup: Ensure your local MySQL server is running. Create an empty database named mcp_demo.

    CREATE DATABASE my_db;
    

(Update the database credentials in src/app.module.ts and src/seed.ts if your MySQL username is not root or if you have a password).

  1. Seed the Database: Generate dummy data (50 users, 50 products, and 50 orders) to test the AI's querying capabilities.

    npx ts-node src/seed.ts
    

💻 Running the Application

This project requires two terminal windows to run simultaneously—one for the NestJS MCP Server, and one for the AI Chat Client.

Terminal 1: Start the NestJS MCP Server Start the backend server so it can expose the database tools via the MCP Streamable HTTP transport.

npm run start

(The server runs on http://localhost:3000 with MCP available at /mcp)

Terminal 2: Start the AI Chat Client Start the interactive command-line interface. The client will connect to the NestJS server, discover the tools, and allow you to chat with the local LLM.

npx ts-node src/chat.ts

💬 Usage Examples

Once the chat client is running, try asking the agent questions that require database knowledge:

"What products do we have available?"

"Can you give me the details for user ID 5?"

"How many orders are in the system?"

"Check the price of product ID 12 and tell me if it's more than $500."

The LLM will pause, call the appropriate NestJS tool, read the database results, and formulate a natural language response.

📂 Project Structure

src/user/, src/product/, src/order/ - NestJS modules containing Controllers, Services, Models, and MCP Resolvers.

src/chat.ts - The Vercel AI SDK client implementing the conversational loop.

src/seed.ts - Database seeding script.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured