Skip to main content
Glama
dreamcatchered

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: E-Commerce MCP Server

🏗️ 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 Desktopclaude_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 connectorhttps://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.

Install Server
A
license - permissive license
C
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • 100+ MCP tools for AI agents: content metadata, trade intelligence, business-expertise analysis.

  • Pocket Agent (aipocketagent.com) MCP server — read tools for personas, apps, and product info.

  • Connect e-commerce and marketing data to AI assistants via MCP.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dreamcatchered/pyaterochka-mcp-tool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server