Skip to main content
Glama
Pyaterochka MCP Tool

Pyaterochka MCP Tool

πŸ›’ Pyaterochka MCP Tool

MCP server and AI bot for the Pyaterochka catalog β€” search for stores, products, promotions, and prices across Russia right from your neural network.

Python MCP Telegram License


✨ What this is

The project turns the public catalog of 5ka.ru into tools for LLMs:

Component

What it does

🧩 MCP stdio server

Connects to Claude Desktop, Cursor, opencode, and any MCP client

🌐 HTTP MCP server

The same set of tools at http://127.0.0.1:8765/mcp (Streamable HTTP) β€” convenient for remote MCP via a tunnel

πŸ€– AI Telegram bot

A full-fledged agent: finds a store on its own, searches for products, shows photos and prices, remembers your preferences

Capabilities:

  • πŸ” find a physical store by address or geolocation;

  • πŸ—‚οΈ get categories of a specific store;

  • πŸ›’ search products with filters: price (min/max), brand, promotions only;

  • πŸ“Š sort by price / discount size / popularity;

  • πŸ’³ show the card price, "buy N items" promotions, the old price;

  • πŸ“‹ return availability, stock, nutritional values, ingredients, PLU, and a product link;

  • πŸ“Έ send a photo album of found products in Telegram.

⚠️ The project is unofficial and not affiliated with X5 Group. It uses the open web catalog without login or password. For educational purposes only.


Related MCP server: supermercado

πŸ—οΈ Architecture

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Claude / Cursor /  β”‚
                    β”‚  ChatGPT / Telegram  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                                 β”‚
     MCP stdio / HTTP MCP                OpenAI-compatible API
              β”‚                                 β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   mcp/mcp_server  β”‚             β”‚    llm_client     β”‚
    β”‚  + mcp_http_serverβ”‚             β”‚ (фолбэк ΠΌΠ΅ΠΆΠ΄Ρƒ     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚  ΠΏΡ€ΠΎΠ²Π°ΠΉΠ΄Π΅Ρ€Π°ΠΌΠΈ)    β”‚
              β”‚                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                 pyaterochka_store_api                 β”‚
    β”‚   Π±Ρ€Π°ΡƒΠ·Π΅Ρ€ Camoufox  Π˜Π›Π˜  aiohttp + cookies.json       β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                        🌐 5d.5ka.ru API

πŸš€ Quick start

1. Installation

git clone https://github.com/<you>/pyaterochka-mcp-tool.git
cd pyaterochka-mcp-tool

python -m venv .venv
# Windows:
.venv\Scripts\activate
# Linux/macOS:
source .venv/bin/activate

pip install -r requirements.txt

It works without it too β€” via cookies (see below). With it, cookies are not needed at all:

pip install "camoufox[geoip]"
python -m camoufox fetch   # ΠΎΠ΄ΠΈΠ½ Ρ€Π°Π· ΡΠΊΠ°Ρ‡Π°Ρ‚ΡŒ Π±Ρ€Π°ΡƒΠ·Π΅Ρ€ (~150 ΠœΠ‘)

2. Setting up .env

cp .env.example .env

