
AI agents are starting to shop for people, and a Shopify store is a good place for them to do it: products, prices and stock already sit behind clean APIs. This guide shows how to add WebMCP tools to a Shopify storefront. New to the topic? Start with what WebMCP is.
WebMCP or Shopify’s own MCP?
Every Shopify store now has an MCP endpoint at /api/mcp, which AI apps can call for product search, carts and policies. That runs on Shopify’s servers and you do not control its tools. WebMCP is different: the tools live on your page, run in the shopper’s browser, and do exactly what you design, such as your own sizing advice or bundle rules. The two work well together. Our guide to WebMCP vs MCP explains the difference.
Where the code goes
- Theme: a script asset loaded from
theme.liquid. Simple, and fine for one store, but it needs care when you change themes. - Theme app extension: an app embed block that the merchant switches on in the theme editor. It survives theme changes and is the better route for agencies and several stores.
A product search tool
Shopify’s predictive search endpoint is public and returns what shoppers can already see, so it needs no private key:
const mc = document.modelContext || navigator.modelContext;
if (mc && mc.registerTool) {
mc.registerTool({
name: 'search_products',
description: 'Search this store. Returns up to 5 products with price, availability and link.',
inputSchema: {
type: 'object',
properties: { query: { type: 'string', description: 'Keywords, e.g. linen shirt' } },
required: ['query'],
},
annotations: { readOnlyHint: true },
execute: async ({ query }) => {
const url = new URL('/search/suggest.json', location.origin);
url.searchParams.set('q', String(query).slice(0, 80));
url.searchParams.set('resources[type]', 'product');
url.searchParams.set('resources[limit]', '5');
const data = await (await fetch(url)).json();
return JSON.stringify(data.resources.results.products.map((p) => ({
name: p.title, price: p.price, available: p.available, url: p.url,
})));
},
});
}Cart actions need the shopper
A tool can call /cart/add.js with the shopper’s own session, but mark it with consequentialHint: true so the shopper approves first. Leave checkout and payment to the shopper. Do not put an Admin API token in storefront code: anything in the browser is public.
Safety rules
- Start read-only. Search and details first; mark them with
readOnlyHint. - Ask before acting. Mark cart, booking and form actions with
consequentialHint, so the visitor confirms. - Check on the server. The browser is not a security boundary, so validate every input and permission in your backend.
- Return little. Send only what a customer may see, never admin data or other customers’ records.
Test it
- Use a recent Chrome with WebMCP turned on, through the origin trial or the testing flag.
- Call each tool with good and bad inputs.
- Check that normal visitors see no change.
- Run the free WebMCP checker on the exact page where your tools live.
Want it done for you?
We add WebMCP tools to Shopify and other stacks, starting with a free readiness audit. See our WebMCP integration services.
Frequently asked questions
Does Shopify support WebMCP?
Shopify storefronts can use WebMCP because it runs in the browser. You add it yourself with a script in your theme or an app. WebMCP itself runs in Chrome as an origin trial in 2026.
What is the difference between WebMCP and Shopify’s MCP endpoint?
Shopify stores expose an MCP endpoint at /api/mcp that AI apps call over the internet. WebMCP tools run on your web page, in the shopper’s browser and session, and you decide what they do.
Do I need a Shopify app to add WebMCP?
No. For one store, a script in the theme is enough. An app with a theme app extension is cleaner when you want easy updates or several stores.
Can an AI agent buy from my Shopify store?
Do not build a tool that pays on its own. An agent can prepare the cart with the shopper’s approval. Checkout and payment should stay with the shopper.
How we can help
- WebMCP Integration ServicesWebMCP development for any stack, from WordPress and Shopify to Next.js, Laravel and Django: search, FAQs and forms offered as secure tools for AI browser agents, with a free audit.
- Headless E-Commerce DevelopmentShopify Plus, Hydrogen, Medusa, and Commercetools storefronts on Next.js with custom checkouts, ERP/3PL integrations, and conversion-rate optimization.
- Custom Web Application DevelopmentFull-stack custom web application development for SaaS, internal tools, dashboards, and enterprise portals across React, Next.js, Node, Laravel, and Django.
Talk to an engineer about your project
Tell us what you are building. We reply within one business day with a candid view on scope, approach and effort.
Book a free strategy callWritten by the UnlockLive IT engineering team. UnlockLive IT Limited works with clients through its Los Angeles headquarters and Toronto office and delivers engineering from its Dhaka delivery centre. About us