跳到正文
DEV Community· Vladimir Pirotskiy·· 1 小時前AI 評分53

AI 助手透過 MCP 購物評測:搜尋與商品選擇的失誤案例

I measured how well an AI assistant shops through MCP. Here is what broke.

AI 導讀

作者開源 mcp-commerce-evals,評測 AI 助手透過 MCP 購物時的搜尋排序與商品選擇。工具層 40 個排序查詢的 hit@1 為 0.90、hit@5 為 0.93;Claude Haiku 每條查詢測試 3 次,共 132 次執行,pass@1 為 0.94。

正文

Vladimir Pirotskiy

An assistant that shops for a buyer can fail in two ways: it finds the wrong part, or it finds the right part and then reasons badly about it. Most demos show neither. So I wrote a small open-source harness that measures both, against any store that speaks MCP over HTTP: mcp-commerce-evals (Rust, MIT).

What is in it

  • A reference store: an MCP server with four tools (search_products, get_product, check_availability, create_cart) over a generated catalog of 500 bicycle parts from 14 fictional brands. Everything is invented, so you can run it in a minute without an account or a key.
  • 44 buyer queries of eight kinds: exact part number, plain description, compatibility, typo, synonym, filter, adversarial, and no_match for things the catalog does not sell. The expected ids come from catalog attributes, never from running the search.
  • Two levels of evals. Tool-level calls the search tool directly and reports hit@1, hit@5, MRR, recall@10 and nDCG@10 with 95% intervals. Assistant-level lets a model shop through the tools and scores the part id it commits to.
cargo run --release -p reference-store
cargo run --release -p mcp-commerce-evals -- --url http://127.0.0.1:8787/mcp

What the numbers said

Tool-level, 40 ranked queries: hit@1 0.90, hit@5 0.93, MRR 0.91. With an assistant on top (Claude Haiku, 3 trials per query, 132 runs): pass@1 0.94.

The misses are the useful part:

  • STO-HT-1O64 ranked 9th: the letter O is not read as a zero inside a part number. A buyer typing from a worn label does this all the time.
  • "11-speed chain, in stock, under $30" found chain lube first. Without a category filter, lubes outrank chains.
  • A hub query ranked 9th because axle parts outrank hubs.

None of these show up in a demo where someone asks for "a chain".

What I would not claim

40 queries is small: one query moves a rate by 2.5 points, and for a kind of six queries the interval runs from 0.44 to 0.97. I wrote the catalog and the queries myself, so this shows that the harness measures, not that one search engine beats another. Latency is a loopback round trip to an in-memory index, not a production figure.

Why it matters

If you put an MCP endpoint on a real store, the assistant becomes one more buyer, and it needs the same thing a search page needs: a test set and a gate in CI. The CLI turns a score into an exit code (--min-hit5, --min-mrr, --min-accuracy), so a ranking regression fails the build like any other test.

The repo, the full tables and the caveats: github.com/Vladimir-Pirotskiy/mcp-commerce-evals. More of my work: pirotskiy.com.

來源:DEV Community · dev.to