The minimum for the MCP server to work is nothing (only cookies, if you didn't install camoufox). The minimum for the bot:

TELEGRAM_BOT_TOKEN=123456:AA...      # ΠΎΡ‚ @BotFather
LLM_API_URL=https://api.openai.com/v1
LLM_API_KEY=sk-...
LLM_MODEL=gpt-4o-mini

Any OpenAI-compatible provider will work: OpenAI, OpenRouter, Groq, DeepSeek, NVIDIA NIM, Together AI, local vLLM/Ollama (http://localhost:11434/v1).

Variable

Default

Description

TELEGRAM_BOT_TOKEN

β€”

Bot token from @BotFather (required for the bot)

TELEGRAM_API_BASE_URL

https://api.telegram.org

You can specify a local Telegram Bot API Server β€” then response streaming is enabled

TELEGRAM_PROXY_SOCKS5

β€”

SOCKS5 proxy for Telegram

LLM_API_URL

https://api.openai.com/v1

Main LLM (OpenAI-compatible /v1)

LLM_API_KEY

β€”

Main LLM key

LLM_MODEL

gpt-4o-mini

Main provider model

LLM_RESERVE_URL/_KEY/_MODEL

β€”

Reserve #1 (auto-fallback on failures/429/5xx)

LLM_FALLBACK_URL/_KEY/_MODEL

β€”

Reserve #2 (last line of defense)

OPENAI_API_KEY, OPENROUTER_API_KEY, GROQ_API_KEY, …

β€”

Keys for the inline /model menu in the bot

PYATEROCHKA_COOKIES_FILE

β€”

Path to cookies.json (if no browser mode)

PYATEROCHKA_PROXY

β€”

SOCKS5 proxy for requests to 5ka.ru

MCP_HOST / MCP_PORT

127.0.0.1 / 8765

HTTP MCP server address

πŸ‡·πŸ‡Ί For users in Russia: if the official api.telegram.org is unavailable, you can use a public Telegram Bot API mirror β€” just add to .env:

TELEGRAM_API_BASE_URL=https://telegram.ebalo.lol

🧩 Running the MCP server

Option A: stdio (for desktop clients)

No need to run anything manually β€” the client starts the process itself. Add the server to the client config:

Claude Desktop β€” claude_desktop_config.json:

{
  "mcpServers": {
    "pyaterochka": {
      "command": "python",
      "args": ["C:/absolute/path/to/pyaterochka-mcp-tool/mcp/mcp_server.py"],
      "env": {
        "PYATEROCHKA_COOKIES_FILE": "C:/secrets/pyaterochka/cookies.json"
      }
    }
  }
}

Cursor / any client with mcpServers β€” the format is the same.

You can check manually like this:

python mcp/mcp_server.py          # ΡΠ»ΡƒΡˆΠ°Π΅Ρ‚ JSON-RPC Π² stdin/stdout
# или послС pip install -e . :
pyaterochka-mcp

Option B: HTTP (Streamable HTTP)

python mcp_http_server.py         # β†’ http://127.0.0.1:8765/mcp

Endpoints: POST /mcp (JSON-RPC), GET /health, GET / (info + list of tools).

Example request:

curl -X POST http://127.0.0.1:8765/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"find_store","arguments":{"address":"Москва, ΠšΠΈΡ€ΠΎΠ²ΠΎΠ³Ρ€Π°Π΄ΡΠΊΠ°Ρ ΡƒΠ»ΠΈΡ†Π°, 17"}}}'

🧰 Available tools (12)

Tool

Description

find_store

Find a store by address β†’ store_id

find_nearest_stores

Nearest stores by coordinates

get_store_info / get_store_hours

Store card and opening hours

list_stores_in_area

Stores in a rectangular map area

list_store_categories

Store category tree

search_products

Product search: price, brand, promotions, sorting

list_category_products

Category products with filters

find_products

Universal search by address or store_id

get_product_promotion

Promotion terms for a product

get_product_info

Product card: ingredients, calories, nutritional values

refresh_session

Refresh the 5ka.ru web session

More details in mcp/README.md.


πŸ€– Running the Telegram bot

python bot.py      # Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π±ΠΎΡ‚
python run.py      # Π±ΠΎΡ‚ + HTTP MCP-сСрвСр вмСстС (ΠΆΠΈΠ²ΠΎΠΉ Π²Ρ‹Π²ΠΎΠ΄ Π² консоль)

How to use:

  1. /start β†’ send the bot your geolocation (paperclip β†’ πŸ“ Location) or type an address;

  2. choose your favorite store with the buttons;

  3. ask: "find milk under 100 β‚½", "what's on sale for coffee?", "opening hours?";

  4. commands: /reset β€” reset memory, /stop β€” interrupt execution, /model β€” switch models on the fly.

The bot behaves like an agent: it calls tools in a chain on its own (find store β†’ search products β†’ check promotions β†’ show photos and the summary).


πŸͺ Cookies: are they needed and why

There are two transports for accessing the catalog β€” pick one:

🦊 Browser mode (camoufox)

πŸ“„ aiohttp + cookies.json

Manual cookies

❌ not needed

βœ… needed

Reliability against 403/anti-bot

higher

lower

Dependencies

heavy (~150 MB browser)

light

How to get cookies.json (for the second option):

  1. Open 5ka.ru in Chrome/Firefox β€” no login needed, just open the site;

  2. Export cookies with an extension like Get cookies.txt LOCALLY (JSON or Netscape format);

  3. Save the file outside the repository, e.g. C:\secrets\pyaterochka\cookies.json;

  4. Specify the path: PYATEROCHKA_COOKIES_FILE=C:\secrets\pyaterochka\cookies.json.

On startup, the client first opens 5ka.ru to accept fresh protective cookies (spjs/spsc and others), then updates them automatically.

πŸ” Never publish cookies.json β€” it's your live web session. The file is already added to .gitignore. If it leaks β€” clear the cookies on the site.


🌍 Public access: connecting ChatGPT / Claude via a tunnel

The HTTP MCP server listens on 127.0.0.1:8765 β€” for external neural networks (ChatGPT, Claude, and any clients with remote MCP support) to reach it, wrap the port in a tunnel:

ngrok:

ngrok http 8765
# ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚Π΅ адрСс Π²ΠΈΠ΄Π° https://a1b2-...ngrok-free.app

cloudflared (no registration):

cloudflared tunnel --url http://localhost:8765
# ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚Π΅ адрСс Π²ΠΈΠ΄Π° https://....trycloudflare.com

Then add the URL to the client:

Client

Where to specify

Claude Desktop / Claude Web

Settings β†’ Connectors β†’ Add custom connector β†’ https://your-address/mcp

ChatGPT

Settings β†’ Apps & Connectors β†’ Create (Developer Mode) β†’ URL https://your-address/mcp

Cursor

MCP settings β†’ Add server β†’ URL/SSE type

MCP Inspector

npx @modelcontextprotocol/inspector, transport: URL

⚠️ Security: the endpoint is public and without authentication β€” anyone who learns the address can use your tools. For permanent use, protect the tunnel with basic authentication on a reverse proxy or use ngrok with IP restrictions. SSH tunnels/keys are deliberately not included in the project code.


πŸ’‘ Example queries

Найди Π² ΠŸΡΡ‚Ρ‘Ρ€ΠΎΡ‡ΠΊΠ΅ ΠΏΠΎ адрСсу Москва, ΠšΠΈΡ€ΠΎΠ²ΠΎΠ³Ρ€Π°Π΄ΡΠΊΠ°Ρ ΡƒΠ»ΠΈΡ†Π°, 17
ΠΌΠΎΠ»ΠΎΠΊΠΎ дСшСвлС 200 Ρ€ΡƒΠ±Π»Π΅ΠΉ ΠΈ отсортируй ΠΏΠΎ Ρ†Π΅Π½Π΅.
Π§Ρ‚ΠΎ ΠΈΠ· ΠΊΠΎΡ„Π΅ сСйчас ΠΏΠΎ Π°ΠΊΡ†ΠΈΠΈ рядом со ΠΌΠ½ΠΎΠΉ? ΠŸΡ€ΠΈΡˆΠ»ΠΈ Ρ„ΠΎΡ‚ΠΎ Ρ‚ΠΎΠΏ-5.

Via CLI (without a neural network):

python pyaterochka_store_api.py resolve --address "Москва, ΠšΠΈΡ€ΠΎΠ²ΠΎΠ³Ρ€Π°Π΄ΡΠΊΠ°Ρ ΡƒΠ»ΠΈΡ†Π°, 17"
python pyaterochka_store_api.py products --address "Москва, ΠšΠΈΡ€ΠΎΠ²ΠΎΠ³Ρ€Π°Π΄ΡΠΊΠ°Ρ ΡƒΠ»ΠΈΡ†Π°, 17" \
    --store-id S105 --query "ΠΌΠΎΠ»ΠΎΠΊΠΎ" --price-max 200 --sort price_asc --limit 20

πŸ“ Project structure

pyaterochka-mcp-tool/
β”œβ”€β”€ mcp/
β”‚   β”œβ”€β”€ mcp_server.py        # MCP stdio-сСрвСр (12 инструмСнтов)
β”‚   └── README.md            # Π΄Π΅Ρ‚Π°Π»ΠΈ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΡ MCP-ΠΊΠ»ΠΈΠ΅Π½Ρ‚ΠΎΠ²
β”œβ”€β”€ mcp_http_server.py       # HTTP (Streamable HTTP) транспорт MCP
β”œβ”€β”€ pyaterochka_store_api.py # API-слой ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π° 5ka.ru (+CLI)
β”œβ”€β”€ bot.py                   # Telegram-Π±ΠΎΡ‚ (aiogram)
β”œβ”€β”€ run.py                   # Π±ΠΎΡ‚ + HTTP MCP ΠΎΠ΄Π½ΠΈΠΌ процСссом
β”œβ”€β”€ agent.py                 # агСнтский Ρ†ΠΈΠΊΠ»: LLM ↔ инструмСнты
β”œβ”€β”€ llm_client.py            # OpenAI-совмСстимый ΠΊΠ»ΠΈΠ΅Π½Ρ‚ с фолбэком
β”œβ”€β”€ providers.py             # ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ LLM-ΠΏΡ€ΠΎΠ²Π°ΠΉΠ΄Π΅Ρ€ΠΎΠ² для /model
β”œβ”€β”€ config.py                # ΠΊΠΎΠ½Ρ„ΠΈΠ³ ΠΈΠ· ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Ρ… окруТСния
β”œβ”€β”€ stats.py / live_timer.py # статистика ΠΈ ΠΊΠΎΠ½ΡΠΎΠ»ΡŒΠ½Ρ‹Π΅ ΡƒΠΊΡ€Π°ΡˆΠ΅Π½ΠΈΡ
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ pyproject.toml
└── .env.example

πŸ›‘οΈ Security

  • All keys and tokens β€” only via .env (never gets into git).

  • cookies.json, sessions.json, logs β€” in .gitignore.

  • Model responses never contain internal ids (sap_code, PLU).

  • Don't publish cookies, proxies, or tokens β€” see the Cookies section.

βš–οΈ License

MIT. The project is not affiliated with X5 Group (Pyaterochka); all trademarks belong to their owners.

Available Tools

12 tools
find_nearest_storesB

Find nearby Pyaterochka stores by coordinates, sorted by distance.

Inputs: latitude (required), longitude (required), limit.

find_productsC

Find products by store_id or address, resolving the nearest store when needed.

Inputs: query (required), sort, brand, limit, +6 more.

find_storeB

Find the nearest Pyaterochka store for a full address and return its store_id.

Inputs: address (required).

get_product_infoB

Get product details by PLU, including ingredients, calories, nutrients and URL.

Inputs: plu (required), store_id (required).

get_product_promotionB

Get promotion details for a product PLU in a store.

Inputs: plu (required), store_id (required).

get_store_hoursB

Get opening hours and 24-hour status for a store by store_id.

Inputs: store_id (required).

get_store_infoB

Get store details by store_id, including address, opening hours, metro and coordinates.

Inputs: store_id (required).

list_category_productsC

List products in a store category and apply filters.

Inputs: store_id (required), category_id (required), sort, brand, +5 more.

list_store_categoriesC

Get the category tree for a store.

Inputs: store_id (required).

list_stores_in_areaC

List Pyaterochka stores inside a rectangular map area.

Inputs: top_latitude (required), left_longitude (required), bottom_latitude (required), right_longitude (required).

refresh_sessionB

Refresh the protective cookies for the current 5ka.ru web session.

Inputs: no named parameters.

search_productsC

Search products in a store and apply price, brand, promotion and sorting filters.

Inputs: query (required), store_id (required), sort, brand, +5 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 12 tools

    Disambiguation3/5

    Several tools overlap in purpose: find_store, find_nearest_stores, and list_stores_in_area all retrieve store locations but with different inputs, while get_store_info and get_store_hours both provide hours (though get_store_info is more comprehensive). Similarly, search_products, list_category_products, and find_products all search products with overlapping filters, which could cause misselection. The descriptions help but are not always enough to clearly distinguish the best tool.

    Naming Consistency2/5

    Tool names use a mix of verbs (refresh, find, get, list, search) without a consistent convention. Some are find_* (e.g., find_store, find_nearest_stores), some get_* (get_store_info, get_store_hours), some list_* (list_stores_in_area, list_store_categories), and some search_* (search_products). This mixed style makes it harder to predict tool names from intent, though the noun part is generally clear.

    Tool Count5/5

    With 12 tools covering store lookup, store details, product search, categories, promotions, and session management, the count is well-scoped for the domain. Each tool has a distinct role, and there are enough tools to represent the core API surface without being overwhelming.

    Completeness4/5

    The tool set covers the typical read-only operations for a grocery store API: finding stores, retrieving store info, searching products, filtering by category and promotion, and getting product details. Minor gaps exist (e.g., no tool for store reviews or a direct list-all-products endpoint), but the main workflows users would expect are well covered.

    Maintenance

    ActivityStale
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      B
      maintenance
      Provides MCP tools to search products, check stock, and retrieve store information from the GTA7 Lab supermarket entity.
      -
    • A
      license
      B
      quality
      C
      maintenance
      Enables LLM-driven interaction with the GLOBUS online store, including product search, catalog browsing, product details, promotions, recommendations, and anonymous shopping cart management via MCP.
      22
      MIT