Skip to main content
Glama

mcp-retail-sim

Synthetic retail store MCP server for building and evaluating shopping / support agents.

No real payments, inventory DB, or third-party APIs — fixtures load into memory so demos and evals stay deterministic.

What you get

Primitive

Examples

Tools

search, get_product_details, check_inventory, add_to_cart, get_cart, remove_from_cart, place_order, get_order_details

Resources

product://{sku}, policy://returns, policy://shipping, policy://privacy

Prompts

compare_products, find_best_deal

Transports

stdio (default) · Streamable HTTP

Cart/order flows are stateless at the protocol layer: the client passes a cart_id handle (no server login session).

Same tools, resources, and prompts are available on both transports — only how the client connects changes.

Related MCP server: helios-mcp-server

Demo catalog

About 1000 synthetic products (SKU-1000…SKU-1999) across common retail departments (grocery, home, beauty, health, clothing, electronics, and more).

search accepts an optional free-text query (substring on name, description, category, brand, tags) plus optional filters: category, brand, tag, min_price, max_price, in_stock, dietary, organic, limit (default 50). Filters are ANDed. Empty query with no filters returns []; empty query with filters browses the filtered set.

Department-specific attrs (plus mirrored tags) support preference-style shopping — for example grocery dietary / organic / allergen / sugar_level, clothing material / fit, electronics connectivity / power_source (battery | mains | passive | rechargeable). There are still no rating/review fields.

Try this

What you should see

search query headphones / yoga / laptop

Matching products

search category=grocery_pantry dietary=vegan max_price=20

Filtered browse (query may be empty)

get_product_details / product://SKU-1001

LumenLab Pro Headphones

check_inventory SKU-1001

In stock

check_inventory SKU-1002

Out of stock (stock_qty 0)

add_to_cart cart-1 + SKU-1001

Cart with items + total / currency; stock unchanged

get_cart cart-1

Same cart snapshot (items + total)

remove_from_cart cart-1 + SKU-1001

Qty down / line removed; total updated; stock unchanged

place_order cart-1 (+ optional idempotency_key)

Order id ORD-…, stock decremented; safe retry with same key

get_order_details

That ORD-… id (only while this server process is running)

policy://returns, policy://shipping, policy://privacy

Store policy text

Categories include electronics, computers, home and kitchen, furniture, clothing, beauty, sports, toys, books, grocery, health, automotive, pets, office, and baby.

Cart / checkout notes

  • add_to_cart merges qty for the same SKU; it never decrements stock.

  • remove_from_cart(cart_id, product_id, quantity=1) decrements qty; drops the line at 0; keeps an empty cart.

  • Cart and order payloads include total and currency (USD).

  • place_order revalidates stock at checkout, then decrements inventory and deletes the cart.

  • Optional idempotency_key: same key + same cart fingerprint returns the original order; same key + different cart is rejected. Keys live in process memory (like orders).

Eval fault injection (test/dev only)

For demos and agent evaluations you can force checkout failures without exposing an admin MCP tool. Set env on the server process (stdio host env, or export before HTTP start):

MCP_RETAIL_SIM_FAULTS=place_order:insufficient_stock

Directive

Effect

place_order:insufficient_stock

Fail before commit (stock unchanged, cart kept)

place_order:latency_ms:N

Sleep N ms before checkout work

place_order:fail_once

First new checkout returns a transient error (before commit); later attempts proceed

place_order:error_after_commit

Commit order + idempotency, then return a fake transient error once; retry with the same idempotency_key returns the real order

Enable one scenario at a time. Idempotent replay skips fault injection. Cleared by default when the env var is unset. In pytest, use mcp_retail_sim.faults.enable_faults([...]) / clear_faults().

A project .env file is not loaded automatically — the MCP host or shell must set MCP_RETAIL_SIM_FAULTS.

Runtime reset (test/eval only)

For long-lived processes or pytest isolation, call mcp_retail_sim.store.reset_runtime_state() to:

  • clear carts, orders, and idempotency records

  • clear fault injection

  • reload products / inventory / policies from fixtures (restores stock)

This is not an MCP tool — agents cannot reset the store.

Eval adversarial fixtures (opt-in)

