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 分