Commerce API

MCP server

Model Context Protocol server exposing Commerce API operations as tools for AI agents.

The Commerce API exposes a Model Context Protocol (MCP) server at /mcp, allowing AI agents and LLM applications to interact with commerce data through standardized tools.

Free keys reach the 21 storefront tools, with three limits. applyCartCoupon and removeCartCoupon have nothing to act on, because no merchant can create coupons yet. listOrders returns an empty list here: it only lists a signed-in customer's orders, and that needs the REST route. Admin tools need a key with the Admin scope, which starts on Grow. Agent Auth starts on Grow. Paid plans are coming.

Endpoint

plaintext
POST /mcp
Content-Type: application/json
Authorization: Bearer {jwt} | x-api-key: {key}

Uses streamable HTTP transport via mcp-handler.

Available tools

MCP tools mirror the REST API endpoints. Each tool maps to an OpenAPI operationId:

Catalog tools

ToolREST equivalentDescription
listProductsGET /v1/productsSearch and list products
getProductGET /v1/products/{id}Get product by ID
getProductBySlugGET /v1/products/by-slug/{slug}Get product by URL slug
listCategoriesGET /v1/categoriesList categories
getStoreGET /v1/storeGet store info
listCountriesGET /v1/countriesList countries

Cart tools

ToolREST equivalentDescription
createCartPOST /v1/cartsCreate a new cart
getCartGET /v1/carts/{id}Get cart details
addCartItemPOST /v1/carts/{id}/itemsAdd item to cart
updateCartItemPATCH /v1/carts/{id}/items/{itemId}Update item quantity
removeCartItemDELETE /v1/carts/{id}/items/{itemId}Remove item
applyCartCouponPOST /v1/carts/{id}/couponApply coupon. No merchant can create coupons yet
removeCartCouponDELETE /v1/carts/{id}/couponRemove coupon. No merchant can create coupons yet
setCartShippingAddressPUT /v1/carts/{id}/shipping-addressSet shipping address
setCartBillingAddressPUT /v1/carts/{id}/billing-addressSet billing address
listCartShippingMethodsGET /v1/carts/{id}/shipping-methodsList shipping options
listCartPaymentMethodsGET /v1/carts/{id}/payment-methodsList payment options
setCartShippingMethodPATCH /v1/carts/{id}/shipping-methodSelect shipping method
placeOrderPOST /v1/carts/{id}/place-orderPlace order from cart
listOrdersGET /v1/ordersList customer orders. Returns an empty list over MCP
getOrderGET /v1/orders/{id}Get order

Admin tools

ToolREST equivalentDescription
adminListProductsGET /v1/admin/productsList all products
adminCreateProductPOST /v1/admin/productsCreate product
adminGetProductGET /v1/admin/products/{id}Get product
adminUpdateProductPATCH /v1/admin/products/{id}Update product
adminDeleteProductDELETE /v1/admin/products/{id}Delete product
adminCreateCategoryPOST /v1/admin/categoriesCreate category
adminUpdateCategoryPATCH /v1/admin/categories/{id}Update category
adminDeleteCategoryDELETE /v1/admin/categories/{id}Delete category
adminListOrdersGET /v1/admin/ordersList orders
adminGetOrderGET /v1/admin/orders/{id}Get order detail
adminCancelOrderPOST /v1/admin/orders/{id}/cancelCancel order
adminGetOrderHistoryGET /v1/admin/orders/{id}/historyGet order history
adminFulfillOrderPOST /v1/admin/orders/{id}/fulfillFulfill order
adminRefundOrderPOST /v1/admin/orders/{id}/refundRefund order
adminListCustomersGET /v1/admin/customersList customers
adminGetCustomerGET /v1/admin/customers/{id}Get customer
adminGetDashboardGET /v1/admin/dashboardDashboard statistics
adminGetStoreGET /v1/admin/storeStore settings
adminUpdateStorePATCH /v1/admin/storeUpdate store settings
adminUpdateInventoryPOST /v1/admin/inventoryUpdate inventory

Authentication

MCP requests use the same authentication as REST:

MethodHeaderScopes
Agent JWTAuthorization: Bearer {jwt}From capability grants
API keyx-api-key: {key}From key metadata

The MCP handler resolves the caller via resolve-caller.ts and sets context in AsyncLocalStorage for tool execution.

Implementation

Each tool in apps/api/lib/mcp/tools.ts calls the same commerce-service.ts functions as REST route handlers and returns both text content and structuredContent:

ts
server.registerTool('listProducts', { inputSchema: searchProductsQuery.shape }, async (input) => {
  const orgId = requireScope('storefront')
  const data = await catalog.searchProducts(orgId, searchProductsQuery.parse(input))
  return {
    content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
    structuredContent: data,
  }
}

Connecting an MCP client

Cursor / Claude Desktop

Add to your MCP config:

json
{
  "mcpServers": {
    "prood-commerce": {
      "url": "https://api.prood.com/mcp",
      "headers": {
        "x-api-key": "pkAbC123..."
      }
    }
  }
}

Programmatic

Use the @modelcontextprotocol/sdk client:

ts
import { Client } from '@modelcontextprotocol/sdk/client/index.js'

const client = new Client({ name: 'my-agent', version: '1.0.0' })
await client.connect(transport)

const result = await client.callTool({
  name: 'listProducts',
  arguments: { query: 'shirt', perPage: 5 },
})