Medusa

io.github.trhonpavelv0.2.2更新於 Oct 1, 2026

Medusa v2 store: orders, customers, products, inventory, sales reports and safe write actions.

概覽

AI 產生的概覽

讓助理透過 Medusa v2 管理 API 存取商店的訂單、客戶、商品、庫存與銷售報表,並執行範圍有限的寫入操作。

功能
此伺服器把 Medusa v2 管理 API 包裝成 MCP 工具。讀取類工具涵蓋商店資訊(區域、貨幣、銷售通路、庫存地點)、可篩選的訂單清單、訂單明細、客戶及其訂單紀錄、商品與款式,以及可設定低庫存門檻的庫存數量。sales_report 工具可計算營收、客單價、件數、不重複客戶數、日/週/月序列與熱銷商品。寫入類工具可建立出貨與物流單、完成或取消訂單、更新或刪除商品、設定款式價格,以及設定庫存數量。
適用情境
當助理需要回答 Medusa v2 商店的相關問題或對其採取動作時適用:查詢訂單、瀏覽客戶與商品、檢查庫存、產生銷售報表,以及日常的出貨或商品目錄更新。適合想用對話方式存取後台資料、而不想自行開發整合的商店營運人員。
執行需求
可透過 npm 套件 medusa-mcp 以 stdio 在本機執行(需要 Node.js),也可作為搭配 OAuth 2.1 的遠端 HTTP 連接器執行。需要 MEDUSA_BACKEND_URL,以及在 Medusa 後台「設定 → 開發者 → 密鑰 API 金鑰」建立的 Medusa 密鑰 API 金鑰,放入 MEDUSA_API_KEY。選用設定包括 MEDUSA_READ_ONLY、REPORT_TIMEZONE;HTTP 模式另需 PUBLIC_URL、OWNER_PASSWORD 與 MCP_STATIC_TOKEN。需要能連線至 Medusa 後端的網路。
安裝前請注意
MEDUSA_API_KEY 是密鑰,權限等同於建立它的管理員使用者,建議改用可個別撤銷的專用使用者。寫入類工具會變更商店資料:create_fulfillment、create_shipment、complete_order、cancel_order、update_product、delete_product、set_variant_price 與 set_stock_level;其中 cancel_order 與 delete_product 標示為破壞性操作,delete_product 需要 confirm_title。將 MEDUSA_READ_ONLY 設為 true 時只會註冊讀取與報表工具。HTTP 模式下端點必須能透過 HTTPS 公開存取,並由 OWNER_PASSWORD 與 OAuth 權杖保護。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Medusa,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

medusa-mcp

🇨🇿 Česky

An MCP server for the Medusa v2 Admin API. It gives Claude (or any MCP client) access to orders, customers, products and inventory, computes sales reports, and performs a small set of carefully scoped write actions.

It runs in two modes:

  • stdio – locally for Claude Desktop, Claude Code and other MCP clients
  • Streamable HTTP + OAuth 2.1 – as a remote connector for Claude (web, desktop, mobile) and ChatGPT

It is listed in the MCP Registry as io.github.trhonpavel/medusa-mcp, and also ships as a Claude Code / Cowork plugin with skills and as a one-click Claude Desktop extension (.mcpb).

Tools

