telegram-bot-testing-mcp
Drives the official Telegram Web client in a real browser to test Telegram bots and Mini Apps: opens chats, sends messages/commands/files/voice, reads messages and keyboards, clicks inline and reply buttons, waits for bot replies, captures screenshots/recordings, and interacts with Mini Apps.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@telegram-bot-testing-mcp open @my_bot, send /start, then verify the reply keyboard renders 2 rows"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
telegram-bot-testing-mcp
Write test scenarios for your Telegram bot — Claude runs them like a human QA.
AI agents can already test any website through browser automation. This MCP server gives them the same power over Telegram bots and Mini Apps: it drives the official Telegram Web client (web.telegram.org) in a real browser. Your agent gets exactly the input a real user gets — the same rendered chat, the same keyboards, the same Mini App — so it can verify not just that the bot responds, but that nothing is broken visually: keyboards render in the right shape, edits land, media shows up, the Mini App actually opens.
Instead of clicking through your bot by hand after every deploy, you describe the scenario once and let the agent execute it — sending /commands, pressing the buttons, uploading files, comparing what it sees against what you expected, and attaching screenshots as evidence.
No MTProto libraries, no session-string hacks, no bot token on the user side. Telegram sees a normal, official web client.
Why not telethon / Bot API?
Bot API shows you the bot's side, not the user's. You can't see how your keyboard renders, whether the edit landed, or what a real user experiences.
MTProto userbot libraries (telethon, gramjs, pyrogram) are custom clients: a different code path from real users, and account-ban-prone.
This adapter is a real user session in the official client — what your agent sees is pixel-for-pixel what users see, structurally and visually.
Related MCP server: Telegram Web MCP Server
Quickstart
# 1. Install (Python 3.11+; from GitHub until the PyPI release)
uv tool install git+https://github.com/SnimanOff/telegram-mcp
# download the browser (playwright lives inside the tool's env, so go through uvx):
uvx --from git+https://github.com/SnimanOff/telegram-mcp playwright install chromium
# 2. Log in once (opens a browser window — scan the QR with a dedicated account)
telegram-bot-testing-mcp login
# 3. Add to Claude Code
claude mcp add telegram -- telegram-bot-testing-mcpThen hand your agent a scenario instead of testing by hand:
Run a regression pass on @my_bot:
/start— the welcome message must show the pricing keyboard, 2 rows of 2.Press Buy — the bot must edit that message into a payment summary.
Send
PROMO2026— the reply must confirm the discount.Open the Mini App from the Catalog button and add the first item to cart.
Screenshot every step and flag anything that renders wrong.
The agent executes it step by step with the same input a human tester would have, and reports what passed, what failed, and how it looked.
Tools
Tool | Purpose |
| Mode, login state, profile location |
| One-time interactive login (QR window) |
| Headless login by phone number — the code arrives on the account's other devices |
| Record & send a real voice message through a fake microphone (WAV input) |
| Open chat by |
| Send text or /command; |
| Forward a message via the real forward picker |
| Attach & send photo/document (with caption) |
| Last N messages as structured JSON (text, buttons grid, media kind, ids) |
| Block until the bot replies — the core test primitive |
| Press an inline button by text or row/col |
| Press a reply-keyboard button |
| Wipe history (test isolation) |
| Release Chromium and keep the signed-in profile |
| Begin recording the Telegram Web UI, optionally as WebM only |
| Save the WebM and GIF and close the recording browser |
| Screenshot chat / single message / window |
| Open a Mini App from a web-app button |
| List interactive elements inside the Mini App ( |
| Interact with Mini App elements by ref |
| Capture / close the Mini App |
All tools return typed errors with actionable hints (not_logged_in,
button_not_found + the buttons that are present, timeout + current chat
state, selector_broken when Telegram changes markup).
Configuration
Env var | Default | Meaning |
|
|
|
| off |
|
|
| Browser profile location |
|
| Multiply all network-bound timeouts (e.g. |
|
| Close the browser after this many idle seconds. Set |
|
| Directory for recorded demos |
| required for HTTP | Bearer key for this server instance |
| localhost addresses | Additional comma-separated HTTP Host values |
| none | Comma-separated browser origins to allow |
|
| Server-side file directory for upload tools over HTTP |
Run two agents with separate accounts
Sign in once per profile. For example, in PowerShell:
$env:TG_MCP_PROFILE_DIR = "$PWD\profile-qa-1"
telegram-bot-testing-mcp login
$env:TG_MCP_PROFILE_DIR = "$PWD\profile-qa-2"
telegram-bot-testing-mcp loginAssign one distinct MCP server to each agent. For local stdio clients, run
telegram-bot-testing-mcp twice and set TG_MCP_PROFILE_DIR in each server's
environment to the corresponding absolute profile path. For HTTP, use a
different port and bearer key for each profile. Each instance serializes
its own tool calls, and the two instances run independently.
The first tool that needs Telegram starts Chromium. In the default headless
mode, the page renders while the browser is active. Ordinary tools run without
recording. The idle timeout releases Chromium, and tg_close_browser releases
it immediately. Chat tools reopen the last selected chat after the browser
restarts. Open a Mini App again if its browser was closed during idle.
Record a bot demo for a README
Install FFmpeg on PATH or install the optional recording extra, for example
pip install ".[recording]" from the repository. WebM-only recording uses
Playwright's video support.
Call
tg_record_startwith{"name": "start-flow"}before the first demo action.Open the bot, send
/start, wait for the reply and click the relevant buttons.Call
tg_record_stop. Copy thegif_pathresult into the bot repository and reference it in the README.
Each run writes demo.webm and demo.gif to a new directory. Pass
export_gif: false to the start tool to save only WebM. Recording starts a
fresh browser using the same signed-in profile and keeps it open until you
stop. Sign in before starting a recording. Operations that need to restart
Chromium, such as switching the fake microphone to another audio file, require
ending the recording first.
Connect over HTTP
Start one Streamable HTTP endpoint per account. For example:
$env:TG_MCP_PROFILE_DIR = "$PWD\profile-qa-1"
$env:TG_MCP_API_KEY = '<unique-random-key-for-qa-1>'
telegram-bot-testing-mcp serve-http --port 8765Configure the MCP client with http://127.0.0.1:8765/mcp and an
Authorization: Bearer <key> header. For a second agent, use its own
profile, port and key. HTTP listens on loopback by default. For a remote
deployment, use an HTTPS reverse proxy and add its hostname to
TG_MCP_HTTP_ALLOWED_HOSTS if the proxy preserves the public Host header.
If your client sends an Origin header, add its exact value to
TG_MCP_HTTP_ALLOWED_ORIGINS.
tg_record_stop includes relative video_url and gif_url fields for
HTTP clients. Download them from the same server with the same bearer key.
Use separate artifact and upload directories when overriding their defaults
for multiple accounts.
Security
The browser profile directory is your Telegram session — treat it like a password. Use a dedicated test account, not your personal one: any automation that can send messages from your account is worth isolating. The profile stays on the server. A remote MCP client receives tool results and can retrieve demo recordings with its bearer key. Keep the key and browser profile private.
Headless servers (CI boxes, VPS)
Everything is headless by default, including login:
telegram-bot-testing-mcp login --phone +42077xxxxxxx
# the confirmation code arrives in the Telegram app on the account's
# other devices (or via SMS) — type it into the terminal promptAgents can do the same via tg_login_phone → tg_login_code
(→ tg_login_password for 2FA accounts).
Alternatively, log in once on a desktop machine (login opens a QR window)
and move the profile — it is just a directory and transfers fine across OSes
(verified Windows → Linux):
tar -czf tg-profile.tgz -C ~/.telegram-user-mcp profile-prod
scp tg-profile.tgz server:
ssh server 'mkdir -p ~/.telegram-user-mcp && tar -xzf tg-profile.tgz -C ~/.telegram-user-mcp'Treat the archive like a password — it contains your session.
Testing against the Telegram test DC
Telegram runs a separate test environment, and TG_MCP_MODE=test targets it.
Reality check as of 2026:
Auto-created test accounts are disabled. The documented
99966XYYYYnumbers with deterministic codes no longer work (tdlib/td#3370 — "Test accounts are disabled currently"). Don't believe older tutorials.Register with a real phone number via the official iOS app: tap the Settings icon 10 times → Accounts → Login to another account → Test.
Log the adapter in:
TG_MCP_MODE=test telegram-bot-testing-mcp login— scan the QR with the test-mode iOS app.Create your bot inside the test DC: message
@BotFatherfrom the test account — it's a separate BotFather with separate tokens.Point your bot's code at the test Bot API route:
https://api.telegram.org/bot<token>/test/METHOD(the bot is a token, not a phone number — one test account can create the bot and act as the user).
For most workflows the default prod mode with a dedicated account is simpler.
Coverage map
The single source of truth for what this adapter can and cannot test. Statuses are earned, not promised:
✅ implemented and verified by a live e2e run against real Telegram
🟡 implemented, no dedicated e2e yet (should work; treat with care)
🔴 not implemented (PRs / issues welcome; priorities below)
⚪ impossible in the official Telegram Web client itself — a human web user can't do it either, so a web-based tester can't and shouldn't
Reading what the bot sends
Component | Status | Notes |
Text, emoji, line breaks | ✅ | emoji restored from |
Formatting entities (bold/links/code/spoilers) | 🟡 | extracted as plain text; markup structure not exposed |
Photo | ✅ |
|
Video | 🟡 |
|
GIF / animation | ✅ | detected as |
Video note (round) | 🟡 |
|
Voice | ✅ |
|
Audio file | 🟡 |
|
Document | 🟡 |
|
Sticker (static/animated/video) | 🟡 |
|
Album / media group | 🟡 | read as one message; items not split out |
Message edit by bot | ✅ | verified via re-read after callback |
Message deletion by bot | 🟡 | disappears from |
Location | ✅ |
|
Venue | ✅ |
|
Live location | 🟡 | detected as |
Contact | ✅ |
|
Poll / quiz | ✅ |
|
Dice / darts / slots | ⚪ | the web client renders them as plain animated stickers — indistinguishable |
Invoice (payments) | 🔴 | Pay button is enumerable; checkout flow unsupported |
Forward header ("Forwarded from") | ✅ |
|
Reply-to attribution | ✅ |
|
Sender attribution | 🟡 |
|
Reactions set by the bot | 🔴 | |
Link preview / web page card | 🔴 | text extracted, preview card not flagged |
Service messages | ✅ | flagged |
Buttons & keyboards
Component | Status | Notes |
Inline callback buttons (grid, click, edit-after-callback) | ✅ | |
Reply keyboard (show, click, toggle) | ✅ | |
| ✅ | see Mini Apps below |
URL buttons | 🟡 | enumerated with text; clicking (opens a new tab) undefined |
| 🔴 | enumerable as text only |
Keyboard remove / one-time / force_reply | 🟡 | not explicitly tracked |
Bot commands menu (/) and menu button | 🔴 |
Acting as the user
Action | Status | Notes |
Send text / commands / emoji | ✅ | delivery-verified (not just typed) |
Send photo / document (+caption) | ✅ |
|
Record & send voice | ✅ | fake microphone fed from WAV |
Press START on a new bot | ✅ | automatic |
Clear chat history (test isolation) | ✅ | |
Screenshots (chat / message / window) | ✅ | |
Send video note (webcam round) | 🔴 | possible via fake video device; not implemented |
Send sticker / GIF (pickers) | 🔴 | |
Create a poll | 🔴 | web client supports it; not implemented |
Forward a message | ✅ |
|
Reply to a specific message | ✅ |
|
Edit / delete own message | 🔴 | |
Set a reaction | 🔴 | |
Inline mode ( | 🔴 | biggest gap for inline bots |
| 🔴 | |
Block / restart bot, profile actions | 🔴 | |
Send location / live location | ⚪ | the official web client cannot |
Calls, secret chats | ⚪ | not available on web / not applicable to bots |
Stories | ⚪ | bots don't interact with stories |
Sessions & flows
Flow | Status | Notes |
QR login (desktop window) | ✅ | manual scan once |
Headless phone login (terminal / MCP tools) | ✅ | autonomous e2e: second session reads the code |
2FA password step | 🟡 | implemented; test account has no 2FA to verify against |
Profile transfer to servers | ✅ | verified Windows → Linux |
Mini App: open / snapshot / click / type / read state / screenshot / close | ✅ | |
Mini App main button / back button | 🟡 | selectors present, no e2e |
Payment checkout (test provider) | 🔴 | feasible on the test DC |
Groups / channels / topics | 🔴 | designed for 1:1 bot chats so far |
Roadmap order for the 🔴s: (1) inline mode; (2) payment checkout on the test DC; (3) sticker/GIF pickers; (4) groups/channels.
Note on message ids: they are the web client's DOM ids. All adapter tools
speak them consistently, but they can diverge from Bot API message_ids
(observed after a history clear) — never compare the two directly.
Limitations
One server instance per profile (Chromium locks the profile directory).
Telegram Web markup changes can break selectors — they live in one file (
selectors.py), and every breakage surfaces as a typedselector_brokenerror. PRs welcome.
Development
uv venv && uv pip install -e ".[dev,recording]" && playwright install chromium
python -m pytest # unit tests (offline, fixture DOM)
python e2e/fixture_bot.py # BOT_TOKEN=... — the e2e fixture bot
python e2e/run_scenarios.py # BOT=@your_fixture_bot — full scenario runMIT license.
Available Tools
25 toolstg_clear_chatB
Clear the open chat's history (test isolation between scenarios).
Inputs: no named parameters. Returns: result
tg_click_buttonB
Click an inline-keyboard button by text substring, or by 0-based row/col. Targets message_id or the last message that has buttons.
Inputs: col, row, text, message_id. Returns: result
tg_click_reply_buttonC
Click a reply-keyboard button (the keyboard shown near the input).
Inputs: text (required). Returns: result
tg_close_browserA
Release Chromium now. The next chat operation reopens the saved profile.
Inputs: no named parameters. Returns: result
tg_forward_messageA
Forward a message by id via the forward picker. Empty to_chat forwards to the current chat (typical bot-test loop).
Inputs: message_id (required), to_chat. Returns: result
tg_loginB
Open a visible browser window for one-time Telegram login (QR or phone). The session persists in the profile afterwards.
Inputs: timeout_s. Returns: result
tg_login_codeA
Headless login step 2: submit the confirmation code. May return password_needed for 2FA accounts (then call tg_login_password).
Inputs: code (required). Returns: result
tg_login_passwordB
Headless login step 3: submit the two-factor password (2FA only).
Inputs: password (required). Returns: result
tg_login_phoneA
Headless login step 1: submit the phone number. The code arrives on the account's other logged-in devices (or SMS); pass it to tg_login_code.
Inputs: phone (required). Returns: result
tg_miniapp_clickB
Click an element inside the Mini App by its snapshot ref (e.g. 'e3').
Inputs: ref (required). Returns: result
tg_miniapp_closeB
Close the open Mini App popup.
Inputs: no named parameters. Returns: result
tg_miniapp_openC
Open a Mini App via a web-app button on the last message (or by text).
Inputs: button_text. Returns: result
tg_miniapp_screenshotB
Screenshot the open Mini App.
Inputs: no named parameters.
tg_miniapp_snapshotA
List interactive elements inside the open Mini App as [ref] lines usable with tg_miniapp_click / tg_miniapp_type.
Inputs: max_elements. Returns: result
tg_miniapp_typeB
Type text into a Mini App input by its snapshot ref.
Inputs: ref (required), text (required). Returns: result
tg_open_chatC
Open a chat by @username or t.me link. Returns the last messages.
Inputs: query (required). Returns: result
tg_read_messagesB
Read the last messages of the open chat as structured JSON (id, direction, text, time, button grid, media kind).
Inputs: limit. Returns: result
tg_record_startB
Start recording the official Telegram Web UI before the demo steps.
Inputs: name, export_gif. Returns: result
tg_record_stopB
Finish the demo and return paths to the WebM and, by default, GIF.
Inputs: no named parameters. Returns: result
tg_screenshotB
Screenshot the chat, a single message (scope='message' + message_id), or the whole window (scope='window').
Inputs: scope, message_id.
tg_send_fileB
Attach and send a file to the open chat. kind: auto (by extension) | photo | document.
Inputs: path (required), kind, caption. Returns: result
tg_send_messageB
Send a text message or /command to the currently open chat. reply_to: message id to reply to (0 = plain message).
Inputs: text (required), reply_to. Returns: result
tg_send_voiceB
Record and send a voice message using a fake microphone fed from a WAV file (PCM). Relaunches the browser on first use per file.
Inputs: path (required), duration_s. Returns: result
tg_statusA
Report adapter mode, login state and profile location.
Inputs: no named parameters. Returns: result
tg_wait_for_messageA
Block until the bot sends something new (the core test primitive). Returns the new incoming messages.
Inputs: after_id, timeout_s. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 25 tools
Each tool targets a distinct action or resource, and the two potentially confusing pairs—tg_login vs the headless tg_login_phone/code/password flow and tg_click_button vs tg_click_reply_button—are clearly differentiated by their descriptions (visible vs headless, inline vs reply keyboard). The miniapp_* family and tg_screenshot vs tg_miniapp_screenshot are also clearly scoped. Only minor overlap remains, e.g. tg_login serving as both a standalone and a fallback to the phone flow.
All tools share a consistent tg_ prefix and snake_case, with a predictable verb_noun pattern for messaging/waiting/clicking and a tidy tg_miniapp_* namespace for the sub-workflow. Minor deviations exist: tg_status is a noun rather than an action, and the tg_record_start/stop pair uses a different verb form than tg_screenshot, but the convention is still uniform and readable.
25 tools is on the heavy side, but the surface spans multiple genuinely distinct subsystems—login (4 variants), messaging/media, keyboard interaction, screenshots, recording, and a full six-tool Mini App workflow—so nearly every tool earns its place. The count is justified by the breadth of the browser-automation domain rather than by redundant options.
The surface covers the full bot-test lifecycle: headless and visible login, opening chats, sending text/files/voice, reading messages, waiting for replies, inline and reply-keyboard clicks, chat clearing, screenshots, recording, and Mini App interaction. Minor gaps remain—no message edit/delete (only whole-chat clear), no reactions, and no explicit media download—but these are workaroundable and don't block core test loops.
Maintenance
Related MCP Connectors
Write, run and check natural-language browser tests of your web app from your AI assistant.
Find UI bugs, verify fixes and run tests on your web app from your AI coding agent.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Browser-based QA for AI-built software. Test pages with real browsers via agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to test Telegram bots by driving the official Telegram Web client in a real browser, allowing visual verification of bot responses, inline keyboards, and Mini Apps.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with Telegram Web through a clean text-based API, including chat search, message history, sending messages, and profile retrieval via a persistent Playwright session.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to autonomously interact with and test web applications in a real browser, providing DOM/Accessibility tree extraction, runtime telemetry, screenshot capture, and Markdown test reports.40 npm1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI coding agents to autonomously interact with, test, click inline buttons on, and verify Telegram bots end-to-end via MTProto.1MIT