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 02f93bf
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -379,6 +379,25 @@ rather than reusing a session another client holds — reuse would make Telegram
379
379
permanently invalidate that session for both clients.
380
380
- "Send this from my work account to @example"
381
381
382
+
### Sharing one session from one host
383
+
384
+
Before connecting, every server process takes a per-session lock (see the
385
+
`AuthKeyDuplicatedError` entry under Troubleshooting). By default it is
386
+
exclusive: a second instance for the same session waits briefly for the first
387
+
to exit and otherwise refuses to start. That lock can only see processes on the
388
+
same host, and Telegram's rule is about IPs, not processes: instances on one
389
+
host only collide when they reach Telegram from different IPs (dual-stack or
390
+
split-tunnel VPN hosts). When they all share one egress IP — a laptop running
391
+
several MCP clients — you can let them share the session instead of pooling:
392
+
393
+
```env
394
+
TELEGRAM_SESSION_LOCK=shared
395
+
```
396
+
397
+
Shared instances coexist with each other but never overlap an exclusive one
398
+
(except on Windows, where a shared instance takes no lock). If you are not sure
399
+
every client egresses from the same IP, use the pool.
400
+
382
401
## Device Identity
383
402
384
403
These optional variables control how the client appears in Telegram under
@@ -645,7 +664,7 @@ Telegram messages, display names, chat titles, and button labels are untrusted c
645
664
interactive phone-code login over stdio.
646
665
-**Invalid API credentials:** verify `TELEGRAM_API_ID` and `TELEGRAM_API_HASH` at [my.telegram.org/apps](https://my.telegram.org/apps).
647
666
-**Database is locked:** prefer string sessions, or make sure no other process is using the same file session.
648
-
-**`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.
667
+
-**`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).
649
668
-**File tools are disabled:** pass allowed roots or configure MCP Roots in your client.
650
669
-**Path rejected:** ensure the path is inside an allowed root and does not use traversal or wildcard patterns.
651
670
-**Auth errors after password changes:** regenerate your session string.
0 commit comments