Skip to main content

MCP Server

The MCP (Model Context Protocol) server lets AI agents like Claude, ChatGPT, and Cursor manage your store through natural language.
                    ┌── Cloud (HTTP) ──► https://mcp.headlesscommerce.io/mcp
AI Agent ───────────┤                                │
(Claude, Cursor,    └── Local (stdio) ─► npx @headless-commerce/mcp-server
 ChatGPT)                                            │
                                               SDK ──► Headless Commerce API
The MCP server is stateless — it holds no data and acts purely as a bridge between AI agents and the Headless Commerce API.

Connection Methods

Cloud (Recommended)Local (stdio)
SetupURL + API key or OAuthRequires Node.js
TransportStreamable HTTPstdio (JSON-RPC)
AuthAPI key or OAuth 2.0API key only
UpdatesAlways latestManual npm update
OfflineNoYes
Best forProduction, most usersAir-gapped, self-hosted

Authentication

The Cloud MCP server supports two authentication methods:
MethodBest forScopes
API Key (sk_)Quick setup, full admin accessadmin (all permissions)
OAuth 2.0Third-party apps, granular permissionsConfigurable per-resource

Getting Your API Key

  1. Log in to the Headless Commerce Dashboard
  2. Go to Settings > API Keys
  3. Click Create API Key and select type Secret (sk_ prefix)
  4. Copy the generated key — it is only shown once
MCP server requires a Secret Key (sk_). Publishable keys (pk_) are for storefront use only and will be rejected by admin endpoints.

Configuration


No installation required — just add the URL and your API key.

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
  "mcpServers": {
    "headless-commerce": {
      "url": "https://mcp.headlesscommerce.io/mcp",
      "headers": {
        "Authorization": "Bearer sk_live_your_api_key"
      }
    }
  }
}

Claude Code

claude mcp add headless-commerce \
  --transport http \
  --url https://mcp.headlesscommerce.io/mcp \
  --header "Authorization: Bearer sk_live_your_api_key"
Or add to .claude/settings.json:
{
  "mcpServers": {
    "headless-commerce": {
      "url": "https://mcp.headlesscommerce.io/mcp",
      "headers": {
        "Authorization": "Bearer sk_live_your_api_key"
      }
    }
  }
}

Cursor

Add to .cursor/mcp.json:
{
  "mcpServers": {
    "headless-commerce": {
      "url": "https://mcp.headlesscommerce.io/mcp",
      "headers": {
        "Authorization": "Bearer sk_live_your_api_key"
      }
    }
  }
}

OAuth 2.0 (for third-party apps)

For apps that need granular, scoped access instead of full admin, the Cloud MCP server supports OAuth 2.0 with PKCE. MCP clients that support OAuth can automatically discover the auth configuration:
  1. Fetch https://mcp.headlesscommerce.io/.well-known/mcp.json — returns the OAuth metadata URLs
  2. Fetch https://mcp.headlesscommerce.io/.well-known/oauth-protected-resource — returns supported scopes and authorization server
  3. Fetch https://api.headlesscommerce.io/.well-known/oauth-authorization-server — returns authorization and token endpoints
Authorization flow:
1. Register client    POST /oauth/register
2. Authorize user     GET  /oauth/authorize?response_type=code&code_challenge=...&scope=...
3. Exchange code      POST /oauth/token  (grant_type=authorization_code)
4. Use access token   Authorization: Bearer <access_token>
5. Refresh token      POST /oauth/token  (grant_type=refresh_token)
Available scopes:
ScopeDescription
adminFull access to all resources
products:readView products, categories, collections
products:writeCreate and update products
orders:readView orders
orders:writeManage orders (confirm, cancel)
customers:readView customers
customers:writeManage customers
inventory:readView inventory levels
inventory:writeAdjust inventory
discounts:readView discounts
discounts:writeCreate and manage discounts
store:readView store settings
store:writeUpdate store settings
dashboard:readView dashboard analytics
A :write scope automatically includes :read access for the same resource. For example, orders:write also grants orders:read.
Token lifetimes:
TokenLifetime
Authorization code10 minutes (single-use)
Access token1 hour
Refresh token30 days (rotated on use)
PKCE (S256) is required for all OAuth flows. Plain code_challenge_method is not supported.

Local (stdio)

If you prefer running the MCP server locally, install via npm:
npm install -g @headless-commerce/mcp-server
# or run directly
npx @headless-commerce/mcp-server

Environment Variables

VariableRequiredDefaultDescription
HEADLESS_COMMERCE_API_KEYYesAdmin API key (sk_ prefix)
HEADLESS_COMMERCE_API_URLNohttps://api.headlesscommerce.io/v1API base URL (override for local dev)

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
  "mcpServers": {
    "headless-commerce": {
      "command": "npx",
      "args": ["-y", "@headless-commerce/mcp-server"],
      "env": {
        "HEADLESS_COMMERCE_API_KEY": "sk_live_your_api_key"
      }
    }
  }
}

Claude Code

Add to .claude/settings.json:
{
  "mcpServers": {
    "headless-commerce": {
      "command": "npx",
      "args": ["-y", "@headless-commerce/mcp-server"],
      "env": {
        "HEADLESS_COMMERCE_API_KEY": "sk_live_your_api_key"
      }
    }
  }
}

Cursor

