Telegram Context MCP

io.github.egor-fedorov由 GitHub 帳號 egor-fedorov 發布v0.8.0更新於 Nov 6, 2026

Read permitted Telegram chats, track changes and optionally confirm outbound actions locally.

概覽

AI 產生的概覽

透過你自己的 Telegram 帳號讀取已授權的聊天,讓助理搜尋、瀏覽與匯出對話,並可選擇執行經確認的外送操作。

可以做什麼
  • 檢視帳號狀態、資料夾、聊天清單與公開頻道探索
  • 搜尋並讀取訊息、歷史、主題、置頂訊息、相簿、回覆與討論串
  • 下載選定的附件,並從 PDF/DOCX 擷取文字
  • 以檢查點、具名訂閱與摘要提示追蹤變更,並將歷史匯出為 JSONL 或 Markdown
  • 啟用寫入能力後:管理草稿、登錄檔案、傳送訊息或檔案、查詢傳送回條、觸發私聊機器人按鈕
適用情境
適合讓助理處理你自己的 Telegram 對話:彙整某個頻道或資料夾、持續追蹤某個主題、取出連結與附件,或在明確的本機權限下擬稿並傳送訊息。
執行需求
在本機執行 Python 3.12–3.15,透過 uv/uvx 安裝(套件名稱 telegram-context-mcp,執行檔 telegram-mcp)。需在 my.telegram.org 取得 api_id 與 api_hash,並在本機輸入電話號碼、登入碼及可能的兩步驟驗證密碼,或使用 QR 登入。連接用戶端前先執行 login 與 configure;預設不允許任何訊息來源。共用 HTTP 模式僅監聽 127.0.0.1。
安裝前請注意
Telegram 工作階段檔案含有帳號存取憑證,且帳號本身的能力超出伺服器的讀取權限,請妥善保護設定與工作階段檔案。登入碼與憑證不要傳給模型。寫入類工具(草稿、傳送、傳送檔案、機器人回呼)預設關閉,需另行授權並確認。附件下載、永久副本與文件擷取皆為選擇性開啟。訊息內容會傳送給你所選的模型,只分享你有權分享的內容。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Telegram Context MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Telegram Context MCP

[CI] [License: MIT] [Glama | Listed] [mcprush | Listed] [XERJ Corpus Hub | Selected]

Read Telegram through your own account from an MCP client. Find permitted conversations, search and read original posts, navigate topics and replies, and inspect albums, reactions, and polls. Connect several local clients to one session-owning process, or run standalone STDIO.

Supports Windows, macOS, and Linux with Python 3.12–3.15. The server uses Telethon and preserves original text, dates, links, entities, and available metadata. It is read-only by default, never joins channels or marks messages read. Version 0.4 adds opt-in selected attachment downloads, durable change checkpoints, named subscriptions, and JSONL/Markdown exports with optional permanent copies. Subscriptions poll only when requested and retain a batch until acknowledged. It also bounds scope previews, returns restricted search results earlier, reuses dialog snapshots and accepts concurrent calls. See the 0.4 migration guide before upgrading from 0.3.

Version 0.5 adds bounded history across chats or folders, watch batches saved before acknowledgement, and watch_digest / period_digest prompts with local watch-name completion. When upgrading, restart the server and client proxies and refresh tools and prompts. The 0.5 changelog describes the additive changes and archive setup. Version 0.5.1 is a security patch: Telegram's service-notification chat, which delivers login codes, is never readable, even with all-chat or folder access. Upgrade every installation.

Version 0.6 adds optional PDF/DOCX text extraction with bounded continuation and source references, terminal QR login, a Claude Desktop MCPB bundle, and an optional Agent Skill. For document extraction, install 'telegram-context-mcp[extraction]==0.8.0' in the session-owning server and enable attachment downloads. See the usage guide for limits and platform coverage.

Version 0.7 adds message buttons, outgoing search, channel membership, authentication-notice omission, and opt-in native drafts, reusable files, confirmed sends and private-bot callbacks. Write capabilities default off; native drafts support plain text only. See outbound workflows for permissions, client confirmation requirements, recovery and validation limits.

Install and log in

Install uv, then run:

