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 8cc3835
Browse filesBrowse the repository at this point in the historyBrowse files
The resulting `.session` file contains account credentials. Keep it private and
229
+
do not commit it. The repository's `.gitignore` already excludes session files.
230
+
231
+
For a labeled account, use `--account` with the same label:
232
+
233
+
```bash
234
+
uv run telegram-mcp-migrate-session --account work
235
+
```
236
+
237
+
This reads `TELEGRAM_SESSION_STRING_WORK` and writes the corresponding
238
+
`TELEGRAM_SESSION_NAME_WORK` instruction. Use `--target PATH` to choose another
239
+
destination. Do not run the migration while another process is using the source
240
+
session.
241
+
192
242
By default, all Telegram MCP tools are exposed. If you want to prevent MCP
193
243
clients from sending messages or performing chat/account mutations, set
194
244
`TELEGRAM_EXPOSED_TOOLS=read-only` to expose only tools annotated with
@@ -374,8 +424,10 @@ Telegram throttles and may flag accounts that open many parallel sessions.
374
424
375
425
Every tool call also has a server-side ceiling of 55 seconds, configured with
376
426
`TELEGRAM_TOOL_TIMEOUT_SECONDS`. A timed-out Telegram request returns an explicit
377
-
MCP error instead of leaving the client waiting indefinitely. Set the value to
378
-
`0` only for a deliberately unbounded operator session.
427
+
MCP error instead of leaving the client waiting indefinitely. The error says
428
+
that completion is unknown: a write may already have succeeded, so check the
429
+
destination before retrying. Set the value to `0` only for a deliberately
430
+
unbounded operator session.
379
431
380
432
Register the shared server with clients:
381
433
@@ -539,12 +591,13 @@ bypassing the proxy.
539
591
540
592
## File Path Security
541
593
542
-
File-path tools are disabled until allowed roots are configured. This affects tools such as `send_file`, `download_media`, `upload_file`, `send_voice`, `send_sticker`, `set_profile_photo`, and `edit_chat_photo`.
594
+
File-path and media tools (`send_file`, `download_media`, `upload_file`, `send_voice`, `send_sticker`, `set_profile_photo`, `edit_chat_photo`, and `send_album`) are registered and supported, but remain strictly disabled by default until allowed roots are configured (safe-by-default to prevent unauthorized file access).
543
595
544
596
Allowed roots can come from:
545
597
546
-
- Server CLI arguments, used as a fallback.
547
-
- MCP client Roots, when supported by the client.
598
+
-**Environment Variable (`TELEGRAM_ALLOWED_ROOTS`):** Semicolon- (`;`) or comma- (`,`) separated paths (also supports colon `:` on POSIX systems). Ideal for Docker, headless daemon setups, and MCP clients that pass settings via environment.
599
+
-**Server CLI arguments:** Positional folder paths passed to `main.py`, used as a server-side fallback.
600
+
-**MCP client Roots:** Configured directly in supported MCP clients (`roots/list`).
548
601
549
602
Security behavior:
550
603
@@ -567,13 +620,20 @@ Security behavior:
567
620
and `upload_file` have no extension limit by default; see
568
621
`TELEGRAM_FILE_EXTENSIONS` above to add one.
569
622
570
-
Run with allowed roots:
623
+
Run with allowed roots via environment variable:
624
+
625
+
```bash
626
+
# Semicolon- or comma-separated roots
627
+
TELEGRAM_ALLOWED_ROOTS="/data/telegram,/tmp/telegram-mcp" uv run main.py
628
+
```
629
+
630
+
Or run with allowed roots via CLI positional arguments:
571
631
572
632
```bash
573
633
uv run main.py /data/telegram /tmp/telegram-mcp
574
634
```
575
635
576
-
From an MCP client configuration, pass the same roots after `main.py`:
636
+
From an MCP client configuration, you can pass roots via `env` or as arguments after `main.py`:
577
637
578
638
```json
579
639
{
@@ -751,7 +811,7 @@ Telegram messages, display names, chat titles, and button labels are untrusted c
751
811
Then set `TELEGRAM_SESSION_STRING` in `.env`. The MCP server does not perform
752
812
interactive phone-code login over stdio.
753
813
-**Invalid API credentials:** verify `TELEGRAM_API_ID` and `TELEGRAM_API_HASH` at [my.telegram.org/apps](https://my.telegram.org/apps).
754
-
-**Database is locked:**prefer string sessions, or make sure no other process is using the same file session.
814
+
-**Database is locked:** make sure no other process is using the same file session.
755
815
-**`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).
756
816
-**File tools are disabled:** pass allowed roots or configure MCP Roots in your client.
757
817
-**Path rejected:** ensure the path is inside an allowed root and does not use traversal or wildcard patterns.
0 commit comments