Skip to content

Telegram MCP 0.6.0

Latest

Choose a tag to compare

@zai-one zai-one released this 14 Oct 15:17
· 4 commits to main since this release
d93a70f
  • Upgrade note: TELEGRAM_TOOLSETS=all now also enables the new opt-in toolsets except account_admin and advanced_read, and an existing groups_admin (or all) gains remove_user, delete_forum_topic and the invite-link writes. Read-only mode and the chat ACL still apply; list toolsets explicitly if you relied on the previous set.
  • Optional lazy tool loading (TELEGRAM_TOOL_LOADING=eager|lazy, default eager = unchanged): lazy lists a small core plus telegram_enable_toolsets (toolsets with one-line description and token cost); enabling makes the already-registered tools visible to that MCP session and sends notifications/tools/list_changed. Allowlists, read-only mode and approval gates still apply. Setup wizard asks eager vs lazy. Startup tokens (tools/list + instructions, ≈chars/4): eager ≈3558, lazy ≈1817. Handshake-era clients see tools.listChanged=true; hot account activation keeps not-yet-enabled tools hidden. Scope: enablement is per MCP session (FastMCP session visibility) for handshake-era clients (initialize), so one client's enabled toolsets never appear for another. Sessionless clients (2026-07-28 server/discover) and the stateless HTTP transport get a new session per request, so enablement does not persist there: use eager or TELEGRAM_TOOLSETS. README lazy section lists verified tools/list_changed client support with sources.
  • Opt-in toolset event_feed: telegram_poll_events — live feed of new / edited / deleted messages from Telethon NewMessage / MessageEdited / MessageDeleted handlers, one bounded in-memory ring per account (2000 events), client-held cursor bound to the account, wait_seconds 0–55, chat_ids / kinds filters, gap=true on restart or overflow. Chat ACL applied per event; deletions without a chat (private chats, basic groups) are hidden while an ACL is set. Event text is never persisted (ids/dates only, see below). Guide telegram://guide/events.
  • Opt-in toolset account_admin (stdio, telegram:write scope): telegram_add_account — QR login in chat (no phone/code/2FA password through the chat; 2FA → local wizard). Writes TELEGRAM_SESSION_STRING_<LABEL> atomically to the private secret file, never overwrites, grants the label in TELEGRAM_BINDINGS_FILE; hot-activated (see below), restart only when the result says restart_required=true.
  • Competitor parity without re-pinning the vendor (zai_telegram/native.py): reads via telegram_read — get_message_by_link, export_unread_messages, get_send_as, get_member_admin_status, transcribe_voice, plus vendor export_contacts; writes via telegram_write (ledger, categories, ACL) — vote_poll, remove_user, edit_forum_topic, delete_forum_topic, rename_folder, plus vendor get_invite_link / export_chat_invite (category groups_admin).
  • zai-telegram-mcp-setup --add-account LABEL [--qr] [--principal P] --directory DIR: log in one more account (phone code or QR, 2FA password via hidden prompt) into the existing secret and bindings files.
  • Hot activation: an account added in chat joins the loaded runtime without restart (restart_required=false; a single-account server becomes multi-account on the fly). Restart is still needed for the label default or if activation fails (only a pure addition of TELEGRAM_SESSION_STRING_<LABEL> is accepted; any other secret change still needs a restart). Fixes the running server refusing calls after the secret file gained a new session.
  • Event feed survives restarts: epoch, sequence and event ids (never text) persist for 24 h in the state DB; old cursors stay valid and only the downtime is reported as gap_window. TELEGRAM_FEED_PERSIST=0 disables.
  • Vendor backports from chigwell/telegram-mcp after v3.2.0 (vendor/patches/zai-backports-2026-10.patch, recorded in the manifest): serialized reconnects per client (2980601), no interactive start() on reconnect plus 30 s reconnect timeout (dd71a12), list_messages search starting at to_date (312cd00), custom custom:<id> and empty reactions (7fc6b4a).
  • Live reload: the server watches its secret and bindings files; a pure session addition is hot-added, new grants apply on the next call, the redaction set refreshes, and when the server becomes multi-account every tool gains account and telegram_list_accounts appears (MCP tools/list_changed). account_admin exposes account from the start. Invalid bindings keep the previous grants.
  • Event feed: downtime backfill (messages sent while the server was down become new events with backfilled=true, bounded 100 dialogs / 500 messages, TELEGRAM_FEED_BACKFILL=0); quiet accounts keep alive_at fresh.
  • Vendor backport d5ddc8c: get_participants paginates without the non-existent Telethon offset argument (every call failed before).
  • Owner follow-up: get_message_by_link now works under a chat ACL — the chat named in the link is checked (unparsable links are denied); t.me/s/<name>/<id> links; transcribe_voice(wait_seconds 0–30) waits for the final text (updateTranscribedAudio); rename_folder also renames imported shared folders. Native tools reconnect like vendor tools; remove_user refuses self; vote_poll rejects closed polls and repeated options.
  • Critic fixes: newly saved sessions are redacted even when activation fails; abandoned QR logins are disconnected after 10 min; in-chat grants work without a bindings file path (reported as binding_saved=false).
  • Review fixes: in-chat QR login keeps Telethon's wait running between status calls, so a scan made before status is no longer lost; the new label is saved to the bindings file even after the embedded runtime cleared TELEGRAM_* variables; telegram_add_account is never registered on HTTP; TELEGRAM_FEED_BACKFILL=0 is honoured; telegram_poll_events no longer blocks the event loop when the ring lost events behind the cursor, and refuses to run (chat_access_denied) while TELEGRAM_DENIED_CHATS names a chat by @username (feed events carry numeric ids only); delete_forum_topic repeats until the whole topic is deleted (partially_deleted after 50 batches).
  • Skeptic review fixes (Security/Fix): telegram_add_account now requires TELEGRAM_WRITE_ENABLED and an enabled provider (checked before the QR login and again before saving) and is removed by read-only mode even when named in TELEGRAM_TOOLS; session + binding updates (in chat and --add-account) run under one cross-process file lock with the label re-checked inside it, so concurrent adders never lose a session or grant; telegram_poll_events is admitted like every read (provider switch, cooldown, rate limit, concurrency lease held during the wait); ring overflow during a long-poll wait is reported as gap=true; downtime backfill reports backfill_complete=false when more than 100 dialogs changed; export_unread_messages returns the unread incoming messages above the read marker (later outgoing messages no longer displace them) and flags truncated.
  • Router: same lines, now also routing live feed and add-account; default/all always-loaded context stays at or below 0.5.0 (enforced by scripts/token_budget.py). Router eval: 34 cases, optional upstream-tool check.

Source: d93a70f · Changes: v0.5.0...v0.6.0