fakestore-mcp-server

Bighero0122/fakestore-mcp-server

3.2

If you are the rightful owner of fakestore-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Fake Store MCP Project is a comprehensive implementation of a Model Context Protocol server and React client for e-commerce functionality, leveraging the Fake Store API.

Tools
  1. login_user

    User authentication

  2. get_products

    Fetch products

  3. get_categories

    List categories

  4. add_to_cart

    Add item to cart

  5. remove_from_cart

    Remove from cart

  6. display_cart

    Show cart details

  7. clear_cart

    Empty cart

  8. get_users

    List all users (bonus)

Fake Store MCP Project

A complete MCP (Model Context Protocol) server and React client implementation for e-commerce functionality using the Fake Store API.

๐ŸŽฏ Overview

This project implements all required MCP server functionality with a modern TypeScript stack:

Demo Loom Link

https://www.loom.com/share/9c123e1acd1148de890be2aadf65c94b?sid=29cd007d-0311-4d1f-9411-b458015fbdb3

โœ… Core Requirements

  • User Authentication - Login with username/password
  • Cart Management - Add/remove items with quantity control
  • Product Browsing - View and filter products
  • Itemized Cart Display - Detailed breakdown with subtotal, tax, and total

โœ… Bonus Features

  • Category Filtering - Browse products by category (electronics, jewelry, men's/women's clothing)
  • User Profile Display - Show authenticated user details in header
  • Cart Persistence - Maintain cart state across sessions
  • Tax Calculation - Automatic 8% tax on cart total
  • Clear Cart - Bulk cart operations
  • Real-time Updates - Live cart count and total updates
  • Health Monitoring - Server health check endpoint

๐Ÿ—๏ธ Architecture

React Client (Port 3000) โ†โ†’ MCP Server (Port 8080) โ†โ†’ Fake Store API

Frontend: React 18 + TypeScript + Tailwind CSS
Backend: Node.js + Express + TypeScript
API: Fake Store API (https://fakestoreapi.com)

๐Ÿš€ Quick Start

1. Server Setup

cd mcp-server
npm install
cp .env.example .env
npm run build
npm start

Server runs on http://localhost:8080

2. Client Setup

cd client
npm install
npm start

Client runs on http://localhost:3000

3. Test Login

Use these credentials:

  • Username: johnd
  • Password: m38rmF$

๐Ÿ”ง API Documentation

MCP Tools Available

ToolPurposeParameters
login_userUser authenticationusername, password
get_productsFetch productscategory?, limit?
get_categoriesList categoriesnone
add_to_cartAdd item to cartuser_id, product_id, quantity?
remove_from_cartRemove from cartuser_id, product_id, quantity?
display_cartShow cart detailsuser_id
clear_cartEmpty cartuser_id
get_usersList all users (bonus)none

HTTP Endpoints

GET  /health                    # Server health check
GET  /mcp/tools                 # List available tools
POST /mcp/tools/{toolName}      # Execute MCP tool

๐Ÿงช Testing

Manual Testing

  1. Open http://localhost:3000
  2. Login with test credentials
  3. Browse products and add to cart
  4. Verify cart calculations and persistence
  5. Test logout and re-login

API Testing

# Health check
curl http://localhost:8080/health

# Login test
curl -X POST http://localhost:8080/mcp/tools/login_user \
  -H "Content-Type: application/json" \
  -d '{"username": "johnd", "password": "m38rmF$"}'

# Get products
curl -X POST http://localhost:8080/mcp/tools/get_products \
  -H "Content-Type: application/json" \
  -d '{"category": "electronics"}'

โš™๏ธ Configuration

Server (.env)

PORT=8080
FAKESTORE_API_URL=https://fakestoreapi.com
CORS_ORIGIN=http://localhost:3000
DEBUG=true

Available Test Users

UsernamePasswordName
johndm38rmF$John Doe
mor_231483r5^_Morrison
kevinryankev02937@Kevin Ryan
doneroewedonDon Ero

๐Ÿšจ Troubleshooting

Port conflicts: Change PORT in server .env or REACT_APP_MCP_BRIDGE_URL in client
CORS errors: Ensure CORS_ORIGIN matches client URL
Build errors: Run npm run build in server directory
Login issues: Verify server is running and accessible

๐Ÿ“Š Features Demonstrated

Core Functionality

  • โœ… User authentication with Fake Store API
  • โœ… Product browsing with real API data
  • โœ… Shopping cart CRUD operations
  • โœ… Itemized cart with tax calculation

Technical Implementation

  • โœ… Full TypeScript implementation
  • โœ… Error handling and validation
  • โœ… RESTful API design
  • โœ… Responsive React UI
  • โœ… State management with hooks
  • โœ… Browser storage persistence

Bonus Implementations

  • โœ… Advanced filtering and categorization
  • โœ… User session management
  • โœ… Comprehensive API documentation
  • โœ… Health monitoring endpoints