Add to .cursor/mcp.json:
{
  "mcpServers": {
    "headless-commerce": {
      "command": "npx",
      "args": ["-y", "@headless-commerce/mcp-server"],
      "env": {
        "HEADLESS_COMMERCE_API_KEY": "sk_live_your_api_key"
      }
    }
  }
}

Local Development

For local development, override the API URL:
{
  "env": {
    "HEADLESS_COMMERCE_API_KEY": "sk_test_your_api_key",
    "HEADLESS_COMMERCE_API_URL": "http://localhost:3010/v1"
  }
}

Available Tools

Products

ToolDescription
list_productsList products with search, filtering, and pagination
get_productGet a product by ID with variants, images, and options
create_productCreate a new product
update_productUpdate product name, description, status, tags

Variants

ToolDescription
create_variantCreate a variant with price (in smallest currency unit)

Orders

ToolDescription
list_ordersList orders with status/payment/fulfillment filters
get_orderGet order details with lines, payments, fulfillments
confirm_orderConfirm a pending order
cancel_orderCancel an order with optional reason

Customers

ToolDescription
list_customersList customers with search by name or email
get_customerGet a customer by ID

Inventory

ToolDescription
list_inventoryList inventory levels for all variants
adjust_inventoryAdjust stock quantity (+/-) with reason

Discounts

ToolDescription
list_discountsList all discount codes/promotions
create_discountCreate a discount (fixed, percentage, or free shipping)

Fulfillments

ToolDescription
create_fulfillmentCreate a fulfillment for an order with tracking info
update_fulfillmentUpdate tracking information
ship_fulfillmentMark a fulfillment as shipped
deliver_fulfillmentMark a fulfillment as delivered

Categories

ToolDescription
list_categoriesList all categories
create_categoryCreate a new category
update_categoryUpdate a category
delete_categoryDelete a category

Collections

ToolDescription
list_collectionsList all collections
create_collectionCreate a collection (manual or auto)
update_collectionUpdate a collection
delete_collectionDelete a collection

Carts & Checkout

ToolDescription
create_cartCreate a new shopping cart
get_cartGet a cart with items and totals
add_cart_itemAdd a product variant to a cart
update_cart_itemUpdate cart item quantity
remove_cart_itemRemove an item from a cart
apply_cart_discountApply a discount code to a cart
checkout_cartCheckout a cart to create an order

Payments

ToolDescription
create_paymentRecord a manual payment for an order
complete_paymentMark a payment as completed

Returns

ToolDescription
list_returnsList all returns
get_returnGet return details
create_returnCreate a return request for an order
approve_returnApprove a return
reject_returnReject a return
receive_returnMark returned items as received
complete_returnComplete a return

Refunds

ToolDescription
create_refundCreate a refund for an order

Regions

ToolDescription
list_regionsList all regions
create_regionCreate a region with currency and tax
update_regionUpdate a region
delete_regionDelete a region
upsert_region_priceSet region-specific pricing for a variant

Shipping Methods

ToolDescription
list_shipping_methodsList all shipping methods
create_shipping_methodCreate a shipping method
update_shipping_methodUpdate a shipping method

Webhooks

ToolDescription
list_webhooksList webhook subscriptions
create_webhookCreate a webhook subscription
test_webhookSend a test event to a webhook

Store

ToolDescription
get_storeGet store settings and configuration
update_storeUpdate store name, currency, metadata

Dashboard

ToolDescription
get_dashboard_statsGet revenue, orders, customers, and recent activity

Resources

ResourceURIDescription
API Referenceopenapi://specEmbedded OpenAPI spec — AI agents read this automatically to understand the full API

Example Prompts

Once configured, try asking your AI agent:
  • “Show me all orders from today”
  • “Create a new product called ‘Wireless Headphones’ at $49.99”
  • “What’s the current inventory for our best-selling items?”
  • “Cancel order ord_abc123 — customer requested refund”
  • “Give me a dashboard summary of the last 30 days”
  • “List all active discount codes”

Troubleshooting

”Unauthorized” (401) when using cloud endpoint

  • Ensure the header is Authorization: Bearer <token> (include the Bearer prefix)
  • For API keys: verify the key starts with sk_ (not pk_) and is active in Dashboard > Settings > API Keys
  • For OAuth tokens: verify the access token has not expired (1-hour lifetime) — refresh it using the refresh token

”Insufficient scope” when using OAuth

  • The OAuth token does not have the required scope for the requested tool
  • Check which scopes were granted during authorization
  • Request additional scopes by re-authorizing with a broader scope parameter

”HEADLESS_COMMERCE_API_KEY environment variable is required”

This applies to the local (stdio) server. It exits immediately if no API key is provided. Ensure the env block in your MCP config has the key set.

”Invalid API key” or “Secret key required for Admin API”

  • Verify the key starts with sk_ (not pk_)
  • Check that the key is still active in Dashboard > Settings > API Keys

Tools return empty results

  • Confirm the API server is running and accessible at the configured URL
  • For local dev, make sure HEADLESS_COMMERCE_API_URL is set to http://localhost:3010/v1
  • Check that your store has data (products, orders, etc.)

Server doesn’t appear in Claude Desktop

  • Restart Claude Desktop after editing the config file
  • Verify the JSON is valid (no trailing commas, correct nesting)
  • Check ~/Library/Logs/Claude/mcp*.log for error messages