Repository navigation
- Upgrade note:
TELEGRAM_TOOLSETS=allnow also enables the new opt-in toolsets exceptaccount_adminandadvanced_read, and an existinggroups_admin(orall) gainsremove_user,delete_forum_topicand 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, defaulteager= unchanged): lazy lists a small core plustelegram_enable_toolsets(toolsets with one-line description and token cost); enabling makes the already-registered tools visible to that MCP session and sendsnotifications/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 seetools.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-28server/discover) and the stateless HTTP transport get a new session per request, so enablement does not persist there: useeagerorTELEGRAM_TOOLSETS. README lazy section lists verifiedtools/list_changedclient support with sources. - Opt-in toolset
event_feed:telegram_poll_events— live feed of new / edited / deleted messages from TelethonNewMessage/MessageEdited/MessageDeletedhandlers, one bounded in-memory ring per account (2000 events), client-held cursor bound to the account,wait_seconds0–55,chat_ids/kindsfilters,gap=trueon 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). Guidetelegram://guide/events. - Opt-in toolset
account_admin(stdio,telegram:writescope):telegram_add_account— QR login in chat (no phone/code/2FA password through the chat; 2FA → local wizard). WritesTELEGRAM_SESSION_STRING_<LABEL>atomically to the private secret file, never overwrites, grants the label inTELEGRAM_BINDINGS_FILE; hot-activated (see below), restart only when the result saysrestart_required=true. - Competitor parity without re-pinning the vendor (
zai_telegram/native.py): reads viatelegram_read—get_message_by_link,export_unread_messages,get_send_as,get_member_admin_status,transcribe_voice, plus vendorexport_contacts; writes viatelegram_write(ledger, categories, ACL) —vote_poll,remove_user,edit_forum_topic,delete_forum_topic,rename_folder, plus vendorget_invite_link/export_chat_invite(categorygroups_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 labeldefaultor if activation fails (only a pure addition ofTELEGRAM_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=0disables. - 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 interactivestart()on reconnect plus 30 s reconnect timeout (dd71a12),list_messagessearch starting atto_date(312cd00), customcustom:<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
accountandtelegram_list_accountsappears (MCPtools/list_changed).account_adminexposesaccountfrom the start. Invalid bindings keep the previous grants. - Event feed: downtime backfill (messages sent while the server was down become
newevents withbackfilled=true, bounded 100 dialogs / 500 messages,TELEGRAM_FEED_BACKFILL=0); quiet accounts keepalive_atfresh. - Vendor backport d5ddc8c:
get_participantspaginates without the non-existent Telethonoffsetargument (every call failed before). - Owner follow-up:
get_message_by_linknow 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_folderalso renames imported shared folders. Native tools reconnect like vendor tools;remove_userrefuses self;vote_pollrejects 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
statuscalls, so a scan made beforestatusis no longer lost; the new label is saved to the bindings file even after the embedded runtime clearedTELEGRAM_*variables;telegram_add_accountis never registered on HTTP;TELEGRAM_FEED_BACKFILL=0is honoured;telegram_poll_eventsno longer blocks the event loop when the ring lost events behind the cursor, and refuses to run (chat_access_denied) whileTELEGRAM_DENIED_CHATSnames a chat by@username(feed events carry numeric ids only);delete_forum_topicrepeats until the whole topic is deleted (partially_deletedafter 50 batches). - Skeptic review fixes (Security/Fix):
telegram_add_accountnow requiresTELEGRAM_WRITE_ENABLEDand an enabled provider (checked before the QR login and again before saving) and is removed by read-only mode even when named inTELEGRAM_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_eventsis admitted like every read (provider switch, cooldown, rate limit, concurrency lease held during the wait); ring overflow during a long-poll wait is reported asgap=true; downtime backfill reportsbackfill_complete=falsewhen more than 100 dialogs changed;export_unread_messagesreturns the unread incoming messages above the read marker (later outgoing messages no longer displace them) and flagstruncated. - 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