You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e6dd352
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -567,6 +568,10 @@ set them to keep a stable, recognisable device name. The same variables are
567
568
read both by the session string generator (at login) and by the server (on
568
569
every connect), so set them in the same place as your other credentials.
569
570
571
+
## Expected Account Check
572
+
573
+
Set `TELEGRAM_EXPECTED_USERNAME` (or `TELEGRAM_EXPECTED_USERNAME_<LABEL>` per account) and the server refuses to start when the session belongs to a different account. The comparison is case-insensitive and ignores a leading `@`. Unset means no check.
574
+
570
575
## Proxy Support
571
576
572
577
Route Telegram traffic through a proxy by setting the `TELEGRAM_PROXY_*`
@@ -842,7 +847,8 @@ Telegram messages, display names, chat titles, and button labels are untrusted c
842
847
the MCP server when you can scan from an existing Telegram app, or
843
848
`uv run session_string_generator.py --phone` when you need phone-code login.
844
849
Then set `TELEGRAM_SESSION_STRING` in `.env`. The MCP server does not perform
845
-
interactive phone-code login over stdio.
850
+
interactive phone-code login over stdio, including after a reconnect: a session
851
+
terminated while the server runs fails with "not authorized after reconnect".
846
852
-**Invalid API credentials:** verify `TELEGRAM_API_ID` and `TELEGRAM_API_HASH` at [my.telegram.org/apps](https://my.telegram.org/apps).
847
853
-**Database is locked:** make sure no other process is using the same file session.
848
854
-**`AuthKeyDuplicatedError` / "Another telegram-mcp process is already connected with this session":** two processes tried to connect the same Telegram session at once (e.g. an MCP client restarted the connector before the old process exited), which Telegram rejects and can invalidate the session for both. The server now takes an exclusive lock per session before connecting; a second concurrent launch waits briefly (default 20s, override with `TELEGRAM_LOCK_GRACE_SECONDS`) for the first to release it and otherwise exits without ever calling `connect()`, instead of racing into a duplicate connection. Retry once only one instance is running — the refusal names the PID holding the lock. If several instances on this host are meant to share one session (all reaching Telegram from the same IP), set `TELEGRAM_SESSION_LOCK=shared`; see [Sharing one session from one host](#sharing-one-session-from-one-host).
0 commit comments