# SushiTCG for AI assistants

SushiTCG is a trading card store in Mexico: Pokémon, One Piece and Riftbound
singles, sealed product, accessories and board games. This page documents
how an assistant reads the catalog and builds a shopper's cart.
API version: 1.2.0.

Catalog tools are public and read-only. Cart and order tools act for a
shopper who signed in and allowed the assistant (OAuth); they change the
same cart the website shows. An assistant can place an order, but never pay
it: every order waits for the shopper to pay on its Mercado Pago link.

## Connect

- MCP server (Streamable HTTP, stateless): `https://sushitcg.com/mcp`
- Product feed (Google Merchant Center RSS): `https://sushitcg.com/feeds/google-merchant.xml`
- Card and product pages carry schema.org `Product` and `Offer` data (JSON-LD).

Catalog tools need no sign-in or key. Requests are limited per client
address, or per assistant and shopper with an access token; over the limit
the server answers HTTP 429 with a `retry-after` header.

## Signing a shopper in

Cart tools need an OAuth 2.1 access token with the `cart` scope, and order
tools the `orders` scope, bound to the `https://sushitcg.com/mcp` resource. MCP clients that follow the MCP
authorization spec do this on their own:

1. A cart tool called without a token answers HTTP 401 with
   `WWW-Authenticate: Bearer resource_metadata="..."`, pointing at
   `https://sushitcg.com/.well-known/oauth-protected-resource/mcp`.
2. The authorization server's metadata is at
   `https://sushitcg.com/.well-known/oauth-authorization-server`. Clients register
   with dynamic client registration (`/oauth/register`) or a client ID
   metadata document URL.
3. The shopper signs in to SushiTCG and approves the assistant. The code is
   exchanged at `/oauth/token` with PKCE (S256). Access tokens last an hour;
   refresh tokens rotate.
4. A token without the scope a tool needs gets HTTP 403 `insufficient_scope`,
   naming every scope to ask for.

The shopper sees connected assistants in their account and can disconnect
one at any time. Its next call then answers HTTP 401 `invalid_token`.

## Identifiers

- **Item id**: stable for a card or product. A single card is its game and
  card id, `pokemon:sv10-236`, `one-piece:OP01-001`, `riftbound:ogn-001-298`.
  Anything else is its SKU, `ACC-DS-MATTE-BLK`.
- **Offer SKU**: one card in one condition and printing, `PK-SV10-236-NM`,
  `PK-SV8-247-NM-RH` (reverse holo), `OP-OP01-001-NM-P` (One Piece
  parallel). The feed's
  `g:id`, the `sku` of each JSON-LD offer and the `sku` of each API offer are
  the same value.

Every tool that takes an `id` accepts either one.

## Tools

| Tool | Arguments | Returns |
|---|---|---|
| `search_cards` | `query`, `game`, `kind`, `set`, `condition`, `in_stock_only`, `limit` (all optional) | `count`, `items` |
| `get_card` | `id` | one item |
| `get_price` | `id` | `prices`: the store's current price per condition in stock |
| `check_stock` | `id`, `condition` (optional) | `in_stock`, `total_available`, `stock` per condition |
| `get_cart` | none (signed in) | `lines` (`sku`, `name`, `condition`, `quantity`, `price`, `currency`, `charge_price`, `charge_currency`), `item_count`, `total`, `shipping_options`, `checkout_url` |
| `add_to_cart` | `sku`, `quantity` (1 to 20, default 1) (signed in) | the updated cart |
| `remove_from_cart` | `sku` (signed in) | the updated cart |
| `preview_checkout` | `delivery_method` (`delivery` or `pickup`) (cart) | `lines`, `subtotal`, `shipping`, `tax`, `total`, `order_limit`, `within_limit`, `return_policy_url` |
| `place_order` | `delivery_method`, `expected_total`, `idempotency_key`, `shipping_address` (orders) | the order with its `payment_url` and `payment_expires_at` |
| `order_status` | `order_id` (orders) | `status`, `lines`, `shipping`, `total`, `payment_url` while unpaid, `tracking` |
| `cancel_order` | `order_id` (orders) | the cancelled order; only unpaid orders this assistant placed |
| `get_shipping_options` | none |""")
s = rep.(s, "| `rate_limited` | HTTP 429", """
| `cart_empty` | There is nothing to check out. |
| `price_changed` | The total is no longer `expected_total`. Nothing was placed; preview again and confirm with the shopper. |
| `over_limit` | The order is above the per-order limit the shopper set for this assistant. Nothing was placed. |
| `shipping_unavailable` | The store doesn't offer that delivery method now. |
| `order_cancelled` | The order placed with this `idempotency_key` was cancelled or lapsed unpaid. Use a new key. |
| `too_many_pending` | The shopper already has 3 unpaid orders from assistants. Pay or cancel one first. |
| `not_cancellable` | The order is paid, or another assistant placed it. |
| `unavailable` | Payments or the cart couldn't be reached. Retry with the same `idempotency_key`. |
| `rate_limited` | HTTP 429""")
s = rep.(s, "## Errors
", """
## Placing an order

