MCP Server
The MCP (Model Context Protocol) server lets AI agents like Claude, ChatGPT, and Cursor manage your store through natural language.Connection Methods
Authentication
The Cloud MCP server supports two authentication methods:Getting Your API Key
- Log in to the Headless Commerce Dashboard
- Go to Settings > API Keys
- Click Create API Key and select type Secret (
sk_prefix) - Copy the generated key — it is only shown once
Configuration
Cloud (Recommended)
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
.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:- Fetch
https://mcp.headlesscommerce.io/.well-known/mcp.json— returns the OAuth metadata URLs - Fetch
https://mcp.headlesscommerce.io/.well-known/oauth-protected-resource— returns supported scopes and authorization server - Fetch
https://api.headlesscommerce.io/.well-known/oauth-authorization-server— returns authorization and token endpoints
A
:write scope automatically includes :read access for the same resource. For example, orders:write also grants orders:read.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 theBearerprefix) - For API keys: verify the key starts with
sk_(notpk_) 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
scopeparameter
”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 theenv 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_(notpk_) - 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_URLis set tohttp://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*.logfor error messages