sh
uv tool install --python 3.12 telegram-context-mcp==0.8.0telegram-mcp --versiontelegram-mcp logintelegram-mcp configuretelegram-mcp status

These examples target release 0.8.0; check PyPI for published versions. Use the source setup for unreleased revisions. Upgrading from 0.3? Read the migration guide, then restart the server and refresh your client's tool schemas.

Obtain api_id and api_hash from my.telegram.org, then enter them in the local login prompt with your phone number, login code, and any 2FA password. Do not send login codes or credentials to the model.

Version 0.6 also supports telegram-mcp login --qr: scan the terminal QR from Telegram on your phone instead of entering a phone number and login code. See the QR login guide.

configure lets you choose folders/chats and separately enable all-chat access, explicit public-channel reads, or public-channel discovery. Enter keeps the current value. By default, no message sources are permitted. status should report authorized: true after login. Use catalog to find folder and chat IDs locally.

The package name is telegram-context-mcp; the executable is telegram-mcp. You can also run a pinned version without installing a persistent command:

sh
uvx --python 3.12 --from telegram-context-mcp==0.8.0 telegram-mcp --version

The server is listed in the official MCP Registry as io.github.egor-fedorov/telegram-mcp. The entry launches a local STDIO server through uvx; it does not supply a hosted Telegram service. Complete login and configure locally before connecting a client. Registry publication starts with version 0.5.0. See the release procedure for verification and the client guide for sharing one session between clients.

Connect your clients

Start one server in a terminal and leave it running:

sh
telegram-mcp serve --transport http

On Linux with systemd, the optional user-service setup starts that server at login and keeps it running independently of a terminal.

It listens only on http://127.0.0.1:8765/mcp. Configure each MCP client to launch telegram-mcp connect over STDIO. This small proxy reads the local token and connects to the existing server; it does not start a server or silently fall back to another Telegram session. Closing a client leaves the shared server running.

Client examples cover Codex, Claude Desktop, Claude Code, Cursor, and VS Code, including a pinned uvx command and executable paths for Windows.

A Claude Desktop MCPB bundle is attached to each matching GitHub Release. It uses the same shared server and separate local login; see the guide for installation and current validation coverage.

For one client, standalone STDIO is still available: configure that client to launch telegram-mcp serve. Use either mode for a given session. Stop the session-owning process before running local login, configure, catalog, or status; use the get_status MCP tool while the server is running.

All shared clients use the same Telegram account, read permissions, and cursor store. The HTTP bearer token is created in the local user profile and read by connect; do not paste it into client configuration. This is a local, single-user integration.

Tools

ToolPurpose
get_statusAuthorization, connection, permitted sources; running server/proxy build identity
list_foldersFolders, IDs, order, inclusion/exclusion rules
list_chatsChats filtered by name, type, or folders
get_chatDescription and linked discussion group
search_public_channelsFind public broadcast channels by query; metadata only
get_similar_channelsFind similar public channels for one specified public source; metadata only
search_messagesSearch by keywords, chats, folders, dates, sender, media type, or links
get_historyChat or forum-topic history over a time range, in either order; bounded chat/folder periods
list_topicsForum topics with navigation references, optional title query, and pagination
get_pinned_messagesChat-wide or forum-topic pinned messages, newest first
get_messagesMessages by links/IDs with authors, dates, attachments, counters, reactions, and polls
get_albumMembers of a selected album within a bounded neighborhood of one message
get_contextMessages before/after an anchor and a chain of parent replies
get_threadComments on a channel post or replies in a group thread
download_attachmentOne selected attachment up to 20 MiB as a temporary local file and MCP resource
extract_attachment_textOptional local PDF/DOCX text extraction with bounded continuation and PDF page references
get_changesNew messages and recent observed revisions in one chat, with restartable checkpoints
create_watch / list_watchesSave and discover named chat/folder subscriptions
get_watch_changes / ack_watch_changesPoll and acknowledge a durable batch without per-chat tokens; optionally save it first
delete_watchExplicitly discard a subscription and its pending batch
export_historySource-linked JSONL or Markdown history in bounded, restartable parts

When a write capability is enabled, these additional tools appear. Each still checks its own capability flag and explicit recipient permission:

