merchant-catalog-mcp
A demonstration MCP server that exposes a mock merchant catalog with tools for product search, availability checking, and order placement, along with a catalog resource and gift-finder prompt.
README
merchant-catalog-mcp
A small, production-quality MCP (Model Context Protocol) server in TypeScript. It exposes a mock merchant catalog to any MCP-compatible client (Claude Desktop, the MCP Inspector, IDE agents, etc.) through three tools — search, availability, and ordering. The data is intentionally in-memory: this project is a clear, readable demonstration of the protocol, not a data layer.
What it does
The server exposes three tools over the MCP stdio transport:
| Tool | Input | What it returns |
|---|---|---|
search_products |
query (string, required), category (enum, optional) |
Products whose name/description match the query, optionally filtered by category. |
check_availability |
productId (string, required) |
Stock status (in_stock / low_stock / out_of_stock) and on-hand quantity. |
place_order |
productId (string), quantity (positive integer) |
Validates against stock, decrements it, and returns a mock order confirmation. Errors (bad id, not enough stock) come back as tool results flagged isError. |
Every tool also declares an outputSchema and returns structuredContent,
so clients receive typed objects, not just text.
It also exposes the other two MCP primitives:
| Primitive | Name | What it is |
|---|---|---|
| Resource | catalog://products |
The full catalog as a read-only JSON resource the host can pull into context. |
| Prompt | gift_finder |
A user-invoked template (occasion, budget) that composes a catalog gift-recommendation request. |
How the MCP pieces fit (the 60-second tour)
- Host / client / server. A host app (Claude Desktop, the Inspector) runs an MCP client that connects to one or more servers. This repo is one server.
- A server exposes three kinds of things. Tools (model-callable actions),
resources (read-only data the app pulls by URI), and prompts
(user-invoked templates). This server demonstrates all three: three tools,
a
catalog://productsresource, and agift_finderprompt. - Transport = the pipe. Messages are JSON-RPC 2.0. With the stdio transport, the client launches this server as a subprocess and exchanges messages over stdin/stdout. (Because stdout is the protocol channel, all diagnostics in this server go to stderr.)
- Input schema = the contract. Each tool declares its arguments with a
zodschema. The SDK converts it to JSON Schema, advertises it during discovery, and validates every incoming call against it before the handler runs. The schema is what tells the model exactly how it's allowed to call the tool. - Output schema = the response contract. Each tool also declares an
outputSchemaand returnsstructuredContent— a typed object the client gets directly, validated by the SDK — instead of only stringified JSON in text. - Lifecycle.
initialize(capability handshake) →tools/list(discovery) →tools/call(invocation) → structured result. State (stock levels) persists for the life of the process, so an order visibly reduces availability.
Project structure
src/
catalog.ts Domain layer: Product type, in-memory data, pure lookup/search/mutate helpers.
No MCP imports — this is the "swap-in-a-database-here" seam.
index.ts Protocol layer: creates the McpServer, registers the three tools
(input + output schema + handler), the catalog resource, and the
gift_finder prompt, then connects the stdio transport.
The split is deliberate: business logic in catalog.ts, protocol wiring in
index.ts. The tools are thin adapters over logic that could just as easily sit
behind a real API or database.
Requirements
- Node.js 18+ (developed on Node 24 LTS)
Install
npm install
Run
# Dev: run the TypeScript directly, no build step
npm run dev
# Production: compile to dist/ then run the compiled server
npm run build
npm start
On startup the server prints merchant-catalog-mcp running on stdio to stderr
and then waits for JSON-RPC messages on stdin. (Running it in a bare terminal and
seeing it "hang" is correct — it's waiting for a client to speak to it.)
Verify it works
Option A — MCP Inspector, UI mode
npm run inspect
This launches the official MCP Inspector and opens a browser panel. Steps:
- It auto-connects to this server over stdio.
- Open the Tools tab and click List Tools — you'll see all three, each with a form generated from its input schema.
- Select
search_products, enter aquery(e.g.speaker), and Run Tool. - Try
place_orderwithproductId=sku-003,quantity=2, then runcheck_availabilityon the same id to watch stock drop.
Option B — MCP Inspector, CLI mode (scriptable)
# Discover tools
npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/list
# Call a tool
npx @modelcontextprotocol/inspector --cli node dist/index.js \
--method tools/call --tool-name search_products --tool-arg query=speaker
# Place an order
npx @modelcontextprotocol/inspector --cli node dist/index.js \
--method tools/call --tool-name place_order \
--tool-arg productId=sku-002 --tool-arg quantity=1
Option C — raw JSON-RPC (what a client does under the hood)
{
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"raw","version":"1.0.0"}}}'
printf '%s\n' '{"jsonrpc":"2.0","method":"notifications/initialized"}'
printf '%s\n' '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
printf '%s\n' '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"search_products","arguments":{"query":"headphones"}}}'
sleep 0.5
} | node dist/index.js
Use it from Claude Desktop
Build first (npm run build), then add this server to your Claude Desktop MCP
config. The file lives at:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"merchant-catalog": {
"command": "/absolute/path/to/node",
"args": ["/absolute/path/to/merchant-catalog-mcp/dist/index.js"]
}
}
}
Then fully quit and reopen Claude Desktop (it loads MCP servers only at startup). The three tools will appear in the tools menu.
Gotcha — use absolute paths for both
commandandargs. Claude Desktop is a GUI app, so it launches this server with the system environment, not your shell's — it does not read~/.zshrc/~/.bashrcand therefore may not findnodeon itsPATH. Pointingcommandat the absolute path of your Node binary (find it withwhich node) avoids a "spawn node ENOENT" failure.
Catalog
Eight products across four categories (audio, wearables, home,
accessories), including deliberately low-stock (sku-003, sku-008) and
out-of-stock (sku-004) items so you can exercise the availability and
validation paths. See src/catalog.ts.
Possible next steps
- Swap
catalog.tsfor a real database — the protocol layer wouldn't change. - Add an HTTP/SSE transport for remote hosting (only the transport lines in
index.tschange). - Add unit tests over
catalog.tsand a CI workflow that runstsc+ tests.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。