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.
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

Authentication

The Cloud MCP server supports two authentication methods:

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:

Claude Code

Or add to .claude/settings.json:

Cursor

Add to .cursor/mcp.json:

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:
Available scopes:
A :write scope automatically includes :read access for the same resource. For example, orders:write also grants orders:read.
Token lifetimes:
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:

Environment Variables

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

Claude Code

Add to .claude/settings.json:

Cursor

Add to .cursor/mcp.json:

Local Development

For local development, override the API URL:

Available Tools

Products

Variants

Orders

Customers

Inventory

Discounts

Fulfillments

Categories

Collections

Carts & Checkout

Payments

Returns

Refunds

Regions

Shipping Methods

Webhooks

Store

Dashboard

Resources

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