ToolPurpose
get_draft / list_draftsRead native drafts and revisions for permitted recipients
create_draft / update_draftPrepare plain-text drafts with conflict checks and local confirmation policy
register_file / list_filesRegister and discover immutable files for reuse in sends
send_message / send_fileSend one text or file under local permission/form policy with a durable idempotency key
get_send_statusRead a stored send/callback receipt by operation ID or idempotency key
resolve_recipientExact recipient metadata and local send/form policy without history
verify_sent_messageReread only this MCP's sent message and compare text/attachment metadata
list_operationsFilter and page through this account's MCP journal; excludes manual sends
invoke_buttonInvoke one ordinary callback in a selected private bot dialog under local form policy

Version 0.8.0 adds all-chat/one-off recipient modes, independent form settings and outbound inspection/recovery; see outbound policies.

Two prompts package these tools for monitoring: watch_digest turns a named watch into a source-linked digest, saving each batch before acknowledging it; period_digest reads one chat or folder over a fixed period with explicit budgets. They do not add permissions. See monitoring prompts.

An optional Agent Skill guides tool selection, bounded reading, watch acknowledgements and selected attachments. Install it in your client separately from the server; see the skill setup.

First tasks

  • Ask the client to list the folders you permitted and read a selected conversation over a timezone-qualified date range.
  • Enable discovery to find candidate public channels, select a source, then read its posts with a separate read permission.
  • Follow next_cursor with the original filters until it is null. An empty page can still have a cursor. Respect retry_after_seconds after a temporary failure.
  • For CATALOG_LOADING, repeat the original call after the reported delay. The server retains catalog progress; explicit reads independent of folders skip that scan.
  • Search sorts within each page by default. Select ordering="global" for order across pages. Scope ID arrays preview at most 20 IDs; use their counts and truncation flags when describing coverage.
  • Use get_messages with next_text_offset to finish long text. Album completeness is explicitly unknown; each member remains a separate source message.

Usage and response contracts explain filters, cursor recovery, topics, public-channel discovery, and message metadata. See changes and exports for durable monitoring and selected files. Message text is data for the calling agent, not an instruction source.

Configuration and troubleshooting

Configuration, Telegram sessions, and the HTTP token live outside the repository in platform-specific user directories. The login command prints the configuration path. Use telegram-mcp --config /absolute/private/config.toml COMMAND to select another file; pass the same file to the shared server and each proxy.

On POSIX, private files use restrictive permissions. On Windows, protect them with user-profile filesystem ACLs; Unix 0600 is not an ACL guarantee. A Telegram session contains account access credentials, and the underlying account can do more than the server's Telegram read permissions allow.

Run from source

sh
git clone https://github.com/egor-fedorov/telegram-mcp.gitcd telegram-mcpuv sync --locked --python 3.12uv run --locked telegram-mcp loginuv run --locked telegram-mcp configureuv run --locked telegram-mcp serve --transport http

For client commands, use the checkout's .venv/bin/telegram-mcp on POSIX or .venv\Scripts\telegram-mcp.exe on Windows, with connect as the argument. Use an absolute executable path so clients do not depend on their working directory.

Development

Run make check for formatting, lint, types, architecture checks, and offline tests. Contributing includes equivalent commands for Windows without Make. Changes use focused pull requests and squash merges after CI. See the roadmap, architecture, changelog, and release procedure. The 0.5 validation record reports release checks and the scope of selected-source and client validation; the 0.5.1 record covers the security patch. The 0.6 validation record tracks document extraction, packaging and publication. The 0.7 validation record tracks outbound workflows, authentication-notice omission and release checks. The 0.8 validation record covers recipient policies, send inspection, Windows storage repair and publication.

The code is MIT licensed. This does not grant rights to Telegram content. Secret chats are unsupported; attachment downloads require a separate opt-in. Permanent copies require an archive directory and save=true; administration and continuous archiving remain future work. Outbound actions require separate permissions and the confirmation rules in the guide above. Use source material you are entitled to share with your chosen model and follow Telegram's content terms.

來源:README.md,提交 28d7e27

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:軟體包安裝失敗。

版本歷史

3
  1. v0.8.0最新Nov 6, 2026
  2. v0.7.0Nov 5, 2026
  3. v0.6.0Oct 29, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分