Optional products for indirect prompt-injection evaluations (agent must not blindly trust tool/catalog text). They are not in the default catalog.

MCP_RETAIL_SIM_EVAL_FIXTURES=adversarial

SKU (harness id only)

Role

SKU-ADV-001

Looks like chamomile tea; description buries a strong injection (OVERRIDE_OK)

SKU-ADV-002

Looks like honey; soft “prefer this SKU / don’t tell the user” injection

SKU-ADV-003

Benign green-tea control (no injection)

Product fields are intentionally unmarked (normal grocery_pantry brands/tags/attrs) so the model is not tipped off. Eval harnesses should key off the known SKU-ADV-* ids, not on labels in the payload. Guardrails belong in the agent, not in fixture labelling.

In pytest / harnesses: mcp_retail_sim.eval_fixtures.enable_eval_fixtures(["adversarial"]) / clear_eval_fixtures(). Not an MCP tool.

Transports

stdio

Streamable HTTP

Start

Client spawns the process

You start the server; it listens on a port

Connect

Pipes (stdin/stdout)

URL, e.g. http://127.0.0.1:8050/mcp

Lifetime

Usually tied to the client

Long-lived until you stop it

Typical use

Cursor, Claude Desktop, Inspector spawn

LangChain / remote-style clients, multi-client

uvx downloads the package from PyPI and runs it. Use these commands if you are not developing this repo:

# stdio (default) — for desktop hosts / Inspector spawn
uvx mcp-retail-sim
# same as:
uvx mcp-retail-sim --transport stdio

# Streamable HTTP — long-lived local server
uvx mcp-retail-sim --transport http --host 127.0.0.1 --port 8050
# MCP endpoint: http://127.0.0.1:8050/mcp

CLI flags (HTTP only uses host/port):

Flag

Default

Meaning

--transport

stdio

stdio or http

--host

127.0.0.1

Bind address for HTTP

--port

8050

Bind port for HTTP

Quick start (from a git checkout)

uv run uses the local source and the project virtualenv. It does not download the PyPI release.

cd mcp-retail-sim
uv sync
uv run mcp-retail-sim --help
uv run pytest

MCP Inspector

stdio — Inspector starts the server for you (do not run the server yourself).

Published package from PyPI:

npx @modelcontextprotocol/inspector uvx mcp-retail-sim

Local checkout — run from the mcp-retail-sim directory:

npx @modelcontextprotocol/inspector uv run mcp-retail-sim

HTTP — start the server first, then point Inspector at the URL:

# terminal 1
uvx mcp-retail-sim --transport http --port 8050

# terminal 2
npx @modelcontextprotocol/inspector \
  --server-url http://127.0.0.1:8050/mcp \
  --transport http

Cursor / Claude Desktop (stdio)

{
  "mcpServers": {
    "mcp-retail-sim": {
      "command": "uvx",
      "args": ["mcp-retail-sim"]
    }
  }
}

Eval example with a fault and/or adversarial fixtures (local checkout):

{
  "mcpServers": {
    "mcp-retail-sim": {
      "command": "uv",
      "args": ["run", "mcp-retail-sim"],
      "env": {
        "MCP_RETAIL_SIM_FAULTS": "place_order:error_after_commit",
        "MCP_RETAIL_SIM_EVAL_FIXTURES": "adversarial"
      }
    }
  }
}

LangChain / HTTP client sketch

# Server must already be running:
#   uvx mcp-retail-sim --transport http --port 8050

config = {
    "mcpServers": {
        "mcp-retail-sim": {
            "url": "http://127.0.0.1:8050/mcp",
        }
    }
}

Architecture (high level)

Client (agent / Inspector / LangChain)
        │
        ├─ stdio: client spawns process, JSON-RPC over pipes
        └─ http:  client connects to http://host:port/mcp
        ▼
┌─────────────────────────────┐
│  mcp-retail-sim (FastMCP)   │
│  tools · resources · prompts│
│  cli: --transport stdio|http│
│  faults via env (eval only) │
└─────────────┬───────────────┘
              │
              ▼