ToolWhat it doesKind
get_store_inforegions and currencies, sales channels, stock locationsread
list_ordersorders – full-text, date range, customer, order/payment/fulfillment statusread
get_orderfull order detail by ID or order number (1042, #1042)read
list_customers / get_customercustomers, order history, total spentread
list_products / get_productproducts, variants, prices, linked inventory itemsread
list_inventorystock per location, low_stock_threshold to find what's running outread
sales_reportrevenue, AOV, units, unique customers, day/week/month series, top productsreport
create_fulfillmentfulfill an order (defaults: all remaining items, the only stock location)write
create_shipmentmark as shipped with a tracking numberwrite
complete_ordermark an order as completedwrite
cancel_ordercancel an order (destructiveHint)write
update_producttitle, description, status, handle, metadatawrite
delete_productdelete a product and its variants, plus their unreserved inventory items; requires confirm_title (destructiveHint)write
set_variant_priceset a variant's base price in one currency – all other prices, including ones with price rules, are preservedwrite
set_stock_levelrestock by SKU, absolute or relative (adjust_by: +10)write

Amounts are in major currency units (Medusa v2 does not store minor units). Plain dates in filters (2026-09-01) are interpreted in REPORT_TIMEZONE (default UTC). With MEDUSA_READ_ONLY=true the write tools are not registered at all.

1. Create a Medusa API key

In the Medusa Admin go to Settings → Developer → Secret API Keys → Create. The key (sk_…) acts with the permissions of the user who created it, so consider a dedicated admin user that you can revoke independently.

2. Local use (stdio)

Claude Code / Cowork plugin

bash
claude plugin marketplace add trhonpavel/medusa-mcpclaude plugin install medusa@medusa-mcp

Claude Code asks for the backend URL and the API key when you enable the plugin (the key goes to the system keychain). Write tools stay off until you turn off Read-only in /config. The plugin adds two skills:

  • store-briefing – yesterday's and month-to-date sales, paid orders waiting to ship, low stock
  • fulfill-orders – fulfill paid orders and add tracking numbers, after you confirm the list

Claude Desktop extension

Download medusa-mcp-<version>.mcpb from the latest release and open it, or drag it to Settings → Extensions. Claude Desktop asks for the same settings and runs the server with its bundled Node.js. Build it yourself with npm run build:mcpb.

Manual configuration

Claude Desktop – claude_desktop_config.json:

json
{  "mcpServers": {    "medusa": {      "command": "npx",      "args": ["-y", "medusa-mcp", "stdio"],      "env": {        "MEDUSA_BACKEND_URL": "https://api.example.com",        "MEDUSA_API_KEY": "sk_...",        "MEDUSA_READ_ONLY": "true"      }    }  }}

Claude Code:

bash
claude mcp add medusa \  -e MEDUSA_BACKEND_URL=https://api.example.com -e MEDUSA_API_KEY=sk_... \  -- npx -y medusa-mcp stdio

3. Remote connector (HTTP + OAuth)

bash
docker run -d --name medusa-mcp -p 127.0.0.1:3000:3000 -v medusa-mcp-data:/data \  -e MEDUSA_BACKEND_URL=https://api.example.com \  -e MEDUSA_API_KEY=sk_... \  -e PUBLIC_URL=https://mcp.example.com \  -e OWNER_PASSWORD="$(openssl rand -base64 24)" \  ghcr.io/trhonpavel/medusa-mcp:latest

Or clone the repo, copy .env.example to .env and run docker compose up -d --build.

The server listens on 127.0.0.1:3000; expose it through a reverse proxy with TLS. Claude connects to remote connectors from Anthropic's servers, so the endpoint must be publicly reachable over HTTPS. Caddy example:

mcp.example.com {    reverse_proxy 127.0.0.1:3000}

Then add a custom connector in Claude with the URL https://mcp.example.com/mcp. Claude registers itself (Dynamic Client Registration), opens the consent page, you enter OWNER_PASSWORD and click Allow.

ChatGPT

In ChatGPT turn on developer mode in the settings, then create an app (connector) with the MCP server URL https://mcp.example.com/mcp and OAuth authentication. ChatGPT registers itself the same way and redirects to chatgpt.com, which is in the default ALLOWED_REDIRECT_HOSTS. The server returns the RFC 9207 iss parameter, so ChatGPT uses its stable callback URL.

Claude Code

Claude Code can use the same OAuth flow, or a static token if you set MCP_STATIC_TOKEN:

bash
claude mcp add --transport http medusa https://mcp.example.com/mcp \  --header "Authorization: Bearer <MCP_STATIC_TOKEN>"

Configuration

VariableRequiredDefaultDescription
MEDUSA_BACKEND_URLyesMedusa backend URL
MEDUSA_API_KEYyesSecret API key (sk_…)
MEDUSA_READ_ONLYfalseRegister read and report tools only
REPORT_TIMEZONEUTCIANA timezone for date filters and report buckets
MEDUSA_TIMEOUT_MS20000Timeout for Medusa requests
PUBLIC_URLHTTPPublic HTTPS origin of this server (without /mcp)
OWNER_PASSWORDHTTPPassword required on the consent page
MCP_STATIC_TOKENOptional static bearer token
ALLOWED_REDIRECT_HOSTSclaude.ai,claude.com,chatgpt.com,localhost,127.0.0.1Hosts OAuth clients may use as redirect targets
TRUST_PROXY1Express trust proxy – number of proxies in front
PORT / HOST3000 / 0.0.0.0Listen address
DATA_DIR./dataWhere OAuth clients and token hashes are stored
ACCESS_TOKEN_TTL / REFRESH_TOKEN_TTL3600 / 2592000Token lifetimes in seconds

Endpoints

PathPurpose
POST /mcpMCP over Streamable HTTP (stateless), requires a bearer token
/.well-known/oauth-protected-resource/mcpRFC 9728 protected resource metadata
/.well-known/oauth-authorization-serverRFC 8414 authorization server metadata
/register, /authorize, /token, /revokeOAuth 2.1 (DCR, PKCE S256)
POST /oauth/loginconsent form (rate limited: 10 attempts / 15 min / IP)
GET /healthzhealth check

Security model

  • The Medusa API key never leaves the server. Clients get their own short-lived tokens (1 h access, 30-day refresh with rotation).
  • Only SHA-256 hashes of tokens are stored, in DATA_DIR/oauth-state.json (mode 600). Delete the file to sign out every client.
  • Dynamic Client Registration only accepts redirect URIs on ALLOWED_REDIRECT_HOSTS, so an arbitrary app cannot register its own callback and phish a token.
  • Authorization codes are single-use, expire after 5 minutes, and PKCE S256 is mandatory.
  • The consent page sends Content-Security-Policy: default-src 'none' and X-Frame-Options: DENY, and compares the password in constant time.
  • Write tools are not marked readOnlyHint and cancel_order / delete_product carry destructiveHint, so clients like Claude ask for approval before running them.
  • Set TRUST_PROXY to the number of reverse proxies in front of the server, otherwise rate limiting only sees the proxy's IP.

See SECURITY.md for reporting vulnerabilities.

Development

bash
npm cinpm test        # build + tests against a mock Medusa (tools and the full OAuth flow)npm run smoke   # read-only check against a real Medusa – prints response shapes only, no datanpm run dev     # HTTP mode via tsx

npm run smoke needs MEDUSA_BACKEND_URL and MEDUSA_API_KEY. Its output contains only keys and types, so it is safe to paste into an issue.

License

MIT

來源:README.md,提交 7b484cb

工具

0
工具後設資料尚未被收錄。

版本歷史

1
  1. v0.2.2最新Oct 1, 2026