跳到正文
DEV Community· Giorgi Kakabadze·· 32 分鐘前AI 評分58

Giorgi Kakabadze 分享以 MCP 將 Laravel 網店接入 AI 助手的經驗及免費套件 Storewire Lite

I put my Laravel store inside AI assistants. Here's what I learned (and the free package)

AI 導讀

Giorgi Kakabadze 將一間以 Laravel 建構的安防設備網店接上 MCP 伺服器,讓 AI 助手搜尋即時商品目錄、比較產品,並建立可在原店網站開啟的購物車。

正文

Shoppers have started asking AI assistants what to buy. "I need four outdoor cameras for a small shop, around 1500 lari." The assistant answers something. The question is whether that answer comes from your store, with your real prices and stock, or from a guess.

I run the platform behind a security-equipment store in Georgia, built on Laravel. Recently I put an MCP server on top of it, using the official laravel/mcp package, so an assistant can search our live catalogue, compare products and hand the shopper a cart that opens on our own site. It runs in production today.

This post covers what worked, what I would do differently, and the free package I extracted from it.

Watch it first (50 seconds)

There's a short video on plugins.hackerman.ge: a shopper asks for cameras on a budget, compares two recorders, and gets a cart on the real store.

You can also point any assistant that supports remote MCP servers at a demo store I host:

https://demo.plugins.hackerman.ge/mcp

It's an invented outdoor gear shop with 61 products, so you can poke at it without touching anything real.

The shape of it

MCP gives an assistant a list of tools it can call. For a store, the useful ones turned out to be:

  • search_products: words, model numbers, category, brand, price range, in-stock only, spec filters
  • get_product: one product as its page shows it: specs, stock, warranty, documents
  • compare_products: a side-by-side table
  • cart tools: add, update, remove, view
  • delivery options and store info (branches, hours, contacts)

The cart is the interesting part. The assistant never takes payment. It builds a cart under a token, and the answer includes a link like /cart/claim/{token}. The shopper clicks it, lands on your site with the cart filled, and checks out the normal way. Your checkout, your payment provider, your customer.

Three things that mattered more than I expected

1. Answer like your product page, not like your database. Early versions returned raw attributes. Assistants did fine with them, but shoppers saw odd wording. Returning what a visitor would see (the formatted price with VAT, the stock line your site shows, the spec table with units) made answers match the site exactly, which builds trust when the shopper clicks through.

2. Never let the assistant invent a price. Every product card carries the guest price from the same price resolver the storefront uses. When a product has no public price, the answer says so explicitly instead of leaving a gap the model might fill.

3. Keep it read-only until the cart. Search and product tools can't change anything. The cart tools only write to an anonymous cart with an expiry. Nothing is ordered and no customer data leaves the store unless the shopper signs in on the site.

Mapping it onto any catalogue

The store-specific part is a contract. In the free version it's one interface:

use Hackerman\StorewireLite\Contracts\CatalogRepository;

interface CatalogRepository
{
    // An id from an earlier answer, a product URL or slug, a model number or SKU.
    public function resolve(string $reference, string $locale): ?string;

    // One product as its page shows it; null when a visitor may not see it.
    public function product(string $id, string $locale): ?ProductDetail;

    public function search(SearchQuery $query): SearchResult;
}

Bind your implementation, switch it on, and the server answers POST /mcp:

composer require hackerman/storewire-lite
php artisan vendor:publish --tag=storewire-lite-config
STOREWIRE_LITE_ENABLED=true
STOREWIRE_LITE_SERVER_NAME="Your Store"
STOREWIRE_LITE_CURRENCY=USD

Test it with curl before you connect an assistant:

curl -s http://localhost:8000/mcp \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  -H 'MCP-Protocol-Version: 2025-06-18' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"search_products","arguments":{"query":"tent"}}}'

It doesn't care whether you run Lunar, a custom schema or something else, as long as you can answer those three methods.

Free and paid

  • Storewire Lite (MIT): search_products and get_product. GitHub, composer require hackerman/storewire-lite.
  • Storewire: the full set (compare, cart handoff, delivery quotes, store info, product and cart widgets for assistants that render them, an app manifest command). It's 40% off from 27 Nov to 2 Dec at plugins.hackerman.ge.

If you build shops for clients and want this set up, or need other Laravel e-commerce work, I take that on too.

What I'd love feedback on

  • How are you exposing your catalogue to assistants today, if at all?
  • Would you want write tools beyond the cart (wishlists, quotes), or is read-only plus cart the right line?

Happy to answer questions in the comments.

來源:DEV Community · dev.to