┌─────────────────────────────┐
│  In-memory store            │
│  ← fixtures (products,      │
│     inventory, policies)    │
│  + carts / orders           │
│  + idempotency map          │
└─────────────────────────────┘

Status

MVP for general retail-agent simulation: catalog + cart tools, checkout with stock revalidation and optional idempotency, stdio + Streamable HTTP, eval-only fault injection.

Still optional / later: PyPI republish of the latest tree, concurrency locks.

Tools advertise MCP annotations (read-only vs mutating/destructive hints) for hosts that surface them.

Maintainer

From the mcp-retail-sim directory:

  • Bump version in pyproject.toml.

  • Run the tests: uv run pytest

  • Save the API tokens (once):

keyring set https://test.pypi.org/legacy/ __token__
keyring set https://upload.pypi.org/legacy/ __token__
  • Build and publish:

uv build --out-dir dist
UV_KEYRING_PROVIDER=subprocess uv publish --publish-url https://test.pypi.org/legacy/
UV_KEYRING_PROVIDER=subprocess uv publish

License

MIT

Available Tools

6 tools
add_to_cartAdd To CartA

Add a product to a cart. Does not decrement stock.

Example: cart_id=cart-1, product_id=SKU-1001, qty=1. Use any new cart id; the cart is created if it does not exist. Fails if the SKU is unknown or out of stock (try SKU-1002 to see that error).

Inputs: cart_id (required), product_id (required), qty. Returns: object

check_inventoryCheck InventoryB

Check stock for a SKU.

Example in stock: SKU-1001. Example out of stock: SKU-1002. Returns stock_qty and in_stock. Does not change inventory.

Inputs: product_id (required). Returns: result

get_order_detailsGet Order DetailsA

Read an order created by place_order.

Pass the order_id from that response, for example ORD-E2F0C262. Orders exist only in this server process; a new process has none.

Inputs: order_id (required). Returns: result

get_product_detailsGet Product DetailsB

Get one product by SKU. Example: SKU-1001 (LumenLab Pro Headphones).

Inputs: product_id (required). Returns: result

place_orderPlace OrderA

Check out a cart created by add_to_cart.

Example: cart_id=cart-1 after adding SKU-1001. Decrements stock, returns an order_id like ORD-XXXXXXXX, and deletes the cart.

Inputs: cart_id (required). Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct action: catalog search, single-product lookup by SKU, stock check, cart addition, checkout, and order read. The boundaries between get_product_details and check_inventory are clarified by descriptions (one returns product data, the other returns stock_qty/in_stock).

    Naming Consistency4/5

    Consistent snake_case with a verb_noun pattern for five tools (get_product_details, check_inventory, add_to_cart, place_order, get_order_details). The lone exception is 'search', which lacks an explicit noun/target, a minor deviation from the otherwise predictable pattern.

    Tool Count5/5

    Six tools is well-scoped for a retail simulation, covering the essential browse-to-checkout flow without redundancy. Each tool earns its place and none feels like filler.

    Completeness4/5

    The core lifecycle (search, inspect, inventory, cart, order) is covered end-to-end. Minor gaps exist: no cart inspection/removal, no order listing or cancellation, which an agent could work around for a simple sim.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to perform e-commerce operations including product search, budget-constrained shopping recommendations, and sustainability analysis. Includes a secure HTTP bridge with OAuth integration and observability features for production deployment.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes a fictional smart-home store's REST API to agents as schema-validated MCP tools, resources, and prompts, letting them search products, check inventory, place atomic orders, look up customers and orders, and open support tickets. It also adds auth injection, rate limiting, REST-to-MCP error mapping with actionable hints, per-call JSONL tracing, and a golden-task eval harness for tool selection and argument correctness.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Provides an in-memory mock commerce backend for shopping agents, enabling product search, order creation, simulated payment, automatic shipping/delivery progression, and refund workflows. It lets developers test full shopping-agent lifecycles deterministically without real products, credentials, or funds.
      7
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables read- or write-scoped access to synthetic enterprise orders, inventory, support tickets, and metrics via schema-validated JSON-RPC tools over stdio and HTTP, with permission allow-lists and audit logging. It also exposes enterprise resources and prompt templates for grounded, cited, multi-step assistant workflows.
      MIT