Skip to main content
Glama

MCP E-commerce Server

A comprehensive Model Context Protocol (MCP) server for e-commerce product management with CRUD operations, AI-powered descriptions, and database integration.

Agents and MCP clients (Cursor, Claude Desktop, MCP Inspector, Apps SDK) can create products, look them up, delete them, browse the catalog, and generate copy through tools, resources, and prompts. Product data lives in MySQL.

Features

  • 🛍️ Complete CRUD Operations — Create, read, update, and delete products (MCP tools plus the service/demo layer)

  • 🤖 AI-Powered Descriptions — Automatic product description generation using MCP sampling when you skip a description

  • 📊 Database Integration — MySQL with a dedicated products schema, unique SKUs, and timestamps

  • 🔍 Smart Search — Search products by name with limit/offset pagination

  • 📦 Low Stock Monitoring — Resource for products with quantity below 5

  • 🌐 Dual Transport Support — Stdio for MCP clients; HTTP/SSE types exported from the library for further wiring

  • 🔧 TypeScript — Fully typed with Zod validation on inputs

  • 📋 MCP Resources — Full catalog (products://catalog) and low-stock (products://low-stock)

  • 🎯 MCP Prompts — Pre-built prompt template for marketing-style product descriptions

Related MCP server: MCP E-commerce Server

Quick start

# 1) Install deps
npm i

# 2) Prepare env
cp .env.example .env

# 3) Create schema (optional, run in your MySQL)
# See sql/schema.sql

# 4) Run demo (non-MCP) usage
npm run dev:demo

# 5) Run MCP server (stdio transport)
npm run dev:mcp

Put your real MySQL password in .env (not in .env.example). The MCP server prints nothing special; it waits on stdio for a client like Claude Desktop, MCP Inspector, Apps SDK, or Cursor to connect.

Environment variables (see .env.example):

Variable

Meaning

Example

MYSQL_HOST

Server host

localhost

MYSQL_PORT

Port

3306

MYSQL_USER

User

root

MYSQL_PASSWORD

Password

your password

MYSQL_DATABASE

Database name

e_commerce_mcp

This repo already includes .cursor/mcp.json, which starts npx tsx src/mcp/server.ts with that .env file.

How it is put together

Layer

Location

Role

MCP server

src/mcp/server.ts

Tools, resources, and prompts

Service

src/services/ProductService.ts

Zod validation and business calls

Repository

src/repo/ProductRepository.ts

SQL against products

Model

src/models/Product.ts

Product type

Database pool

src/db.ts

mysql2 pool from environment variables

Demo CLI

src/index.ts

Create → read → update → list → delete without MCP

src/index.ts also re-exports ProductService and Product so other Node code can use the same library.

Product data model

Each row in products (sql/schema.sql) has:

Field

Type

Notes

id

integer

Auto-increment primary key

sku

string (max 64)

Unique stock-keeping unit

name

string (max 255)

Required

description

text

Optional

price

decimal(10,2)

Non-negative; default 0.00

quantity

integer

Non-negative; default 0

created_at

timestamp

Set on insert

updated_at

timestamp

Updated on every change

There is an index on name (idx_products_name) to support search.

MCP tools

Registered on server ecommerce-custom-mcp (v1.0.0). Inputs are validated with Zod.

add_product — Create a product. Required: sku, name, price (≥ 0), quantity (integer ≥ 0). Optional: description. Returns the inserted row, including id and timestamps.

add_product_smart — Same fields. If description is omitted, the server asks the connected model (MCP sampling, up to 100 tokens) for a short 2–3 sentence description from the name and price. If you pass a description, sampling is skipped.

get_product_by_id — Fetch one product by positive integer id. Missing ids return product {id} not found.

delete_product — Delete by id. Returns { deleted: true } or { deleted: false }.

List, update, and name search are available on ProductService (demo, catalog resource, repository). They are not separate MCP tools.

MCP resources and prompt

Name

URI

Behavior

products-catalog

products://catalog

Up to 200 products, newest id first

low-stock-products

products://low-stock

Same list, then quantity below 5

generate-product-description-template takes productName (required) plus optional features and targetAudience. It asks the model for a 5–8 word headline, 2–3 paragraphs, 3–5 benefit bullets, and a call to action.

Service and database

ProductService and ProductRepository support create, get by id, get by SKU, partial update, delete, list (ORDER BY id DESC with limit/offset), and search by name (LIKE with the same pagination). The pool in src/db.ts uses a limit of 10 connections, a 60s idle timeout, and keep-alive.

npm run dev:demo inserts DEMO-001, reads it, updates price/quantity, lists up to 10 rows, deletes the demo product, and closes the pool — useful to verify MySQL before attaching an MCP client.

Scripts and layout

Script

What it does

npm i

Install dependencies

npm run dev:demo

CRUD smoke test against MySQL

npm run dev:mcp

MCP server on stdio (tsx)

npm run check

Typecheck without emit

npm run build

Compile to dist/

After a build, the binary name is ecommerce-products-mcp (dist/mcp/server.js).

src/
  mcp/server.ts
  services/ProductService.ts
  repo/ProductRepository.ts
  models/Product.ts
  db.ts
  index.ts
sql/schema.sql
.cursor/mcp.json
.env.example

Author

Santhan Sai

Available Tools

4 tools
add_productAdd ProductB

Create a new product with sku, name, (optional) description, price, and quantity.

ParametersJSON Schema
NameRequiredDescriptionDefault
skuYes
nameYes
priceYes
quantityYes
descriptionNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
idNo
skuYes
nameYes
priceYes
quantityYes
created_atNo
updated_atNo
descriptionNo

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the mutation ('Create') but does not disclose side effects such as duplicate SKU handling, idempotency, permission requirements, or whether existing data is affected. The agent knows it is a write operation but nothing about its behavioral edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that front-loads the action and efficiently lists all fields in a compact order. No redundant words, no filler. Every part contributes to conveying the core operation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 5-parameter create tool with no annotations and no sibling differentiation, the description is minimally viable but incomplete. It correctly identifies the operation and fields, and an output schema exists to document return values. However, it lacks critical operational context such as duplicate handling, required permissions, or when to prefer the sibling add_product_smart.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists all five parameters and marks description as optional, which clarifies the confusing optionality expressed in the schema's convoluted anyOf. However, it adds no deeper semantic meaning beyond the parameter names, and the schema already defines types and constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific verb ('Create') and resource ('a new product'), and enumerates the key fields (sku, name, optional description, price, quantity). It is unambiguous about the operation, but it does not differentiate from the sibling tool add_product_smart, both of which appear to create products.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus add_product_smart or how it differs from get_product_by_id or delete_product. There is no mention of conditions, alternatives, or exclusions, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

add_product_smartAdd Product (Smart AI Enhanced)A

Create a new product with smart ai generated description if missing

ParametersJSON Schema
NameRequiredDescriptionDefault
skuYes
nameYes
priceYes
quantityYes
descriptionNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
idNo
skuYes
nameYes
priceYes
quantityYes
created_atNo
updated_atNo
descriptionNo

TDQS

A3.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of explaining behavior. It discloses the key non-obvious trait: a missing description will be AI-generated. It does not discuss failure modes or side effects, but the core create behavior is transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence that front-loads the action and then adds the key qualifier. There is no filler or redundant content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple and an output schema exists, but the description does not differentiate add_product_smart from add_product or clarify behavior when a description is actually supplied. These are meaningful gaps for a tool with no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning for the description parameter by stating it is optional and auto-generated when missing, but the other parameters (sku, name, price, quantity) rely on their self-explanatory names without additional context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new product') and the distinguishing behavior ('smart ai generated description if missing'). It does not explicitly contrast with the sibling add_product tool, so it stops short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'if missing' implies that this tool is useful when a description is not provided, which is a light usage cue. However, it never mentions alternatives like add_product or explains when the plain version should be preferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

delete_productDelete ProductA

Delete a product by id. Returns { deleted: boolean }.

ParametersJSON Schema
NameRequiredDescriptionDefault
idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
deletedYes

TDQS

A3.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full responsibility for behavioral disclosure. It states the delete action and the return value, but it does not mention irreversibility, idempotency, behavior for non-existent ids, or permission requirements, which is a significant gap for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two short sentences with no filler. The action is front-loaded and the return type is given directly, making it concise and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

This is a simple single-parameter destructive call with an output schema, but the description omits behavior for non-existent ids (e.g., false vs error), permanence, and side effects. For an agent to confidently invoke it on real data, this is only partially complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. Saying 'by id' clarifies that the sole parameter 'id' refers to the product identifier, adding meaning beyond the bare schema. This fully covers the parameter's role, though it doesn't discuss id sourcing.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Delete') and a resource ('product by id'), making the operation unambiguous. It clearly distinguishes itself from siblings like add_product and get_product_by_id, and the return value is also explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for deleting a product, but provides no explicit guidance about when to choose this tool over alternatives or any exclusions. With siblings like get_product_by_id, an agent must infer that delete is intended for removal, which is straightforward but not directly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_product_by_idGet Product by IDA

Fetch a single product by numeric ID

ParametersJSON Schema
NameRequiredDescriptionDefault
idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
idNo
skuYes
nameYes
priceYes
quantityYes
created_atNo
updated_atNo
descriptionNo

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full behavioral disclosure burden. 'Fetch' clearly conveys a read-only operation, which is helpful, but it does not mention behavior for missing IDs, error responses, or potential side effects. This is adequate but not deeply transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no filler. 'Fetch a single product by numeric ID' efficiently states the action, target, and key constraint, earning every word.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given a single parameter and an existing output schema, the description plus schema provides the essential information for a correct call. Minor gaps like error behavior and explicit usage routing remain, but they do not block an agent from invoking this tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema documentation coverage is 0%, so the description must compensate for the parameter 'id'. It only adds 'numeric ID', which essentially restates the schema's integer type. It does not explain what the ID represents or provide any meaning beyond the property name and schema constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Fetch') with a clear resource ('product') and a clear qualifier ('single', 'by numeric ID'), which makes it immediately distinct from sibling tools like add_product and delete_product. An agent can tell this is a read-by-ID operation without needing to inspect schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through the contrast between 'Fetch' and the sibling add/delete tools, but it never explicitly states when this tool should be chosen or when another tool would be more appropriate. The guidance is present only by inference, not direct routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.4/5.0
Disambiguation2/5

add_product and add_product_smart overlap significantly since both create a product, differing only by optional AI description generation. An agent could easily select the wrong one. The other tools are distinct enough.

Naming Consistency4/5

Names mostly follow a clear verb_noun snake_case pattern: add_product, get_product_by_id, delete_product. add_product_smart is a minor deviation but remains readable and predictable.

Tool Count4/5

Four tools is a reasonable size for a focused product management server. However, add_product_smart feels like a variant rather than a distinct capability, so the set is slightly less tight than it could be.

Completeness3/5

The server covers create, read, and delete for products, but misses obvious update and list/search operations. Agents can do basic workflows but will hit dead ends when trying to modify products or view all products.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/santhansai11/MCPmerce'

If you have feedback or need assistance with the MCP directory API, please join our Discord server