Shopify MCP
Shopify Customer Accounts MCP server enables authenticated customer actions like order management and account preferences. It uses OAuth 2.0 for secure access to customer-specific data and requests.
How to Install and Use Shopify MCP
Shopify MCP is a helpful server that connects your AI agent to a Shopify store's catalog, shopping cart, and store policies. It allows your AI to help shoppers find products, add items to their cart, and complete checkout. Here’s an easy way to get started with Shopify MCP using examples and clear steps.
Step 1: Connect to the Shopify MCP Server
Before you can start using Shopify MCP, you need to connect to the correct server for the store you want to work with. Every Shopify store has its own MCP server endpoint. This endpoint handles all calls related to product search, cart updates, and policy questions.
Here’s what the endpoint looks like:
https://storedomain.com/api/mcp
Replace storedomain.com with the real domain of the Shopify store you are working with. For example, if the store is called "your-store", the endpoint would be:
https://your-store.myshopify.com/api/mcp
Step 2: Create an API Request to the MCP Server
Now that you have the endpoint, you can send requests to it to get information or update a cart. Shopify MCP servers do not need any authentication, so you only need to set up your request with the right Content-Type header and the data you want.
Here’s a basic example of how to make a request to search the store catalog for "coffee" products:
const storeDomain = 'your-store.myshopify.com';
const mcpEndpoint = `https://${storeDomain}/api/mcp`;
fetch(mcpEndpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'tools/call',
id: 1,
params: {
name: 'search_shop_catalog',
arguments: { query: 'coffee', context: "reader" }
}
})
});
Replace 'your-store.myshopify.com' with your store’s domain, and then you can customize the query with the product search terms you want.
Step 3: Use Shopify MCP Tools
Shopify MCP offers several useful tools that help your AI support shoppers. Here are some main tools you can use:
- search_shop_catalog: Finds products in the store based on a search query.
- search_shop_policies_and_faqs: Answers questions about store policies like returns or shipping.
- get_cart: Retrieves the current cart contents.
- update_cart: Adds or changes items in the shopping cart.
For example, here is how to call the search_shop_catalog tool to look for "organic coffee beans" with additional context:
{
"jsonrpc": "2.0",
"method": "tools/call",
"id": 1,
"params": {
"name": "search_shop_catalog",
"arguments": {
"query": "organic coffee beans",
"context": "Customer prefers fair trade products"
}
}
}
You send this JSON in the body of your POST request to the MCP endpoint.
Step 4: Updating the Cart with Shopify MCP
You can also use Shopify MCP to manage the shopper’s cart. If you want to add items or change quantities, use the update_cart tool. If you don’t provide a cart ID, a new cart will be created automatically.
Here is an example of updating the cart by adding two products:
{
"jsonrpc": "2.0",
"method": "tools/call",
"id": 1,
"params": {
"name": "update_cart",
"arguments": {
"cart_id": "gid://shopify/Cart/abc123def456",
"lines": [
{
"line_item_id": "gid://shopify/CartLine/line2",
"merchandise_id": "gid://shopify/ProductVariant/789012",
"quantity": 2
}
]
}
}
}
Replace "cart_id" and item IDs with your actual cart and product variant IDs.
By following these simple steps, you can install and use Shopify MCP to connect your AI with Shopify stores and help shoppers get what they want! Always remember to test with your specific store domain to make sure everything works well.