Skip to main content
Glama

Оформление и оплата заказа

grocery_checkout
Destructive

Finalizes grocery orders from a cart, validates delivery, places the order, and charges the confirmed total; preview mode returns the final amount before payment.

Instructions

Полный чекаут: доставка → заказ → оплата. РЕАЛЬНЫЕ ДЕНЬГИ. app_id/point_id — из grocery_stores() (обязательны, тот же магазин что в корзине). Клиент с элиситацией: если expected_sum не передан, тул сам сделает предпросмотр, покажет кнопки с финальной суммой и оформит заказ на неё — dry_run не нужен.

dry_run=True — ПРЕДПРОСМОТР: доводит до доставки и возвращает финальную сумму, НЕ создавая заказ и НЕ списывая деньги. Вызывай его ВСЕГДА перед оплатой: только бэкенд знает, во что пересчитаются весовые товары, и только магазин знает, отдаёт ли он сейчас слот доставки. Сумму из предпросмотра показывай пользователю и её же передавай в expected_sum — тогда оплата проходит с первой попытки.

СЧЁТ СПИСАНИЯ по умолчанию — тот, которым пользователь последний раз платил за продукты В ПРИЛОЖЕНИИ (банк отдаёт его сам), а НЕ первый счёт с балансом. Хочешь другой — передай account_id из list_accounts(). Списанный счёт печатается в ответе.

expected_sum — сумма, которую подтвердил пользователь. Передавай её ВСЕГДА и РОВНО как есть, до копейки (3700.63, не 3700): сравнение точное, допуск 0.01 ₽. Без неё (и без элиситации) чекаут НЕ списывает деньги: он вернёт предпросмотр и попросит повторить с expected_sum. Банк дважды пересчитывает корзину уже ПОСЛЕ подтверждения (веб-корзина, затем доставка); расхождение отменяет чекаут ДО создания заказа.

При неопределённом результате (заказ мог создаться) повтор БЛОКИРУЕТСЯ — сначала grocery_attempts() и проверь заказ в приложении. force=True — только если пользователь ЯВНО подтвердил, что прошлого заказа нет. Всегда показывай состав и сумму и жди явного подтверждения перед вызовом.

Реализация: тул асинхронный и запускает браузер Playwright в отдельном worker-потоке (asyncio.to_thread) — sync_playwright падает, если звать его внутри event-loop, а FastMCP крутит sync-тулы именно в loop. Если тул падает с Playwright-ошибкой — проверь python -m playwright install chromium (в окружении MCP).

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "grocery_checkout"
  }
}

Input Schema

NameRequiredDescriptionDefault
forceNo
app_idNo
dry_runNo
point_idNo
account_idNo
expected_sumNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.2

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond destructiveHint/openWorldHint/idempotentHint=false, it discloses that real money is debited, which account is charged by default (last-used grocery account, not first with balance), the single 0.01 ₽ tolerance on exact sum comparison, that the bank recalculates twice after confirmation and aborts before order creation, and that repeats are blocked after an indeterminate result. This is substantive behavior the annotations cannot convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Critical information (real money, always preview first, exact sum) is front-loaded and organized into short labeled blocks. The closing Playwright/asyncio worker-thread paragraph is operationally useful for debugging but tangential to tool selection and lengthens the definition noticeably.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive, open-world payment tool with an output schema present, the description covers prerequisites, failure modes, retry policy, and where results surface (the charged account is printed in the response). Nothing an agent needs to invoke it safely is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, yet the description accounts for all six parameters: app_id/point_id sourced from grocery_stores() and required to match the cart store, account_id from list_accounts() with an explicit default, dry_run preview semantics, expected_sum exactness, and force preconditions. That fully compensates for the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening line states a specific verb chain and resource scope ('Полный чекаут: доставка → заказ → оплата') and flags the stakes with 'РЕАЛЬНЫЕ ДЕНЬГИ', so the agent knows this is the money-moving tool. It does not explicitly contrast itself with the likely sibling grocery_plan_order, so differentiation is implied rather than stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives explicit routing rules: always run dry_run=True before payment, pass expected_sum exactly, use force=True only on explicit user confirmation, and stop-and-check via grocery_attempts() when the prior result is unknown. It also states the when-not condition (checkout will not charge without expected_sum outside elicitation).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.