tbank
# T-Bank Mobile Agent
**T-Bank (Т-Банк) Mobile Agent** — mobile-only banking API & MCP server, interactive hidden-input login CLI, synchronous Python MCP client, and optional private HTTP adapter for Claude Code, Codex, ChatGPT, and other MCP-capable agents.
Based on [icyberdeveloper/tbank-mcp](https://github.com/icyberdeveloper/tbank-mcp) (MIT License), packaged without any web/browser CLI or Telegram bot dependencies.
## Features
- **78 tools**: accounts, cards, documents, operations, grocery ordering, cinema and
concert tickets, orders, transfers (including payment by bank requisites, from a
scanned invoice QR), messenger, investments
- **11 skills**, entered through the `tbank` router skill: grocery order, tickets,
travel search, transfer, bill pay, cards & documents, messenger, budget analysis,
invest advisor, login
- **Interactive hidden-input CLI login** (`tbank-mobile-login` and `login_cli.py`):
phone, SMS code, password, and PIN stay OUT of shell history and LLM context
- **Synchronous MCP host** (`tbank_mobile.mcp_client`): isolated subprocess environment
and native fail-closed MCP elicitation for all monetary actions
- **Optional private HTTP adapter** (`tbank-mobile-server` + `Dockerfile` / `docker-compose.yml`):
bearer-authenticated REST endpoints (`/healthz`, `/v1/auth/status`, `/v1/accounts`,
`/v1/operations`, `/v1/transfers/prepare`, `/v1/transfers/confirm`, `/v1/transfers/cancel`)
- **Pinned CA trust**: system store + the Russian Trusted Root CA (Минцифры), which no
OS ships and every `*.t-bank-app.ru` host needs — that is most of the 22 hosts this
MCP talks to. Shipped in `ca/roots/`, pinned by SHA-256. Leaf/intermediate rotation
needs no action; a root rotation is a PEM drop into `ca/roots/` (or `TBANK_EXTRA_CA`).
Certificates are never learned from the network — see the header of `src/tls.py`.
- **Grocery checkout**: search → cart → order → pay (optional Playwright extra)
## Quick Install
### As a Claude Code plugin (server + all 11 skills in one step)
```bash
/plugin marketplace add mishanaer/tbank-mobile-agent
/plugin install tbank@tbank-mobile-agent
/reload-plugins
```
The venv and the Python dependencies are created on the server's first start by
`bin/tbank-mcp`. Only the optional grocery checkout needs a browser — install it
yourself if you want that flow:
```bash
pip install -e ".[checkout]"
python -m playwright install chromium
```
### Manually (clone, no plugin)
```bash
git clone https://github.com/mishanaer/tbank-mobile-agent.git
cd tbank-mobile-agent
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
# 1. Interactive hidden-input login (phone, SMS, password/PIN never hit shell history):
tbank-mobile-login
# 2. Connect as an MCP server:
claude mcp add tbank -- ./.venv/bin/python -m src.server
# 3. Optional skills copy:
cp -r skills/* ~/.claude/skills/
```
### Optional private HTTP adapter (Docker or local)
```bash
export TBANK_SERVER_TOKEN="$(openssl rand -hex 32)"
tbank-mobile-server
# Listens on 127.0.0.1:8081 by default
```
Or with Docker Compose:
```bash
TBANK_SERVER_TOKEN="$(openssl rand -hex 32)" docker compose up -d --build
```
## 🔒 Login — secrets never reach the agent
The phone number, SMS code, password, and PIN are **not put into the model's context**.
### Option 1 (recommended): hidden-input TTY login
```bash
tbank-mobile-login
# Телефон (+7XXXXXXXXXX, ввод скрыт):
# Код из SMS (ввод скрыт):
# Пароль аккаунта (ввод скрыт):
```
Or use the upstream script directly:
```bash
.venv/bin/python login_cli.py +7XXXXXXXXXX
```
Both save the session to `~/.local/share/tbank-mcp/session.json` (mode `0600`,
override via `TBANK_SESSION`), which the MCP server and HTTP adapter read automatically.
### Option 2: through the agent (convenient, but the LLM sees the credentials)
```
> login(+7XXXXXXXXXX)
> confirm_otp("1234")
> confirm_password("YourPassword")
```
⚠️ **Note:** the password ends up in the model's context and in call logs. For an
account you care about, use Option 1.
## Other agents (Codex, ChatGPT, Hermes, OpenClaw)
```jsonc
{
"mcpServers": {
"tbank": {
"command": "/path/to/tbank-mcp/.venv/bin/python",
"args": ["-m", "src.server"],
"cwd": "/path/to/tbank-mcp"
}
}
}
```
## Tools
Each tool's docstring is the reference — this table is only a map of the surface.
The docstrings, the skills and everything the tools print are in Russian: the bank is
Russian and so is the person reading the answer.
| Group | Tools |
|---|---|
| **Login** | `login`, `confirm_otp`, `confirm_password`, `confirm_pin` |
| **Session** | `refresh_session`, `session_status`, `keepalive`, `push_unread_count` |
| **Reads** | `list_accounts`, `list_operations`, `spending_categories`, `operations_histogram`, `get_data` |
| **Cards & accounts** | `list_cards`, `card_limits`, `card_requisites`, `card_operations`, `account_requisites` |
| **Documents** | `documents`, `bank_documents`, `insurance_policies`, `payment_receipt` |
| **Grocery** | `grocery_stores`, `grocery_search`, `grocery_plan_order`, `grocery_add_to_cart`, `grocery_set_cart`, `grocery_cart`, `grocery_checkout`, `grocery_attempts`, `grocery_order_status`, `grocery_order_cancel` |
| **Nutrition** | `grocery_good_info`, `grocery_rank` |
| **Orders** | `orders`, `order_details`, `travel_order_details` |
| **Afisha** | `afisha_catalog`, `afisha_places`, `place_schedule`, `place_info` |
| **Tickets** | `cinema_search`, `cinema_schedule`, `cinema_seats`, `concert_schedule`, `concert_hall`, `cinema_book`, `ticket_pay`, `ticket_cancel`, `ticket_qr` |
| **Search** | `search_app` |
| **Travel search** | `train_search`, `train_calendar`, `flight_search`, `flight_history` |
| **Marketplace** | `shop_search`, `shop_cart` |
| **Messenger** | `messenger_conversations`, `messenger_messages`, `messenger_file`, `messenger_send`, `messenger_unread` |
| **Money** | `transfer_sbp_resolve`, `transfer`, `payment_qr`, `transfer_requisites`, `payment_commission`, `pay_bill`, `payment_providers`, `confirm_payment`, `payment_status` |
| **Invest** | `invest_accounts`, `invest_portfolio`, `invest_operations`, `invest_securities` |
| **Utility** | `flows`, `diagnostics`, `debug_report` |
`get_data(section)` covers 40 sections: subscriptions, credit_schedule, statements, loans, invest_accounts, pension, etc. (`invest_portfolio` is a tool of its own, not a section — see the docstring for the full list.)
Grocery tools (`grocery_search`, `grocery_plan_order`, `grocery_add_to_cart`, `grocery_set_cart`, `grocery_cart`, `grocery_checkout`) require `app_id` + `point_id` taken from `grocery_stores()` — there's no silent default store, so add/cart/checkout always operate on the same cart, instead of reporting an empty one right after something was added to a different store's.
## Skills
| Skill | What it does |
|---|---|
| `tbank` | **Entry point** — what the bank can do and which skill handles it |
| `tbank-grocery-order` | Recipe → search → cart → confirm → checkout |
| `tbank-tickets` | Cinema/concert: search → showtime → seats → book → pay |
| `tbank-travel-search` | Trains, flights, marketplace — search only, no booking |
| `tbank-bill-pay` | Service bills — utilities, taxes, fines: catalogue → provider fields → commission preview → pay |
| `tbank-transfer-money` | P2P, SBP (СБП), account transfers |
| `tbank-cards-documents` | Cards, limits, requisites, passport and other documents |
| `tbank-messenger` | Bank chats and support |
| `tbank-budget-analyzer` | Spending analysis, subscription audit, savings tips |
| `tbank-invest-advisor` | Portfolio, P&L, rebalancing, tax optimization |
| `tbank-login` | Multi-step login, session management |
## Example requests
Ask in Russian — the tools answer in Russian. Everything below was run against the
live bank.
**Кино и афиша**
```
Что идёт в кино сегодня?
Купи два билета на «Майкла» на завтра в Каро 11 около 20:00 в центре зала
Отмени заказ
Покажи последние 5 моих заказов
```
**Деньги**
```
Покажи мои счета
Переведи 10 рублей Алёне на +79991234567
Какие последние 5 операций?
Покажи реквизиты счёта
```
**Продукты**
```
Хочу оливье, собери корзину с минимальным КБЖУ
Хочу оливье, собери корзину с минимальной ценой
Хочу оливье, собери корзину из премиум продуктов
Найди самый дешёвый картофель за килограмм
Отмени заказ
```
**Карты и документы**
```
Покажи реквизиты основной карты
Какие лимиты по основной карте?
Покажи реквизиты моего паспорта
Когда истекает мой загранпаспорт?
```
## Tests
No pytest — the tests are standalone scripts. Run them all:
```bash
.venv/bin/python tests/run_all.py # every file, ~35 s, offline
.venv/bin/python tests/run_all.py transfer # only files matching "transfer"
```
Each runs in its own process, and the runner redirects the attempt/event journals to
a temp directory so a test run never writes to `~/.local/share/tbank-mcp/`.
Everything needed is in the repo: request contracts are pinned against scrubbed
fixtures in `tests/fixtures/` (real structure and protocol values, synthetic personal
data), so the suite is meaningful on a clean clone. Where the original Burp capture is
present the tests additionally check the fixtures have not drifted from it.
## Security
- **`session.json`** — canonical path `~/.local/share/tbank-mcp/session.json`
(override with `TBANK_SESSION`), mode 0600, owner-only. It holds tokens. Both
`login_cli.py` and the MCP server read the same file, so there is nothing to
configure. On start-up the MCP logs the path, size and permissions only — never a
token or a cookie.
- **Password / PIN** — not in git, not in the code, and not in the LLM context if you
use `login_cli.py`.
- **No secrets in the repo.** Two kinds of committed material look secret-adjacent and
are not: `ca/roots/*.pem` are public CA root certificates, shipped on purpose and
pinned by SHA-256 in `src/tls.py`; `tests/fixtures/*.json` are request contracts
scrubbed from a real capture — real structure and protocol values, synthetic
account, phone, address and device ids. The captures themselves are gitignored and
never leave the machine.
- **`events.jsonl` + `attempts.jsonl`** — redacted diagnostics in
`~/.local/share/tbank-mcp/`. They carry step, http_status, blame, amount and order
id, and never tokens, cookies, addresses, phone numbers, emails or account numbers.
Safe to share while debugging; the `diagnostics` tool reads them.
- **`calls.jsonl`** — one line per tool call, so it can be seen how an agent uses
this MCP: the tool, its arguments, the duration, and the FIRST LINE of the answer,
which is what the agent actually read. Held to the same promise as the files above:
arguments that are free text a person wrote (a chat message, a transfer note) or a
credential are measured, never stored; long digit runs — account, card, order and
payment ids — are replaced in the recorded line, both to keep them out and because
the report groups by that line. The `debug_report` tool reads it. On by default;
`TBANK_TRACE=0` disables it, `TBANK_TRACE_FILE` moves it, and it rotates at 5 MB.
- **`TBANK_CONFIRM_ABOVE`** — the ruble threshold from which `transfer_requisites`
shows the «Перевести/Отмена» elicitation dialog in clients that support it
(default `0`: every transfer asks). Clients without elicitation are unaffected —
they keep the text confirmation flow.
- **Device profile.** Payments carry a 3DS/anti-fraud block whose device facts —
screen size, locale, timezone, hardware model — default to the device the traffic
was captured from. Override them with `TBANK_DEVICE_SCREEN_HEIGHT` / `_WIDTH` /
`TBANK_DEVICE_LANGUAGE` / `TBANK_DEVICE_TIMEZONE` / `TBANK_DEVICE_MODEL` so your
payments do not describe someone else's phone.
- **Request-shape switches.** Two divergences from the captured app are corrected
behind env vars, so a rollback is one variable and no re-login (neither touches
`session.json`):
- `TBANK_QUERY_PROFILE=legacy` — restores sending `wuid` to every host and
injecting `vendor`/`client_version` on every read. The app sends `wuid` only to
`www.tbank.ru` under `/api/common/`, and the other two only on the OIDC
authorize call, so the default is now the scoped form.
- `TBANK_ACCEPT_PROFILE` — `json` (default, and today's behaviour byte-for-byte)
| `auto` | a comma-separated host list. The app does not send
`application/json` to its native hosts; that string is the Apple URL-loading
default that appears when no Accept is set. The captured responses are
`application/json` either way, so this is fidelity rather than a fix — but 63
templates share the busiest host and there is no staging environment, so it is
OFF until driven live. Roll it out one host class at a time, cheapest first:
`webview`/`shortcuts`/`my-home` (unreachable or trivial reads) → `api-invest*`
(`invest_accounts`, `invest_portfolio`) → `api.t-bank-app.ru` starting with
`keepalive`, whose Content-Type demonstrably becomes `text/html` while its body
stays JSON → `www.tbank.ru` → the three lifestyle shelf paths. A regression has
one signature: `_unwrap` raising `HTTP_200` because the body no longer parses.
Compare `debug_report()` before and after each step.
- Money tools (`transfer`, `transfer_requisites`, `grocery_checkout`, `ticket_pay`,
`pay_bill`, `confirm_payment`) require confirmation of a specific amount — "buy it"
is not a confirmation. A `/v1/pay` the bank holds at `WAITING_CONFIRMATION` is
resumed with `confirm_payment(attempt_id, otp)` and reconciled with
`payment_status(attempt_id)` — never by repeating the transfer, which would create a
second pending payment.
- **Tool annotations.** Every tool declares what it does, in one table —
`TOOL_KINDS` in `src/server.py` — and a tool missing from it raises at import
rather than defaulting to anything. Three kinds: 60 are `readOnlyHint: true` and
may run without a prompt; 12 write something that costs nothing (a cart, a
booking, a message, an OTP, a token, a local file) and are marked
`destructiveHint: false`; 6 debit an account — `transfer`, `transfer_requisites`,
`grocery_checkout`, `ticket_pay`, `pay_bill`, `confirm_payment` — and are the only
ones carrying `destructiveHint`, which
is what forces a confirmation dialog. The line is drawn at money on purpose: a
booking expires by itself and a cart line is a rewrite away, so confirming those is
friction that teaches people to click through the one dialog that matters.
The 12 writers are not marked read-only, because they do modify things and that
flag states the opposite — if your client still prompts on them, allow them once
in the client rather than changing what the server claims.
## Disclaimer
For personal use with your own T-Bank account. Not affiliated with T-Bank.
TDQS
Scored across 78 tools
Most tools target a distinct vertical+action and the descriptions actively police the boundaries (confirm_otp vs confirm_payment, cinema_schedule vs place_schedule vs concert_schedule, grocery_search vs grocery_rank). The main ambiguity is the universal `get_data` getter, which overlaps named tools like list_cards, invest_accounts, account_requisites and list_operations, plus the three near-identical 'operations/spending' readers (list_operations, operations_histogram, spending_categories). These are documented, but an agent can still plausibly pick the wrong one.
The dominant pattern is a consistent snake_case prefix_verb/noun scheme grouped by domain (list_accounts, card_limits, grocery_add_to_cart, cinema_schedule, transfer_requisites, payment_status). Deviations exist — bare nouns/verbs like get_data, orders, documents, flows, keepalive, diagnostics, debug_report — but they are readable and few relative to 78 tools. No camelCase mixing.
78 tools is far beyond the practical ceiling for reliable selection, even for a banking super-app. The breadth (payments, groceries, tickets, travel, messenger, investments, auth) justifies many of them, but sub-verticals like cinema/concert/afisha/place alone consume 8+ tools and the universal get_data crowd pushes the set well past a manageable surface.
Coverage is unusually thorough: full auth lifecycle (login/otp/pin/password/refresh/keepalive), money movement (transfer, transfer_requisites, pay_bill, payment_commission, confirm_payment, payment_status, receipt), grocery end-to-end (stores→search→cart→set→checkout→status→cancel→attempts), tickets book/pay/cancel/qr, cards, requisites, statements, documents, investments, messenger and diagnostics. Remaining gaps (inner transfers, shop/train/flight checkout) are explicit, documented dead ends rather than surprises.