1. `preview_checkout` and show the shopper the total and lines.
2. `place_order` with that total as `expected_total` and a new
   `idempotency_key`. A retry with the same key returns the same order.
3. Give the shopper the `payment_url`. The order holds its copies until
   `payment_expires_at`; unpaid, it is cancelled and they go back on sale.
4. Follow it with `order_status`. Prices include tax. Returns follow
   `return_policy_url`.

## Errors
 `options`: `method` (`delivery`, `pickup`), `name`, `cost`, `currency`, and `pickup_address`/`pickup_hours` for pickup |

`query` reads a name (`Regidrago VSTAR`), a card id (`sv10-236`), a set and
number (`SV10 236`) or a name and number (`Pikachu 25`). `game` is `pokemon`,
`one-piece` or `riftbound`. `kind` is `single`, `sealed`, `accessory` or
`board_game`. `condition` is `nm`, `lp`, `mp`, `hp`, `dmg` or `sealed`.
`limit` goes up to 25. Items in stock come first.

### An item

```json
{
  "id": "pokemon:swsh12-136",
  "kind": "single",
  "game": "pokemon",
  "name": "Regidrago VSTAR",
  "set": {"id": "swsh12", "name": "Silver Tempest"},
  "number": "136",
  "rarity": "Rare Holo VSTAR",
  "image": "https://...",
  "url": "https://sushitcg.com/pokemon_tcg/card/swsh12-136",
  "in_stock": true,
  "offers": [
    {
      "sku": "PK-SWSH12-136-NM",
      "condition": "nm",
      "condition_name": "Near Mint",
      "printing": null,
      "printing_name": null,
      "price": {"amount": "3.50", "currency": "USD"},
      "charge_price": {"amount": "65.00", "currency": "MXN"},
      "quantity_available": 2
    }
  ]
}
```

- An offer exists only while copies can be bought. `quantity_available`
  leaves out copies held in other shoppers' carts, so it can change between
  calls.
- `price` is the listed price. `charge_price` is the same price in MXN, the
  currency the store charges, at the store's current rate; it is `null` when
  no current rate is available.
- `printing` is `null` for a card's main printing. Pokémon: `reverse_holofoil`,
  `first_edition_holofoil`, `first_edition_normal`. One Piece: `parallel`,
  `alt_art`, `manga`. `printing_name` is the same in words. An item's name,
  image and number are its main printing's.
- Card language is not tracked yet and is not reported.

## Errors

A tool that cannot answer returns `isError: true` and
`{"error": {"code": "...", "message": "..."}}`:

| Code | Meaning |
|---|---|
| `not_found` | No card or product has that id or SKU. |
| `invalid_argument` | An argument is missing or has a value the tool does not take. The message names it. |
| `insufficient_stock` | Fewer copies are free than asked for. Nothing was added. |
| `sold_out` | No copy is free. |
| `line_limit` | The cart already holds as many copies of this card as one shopper may. |
| `hold_limit` | The shopper holds too many copies across the cart. |
| `rate_limited` | HTTP 429, outside the tool result. Wait `retry_after_seconds`. |

Protocol errors (unknown method, unknown tool) are JSON-RPC errors. Send one
JSON-RPC message per request; batches are refused.
