Sponsored by Deepsite.site

MCP Demo App

Created By
sameerfa8 months ago
A simple Node.js/Express API server using TypeScript for managing products and orders, with Model Context Protocol (MCP) integration.
Content

MCP Demo App

A simple Node.js/Express API server using TypeScript for managing products and orders, with Model Context Protocol (MCP) integration.

Features

  • RESTful API for products and orders
  • Bearer token authentication
  • Data stored in JSON files
  • MCP server exposing tools for product/order queries
  • TypeScript for type safety

Project Structure

├── src/
│   ├── server.ts         # Main Express API server
│   ├── mcpServer.ts      # MCP server exposing tools
│   └── data/
│       ├── products.json # Product data
│       └── orders.json   # Order data
├── dist/                 # Compiled JS output
├── package.json          # Project metadata and scripts
├── tsconfig.json         # TypeScript config
└── .gitignore            # Ignored files

Getting Started

Prerequisites

  • Node.js (v16+ recommended)
  • npm

Install Dependencies

npm install

Build the Project

npm run build

Run the API Server

npm run dev   # For development (with nodemon)
npm start     # For production (after build)

Run the MCP Server

npm run mcp

Authentication

All API endpoints (except /health) require a Bearer token. Example valid tokens:

  • valid_token_123
  • client_abc_token

Include the token in the Authorization header:

Authorization: Bearer valid_token_123

API Endpoints

Health Check

  • GET /health — Returns { status: 'ok' }

Products

  • GET /products — List all products
  • GET /products/:productId — Get product by ID

Orders

  • GET /orders — List all orders (optionally filter by customerId)
  • GET /orders/:orderId — Get order by ID

MCP Server Tools

The MCP server (src/mcpServer.ts) exposes the following tools:

  • getProductInfo(productId) — Get product details and related orders
  • listProducts() — List all products
  • getProductOrders(productId) — Get all orders for a product
  • searchProducts(query) — Search products by name or category

Example Data

Products (src/data/products.json)

[
  { "id": "p1", "name": "Cloud Widget", "category": "Widgets", "price": 99.99 },
  { "id": "p2", "name": "Data Analyzer", "category": "Analytics", "price": 199.99 },
  { "id": "p3", "name": "API Gateway", "category": "Infrastructure", "price": 149.99 }
]

Orders (src/data/orders.json)

[
  { "id": "o101", "productId": "p1", "customerId": "cust_abc", "quantity": 2, "orderDate": "2023-10-26T10:00:00Z", "status": "shipped" },
  { "id": "o102", "productId": "p2", "customerId": "cust_xyz", "quantity": 1, "orderDate": "2023-10-27T15:30:00Z", "status": "processing" },
  { "id": "o103", "productId": "p3", "customerId": "cust_abc", "quantity": 3, "orderDate": "2023-10-28T09:15:00Z", "status": "delivered" }
]

Development Notes

  • TypeScript config: see tsconfig.json
  • Ignored files: dist/, node_modules/
  • Data is persisted in JSON files in src/data/

License

MIT

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Tavily Mcp
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
ChatWiseThe second fastest AI chatbot™
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Serper MCP ServerA Serper MCP Server
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Amap Maps高德地图官方 MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
DeepChatYour AI Partner on Desktop
CursorThe AI Code Editor
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.