Sample Shop MCP server

io.github.apitoagents由 GitHub 账号 apitoagents 发布v1.0.1更新于 Oct 24, 2026

Sample shop MCP server: paginated search, idempotent orders, guarded cancellation. Four languages.

已验证Streamable HTTP可网页运行开发者工具商业与电商

概览

AI 生成的概览

一个演示商店 MCP 服务器,提供商品搜索、商品详情、下单和需确认的订单取消,可通过 npx 本地运行或连接托管远程演示。

可以做什么
按关键词和可选分类搜索商店目录,支持分页并通过 nextCursor 获取后续结果,也可按 id 获取单个商品的完整详情。使用幂等键为单个商品下单,重试时不会重复创建订单。取消尚未发货的订单,先以预览方式获取详情,用户明确同意后再执行取消。README 将其定位为分页读取、幂等写入和受保护操作的参考示例。
适用场景
适合试用或演示 MCP 工具模式,例如分页、幂等写入和需确认的破坏性操作,也适合用一个小型示例商店测试助手。不适合真实交易,因为托管副本使用会定期重置的内存数据。
运行要求
本地 stdio 包需要 Node.js 和 npx,启动时会在 127.0.0.1:4010 运行内置商店 API。HTTP 模式使用环境变量 HOST、PORT、UPSTREAM_URL、UPSTREAM_API_KEY(默认 demo-key)和 ALLOWED_HOSTS。也可直接连接托管远程端点;未声明身份验证。
安装前请注意
create_order 会真实下单,cancel_order 会永久取消未发货订单,因此应先与用户确认商品和数量,并在取消前使用预览步骤。HTTP 模式会读取 UPSTREAM_API_KEY,其默认值为演示值。公开演示使用会定期重置的内存数据,不应视为持久存储。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Sample Shop MCP server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/io.github.apitoagents%2Fsample-shop-mcp/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

{
  "mcpServers": {
    "sample-shop": {
      "type": "http",
      "url": "https://demo.apitoagents.com/mcp"
    }
  }
}

README

@apitoagents/sample-shop-mcp

An MCP server for a small sample shop, written with the official TypeScript SDK. It shows the three kinds of tool every real integration needs: paginated reads (search_products, get_product), an idempotent write (create_order) and a guarded action that refuses to run without explicit confirmation (cancel_order).

The same server exists in Python, C# and PHP, all passing one conformance scenario: github.com/apitoagents/mcp-examples. Walkthrough: apitoagents.com/docs/build-mcp-server-typescript.

Try it in one command (stdio)

bash
npx @apitoagents/sample-shop-mcp

That starts the bundled Sample Shop API on 127.0.0.1:4010 and serves the MCP tools over stdio, which is what Claude Desktop, Claude Code and the MCP Inspector expect from a local server.

Claude Code:

bash
claude mcp add sample-shop -- npx -y @apitoagents/sample-shop-mcp

Claude Desktop (claude_desktop_config.json):

json
{ "mcpServers": { "sample-shop": { "command": "npx", "args": ["-y", "@apitoagents/sample-shop-mcp"] } } }

Run it over Streamable HTTP

bash
UPSTREAM_URL=http://127.0.0.1:4010 npx -p @apitoagents/sample-shop-mcp node node_modules/@apitoagents/sample-shop-mcp/dist/server.js

Or from a clone: npm ci && npm run build && npm start (listens on 127.0.0.1:3001/mcp). Environment: HOST, PORT, UPSTREAM_URL, UPSTREAM_API_KEY (default demo-key), ALLOWED_HOSTS (comma-separated public hostnames accepted in the Host header).

Public demo

A hosted copy runs at https://demo.apitoagents.com/mcp (in-memory data, resets regularly). Add it as a remote MCP server in Claude or ChatGPT and ask for a desk lamp.

MIT. Built by API to Agents, which designs and hosts servers like this for companies' own APIs.

来源:typescript/README.md,提交 1014f2c

工具

4

search_products

Search products

Search the shop catalogue by phrase and optional category. Returns one page of up to `limit` products and a `nextCursor`; when nextCursor is not null, more results exist and you must say so rather than claiming the list is complete. Use get_product for full details of one item. This tool does not place orders.

输入参数limitquerycursorcategory

get_product

Get product details

Return the full details of one product by its id (for example p-1001). Use search_products first if you only know a name.

输入参数productId必填

create_order

Create an order

Place an order for one product. Generate one random idempotencyKey per user request and reuse the same key if you retry after an error or timeout; the shop returns the original order instead of creating a duplicate. Confirm product and quantity with the user before calling. Returns the order with its id, status and total.

输入参数quantity必填productId必填idempotencyKey必填

cancel_order

Cancel an order

Cancel an order that has not shipped. This cannot be undone. Call it first with confirm=false to get the order details, show them to the user, and only after the user explicitly agrees call again with confirm=true.

输入参数confirmorderId必填

版本历史

1
  1. v1.0.1最新Oct 8, 2026

评分

已满足适用检查项的 100%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分