Skip to content
Ahmad Raza
Menu
All posts

5 min read

WebMCP on Your Storefront: Tools Agents Can Call Without Scraping

WebMCP lets your storefront expose tools like search_products and add_to_cart in the browser session, so agents stop scraping and shoppers keep paying.

WebMCP on Your Storefront: Tools Agents Can Call Without Scraping
On this page

WebMCP is the part of agentic commerce that lives on your own website. Instead of an AI agent guessing which button to click, your storefront tells the agent, "here are the things you can do on this page," and the agent calls them directly.

If you have ever maintained a test suite that broke because someone renamed a CSS class, you already understand why this matters. Click automation is brittle. WebMCP storefront tools are a contract.

The problem with scraping and clicking

Right now, when a browser agent shops on a site, it usually does something like this. It loads the page, reads the DOM or a screenshot, finds something that looks like a search box, types, waits, finds something that looks like a product, finds something that looks like "Add to cart," and clicks.

That works in demos. In real stores it breaks for ordinary reasons:

  • A theme update moves the button.
  • A popup asks about cookies or newsletter signups.
  • A variant picker uses a custom dropdown the agent cannot read.
  • A sale banner pushes content down and the click lands on the wrong thing.

Every one of those failures looks to the shopper like your store is broken. Not the agent. Your store.

What WebMCP changes

With WebMCP, your page registers tools inside the browser session on your merchant domain. A tool has a name, a description, input fields, and a result. For a store, the obvious first tools are:

  • search_products: takes a query and filters, returns matching products with variants and prices.
  • get_product: returns full details for one product.
  • add_to_cart: takes a product, variant, and quantity, and adds it to the current session cart.
  • view_cart: returns what is in the cart and the current total.

The agent calls these the same way it would call any MCP tool. It does not care what your HTML looks like. Your designer can change the whole layout tomorrow and the tools keep working.

Why the browser session matters

This is the subtle part, and the part I like most.

WebMCP tools run in the shopper's real session. If they are logged in, the tools see their account. If they have a saved address, shipping estimates use it. If they already have something in their cart, add_to_cart adds to that cart, not a new invisible one.

That means the agent is working with the shopper, inside your site, not around it. Your analytics still see the visit. Your personalization still applies. Your brand is still on screen.

Payment stays with the shopper

Here is the line I would not cross, and WebMCP is built around it. The agent can search, compare, and fill the cart. The shopper completes payment.

You do not expose a "pay now" tool. When the cart is ready, the agent hands off to your normal checkout and the shopper reviews and pays like they always do. Card details never pass through the agent.

This keeps three things safe at once:

  1. The shopper keeps control of their money.
  2. You keep your existing fraud checks and payment provider.
  3. You avoid building a new, risky path that a prompt injection could abuse.

A simple implementation plan

You do not need to rebuild your store. On a Next.js storefront, this is a small, contained piece of work.

Start read-only. Ship search_products and get_product first. They cannot change anything, so the risk is close to zero. Watch how agents use them.

Reuse your existing APIs. Your search page already calls something. Your cart already has an endpoint. The tools should wrap those, not duplicate logic. One source of truth for price and stock.

Return structured, honest data. Include stock status, variant IDs, prices with currency, and shipping estimates when you have them. If something is out of stock, say so clearly.

Add cart tools next. add_to_cart and view_cart change session state, but nothing irreversible. Validate inputs the same way your UI does.

Stop at checkout. Provide a clear handoff, such as a checkout URL or a navigation to your checkout page. Let the shopper take it from there.

Log tool calls. Keep a simple record of which tools were called and whether they succeeded. It is the fastest way to find data problems.

Writing good tool descriptions

Agents choose tools based on their names and descriptions, so write them for a reader who has never seen your store.

A weak description: "Search."

A useful one: "Search products in this store by keyword. Optional filters: category, size, color, max price. Returns up to 20 in-stock and out-of-stock items with variant IDs and prices in USD."

Be specific about units, currency, limits, and what happens when nothing matches. Clear descriptions mean fewer wrong calls.

Where WebMCP fits next to Shop MCP

Shop MCP is a shared shopping layer that works across many merchants, strongest on Shopify. WebMCP is on your own domain, in the shopper's live session. They solve different problems.

If most of your sales are standard products on Shopify, Shop MCP may cover a lot of ground for free. If you care about the on-site experience, have custom configuration, or run a headless store, WebMCP gives you a direct, branded path for agents. Plenty of stores will want both.

Common mistakes I would avoid

  • Exposing too much. You do not need order history, account edits, or refunds as tools on day one. Start small.
  • Separate logic for agents. If the tool computes price differently from your UI, you will eventually show two prices. Share the code.
  • Silent failures. If add_to_cart fails, return a clear reason. "Variant out of stock" is useful. A generic error is not.
  • Forgetting mobile and slow networks. Tools still run in a browser. Keep responses lean.

Wrapping up

WebMCP storefront tools replace guessing with a contract. Agents get a stable way to search and fill a cart. Shoppers stay in their own session and pay the way they trust. You stop losing sales to a button that moved.

If you run a Next.js or headless store and want WebMCP tools built properly, with read-only first, shared logic, and a clean checkout handoff, I can help. Take a look at my work, reach out through the contact section, or email ahmadraza365pro@gmail.com.

  • 5 min read

    A 30-Day Agentic Commerce Rollout for a Next.js Store

    A practical, week by week plan to make a Next.js store ready for AI shopping agents: clean the data, ship a read only catalog MCP server, add carts, hand off to confirmed checkout, then log and cap everything.

  • 5 min read

    Fraud and Abuse When Agents Shop Your Checkout

    AI shopping agents look a lot like bots, and bots look a lot like agents. Here is how to tell them apart, where to put bot challenges, and why hosted checkout like Shop Pay is your best trust boundary.

  • 4 min read

    Hydrogen SDK vs Calling Storefront API Yourself in 2026

    Shopify's Hydrogen SDK now reaches beyond Remix and React Router into other frameworks. Here is what it gives you for agent ready storefronts, what a thin Next.js client gives you, and when each one pays off.