atb-mcp
# atb-mcp
Unofficial **Model Context Protocol (MCP)** server for **ATB Market** (Ukraine), powered by [`atb-api`](https://github.com/ArturLys/atb-api). Gives Claude and other AI assistants fast search across ATB stores, normalized UAH/kg unit prices, promo campaigns, cart management, pickup slot previews, and order history using pure HTTP (~40 MB RAM).
> **Educational & Community Wrapper**
> Built as an unofficial integration over ATB's mobile APIs (`curl_cffi` TLS impersonation + OIDC PKCE). Upstream API changes or Cloudflare rule updates can break calls at any time; tools surface explicit HTTP/auth errors gracefully. Pickup checkout (`submit_pickup_order`) and cancellation (`cancel_order`) default to staging/preview (`confirm_purchase=False`) and refuse to mutate real orders without explicit confirmation flags.
## Tools
| Tool | Purpose | Auth Required |
|---|---|---|
| `search_products` | Search ATB inventory via multisearch with price, UAH/kg or UAH/L unit cost, badges, and stock (`md`, `html`, `json`) | No (`shop_id` needed) |
| `search_multi` | Search up to 20 items concurrently in one call for cross-store price comparison | No (`shop_id` needed) |
| `browse_categories` | Inspect ATB's category tree or list items inside a category with ATB Card prices | No (`city_id` + `shop_id`) |
| `get_product` | Fetch extended item info (`inStockQuantity`, `cardPrice`, old/new price, unit text) | No |
| `get_promos` | List active ATB promotional campaigns for a store | No |
| `find_shops` | Search ATB stores by city/street or list pickup shops in a `city_id` | No |
| `set_pickup_shop` | Pin `city_id` / `shop_id` locally and sync active server self-pickup location | Yes (for server sync) |
| `manage_cart` | View, add, update (`quantity=0` removes), or clear the live ATB shopping cart | Yes |
| `preview_checkout_and_slots` | Preview cart checkout metadata (`if_no_product`, `cash` paymethod), profile readiness, and slots | Yes |
| `submit_pickup_order` | Stage or submit ATB store pickup (`paymethod="cash"` / `Оплата в магазині`) behind `confirm_purchase=True` | Yes |
| `get_orders_and_receipts` | Read active/completed orders (with Ukrainian status labels + pickup codes) and e-receipts | Yes |
| `cancel_order` | Inspect ATB cancel reasons or cancel an order behind `confirm_cancel=True` | Yes |
## Quick Setup
### 1. Install
```bash
pip install git+https://github.com/ArturLys/atb-mcp.git
```
### 2. Configure Claude / MCP Client
```json
{
"mcpServers": {
"atb": {
"command": "atb-mcp",
"env": {
"ATB_CITY_ID": "433",
"ATB_SHOP_ID": "1679"
}
}
}
}
```
### 3. Optional Login (for live cart, pickup slots, and orders)
Find your store with `atb shops --city ...`, then log in once via SMS OTP:
```bash
atb set-shop --city-id <CITY_ID> --shop-id <SHOP_ID>
atb login --phone +380XXXXXXXXX
```
Tokens stay locally in `~/.config/atb/session.json`.
TDQS
Scored across 12 tools
Most tools target clearly different resources or lifecycle steps, such as cart management versus checkout preview versus order cancellation. The main overlap is between search_products and search_multi, where single-item versus batch search could be confused, though the descriptions make the distinction reasonably clear.
The set uses snake_case and mostly follows a verb_noun pattern, making names predictable overall. Minor deviations like search_multi (which omits the searched object) and compound names such as get_orders_and_receipts are still readable but keep it from perfect consistency.
Twelve tools is well-scoped for a grocery-store shopping MCP server. The surface is broad enough to cover search, stores, cart, checkout, and orders without feeling bloated.
The lifecycle is largely covered: product discovery, store/pickup setup, cart management, checkout preview, order submission, receipts, and cancellation. Minor gaps exist around explicit account/profile management and more granular payment/slot inspection outside the checkout preview, but core workflows are supported.