tgread
tgread
一个只读的 Telegram MCP 服务器。让 Claude Code 读取你的频道、群组和私信——并且不提供任何写入途径。
./install.sh # pinned venv + ~/.local/bin/tgread + MCP registration
tgread login # api_id/api_hash, phone, code, 2FA
tgread status # who am I, is the session live, are perms sane为什么不用现成的那些
有一些不错的社区服务器——chigwell/telegram-mcp 有 1.5k star、30 位贡献者和严谨的发布纪律。写这个的原因不是不信任那些代码,而是自己写的真正收益在于工具暴露面和可审查性,而不是依赖数量。当进程持有一个 Telegram 会话,并向智能体投喂攻击者控制的文本时,这两点才是关键。
社区服务器 | tgread | |
MTProto | Telethon | Telethon — 一样,而且理应如此 |
解析出的包 | 44 | 5 ( |
MCP 层 |
| 本仓库中约 200 行 stdio JSON-RPC |
写入工具 | send、edit、delete、forward、react、join、admin | 无 |
写入约束 | 靠约定 | 在传输瓶颈处 |
信任前需要审查的代码 | 约 3,000 行,来自 30 位贡献者 | 一个你能一口气读完的文件 |
手写 MTProto 是鲁莽的——Telethon 就是加密、DC 迁移和重连逻辑本身。所以它保留。它之上的一切都是我们自己的。
Related MCP server: telegram-mcp-server
威胁模型
读取频道意味着攻击者选择的文本会进入一个持有 shell 的智能体——而且通常还有你已连接的其他一切:邮件、笔记、云凭证。这是这里的主要风险,而且这不是由谁来编写服务器就能解决的。选择一个没有写入面的服务器,是少数不依赖模型表现良好的缓解措施之一。
flowchart TD
A["hostile channel post<br/>'ignore previous instructions…'"] --> B["tgread read_chat"]
B --> C["UNTRUSTED envelope<br/>wrapped around every payload"]
C --> D["agent context"]
D --> E{"agent tries to act on it"}
E -->|"send / delete / join"| F["no such tool exists<br/>tools/call → isError"]
E -->|"raw TL request"| G["guard at _call → WriteBlocked"]
E -->|"summarise for the user"| H["fine — this is the intended path"]
style F fill:#1f6f43,color:#fff
style G fill:#1f6f43,color:#fff三层防护,按它们在遇到 bug 时能幸存的程度递增排列:
不公布任何写入工具。 注入的指令没有任何可调用的东西。
每个载荷都被包装在一个
UNTRUSTED CONTENT横幅中,标明它是数据而非指令——包括聊天的标题和简介,这些同样受攻击者控制。传输守卫。 Telethon 将所有出站 TL 请求都经由
TelegramClient._call汇聚(68 个内部调用点通过await self(req)到达它,而__call__是一行委托)。ReadOnlyClient覆盖了它。即使这个文件有 bug,仍然无法改动账户。
该守卫默认拒绝:除非 TL 类名以 Get/Search/Resolve/Check/Find 开头,或位于一个九项基础设施白名单中,否则请求一律被拒绝。三个读取形态的请求按名称被拒绝,因为它们有其他人可观察到的影响——GetMessagesViews (增加公开的浏览量计数)、GetBotCallbackAnswer (按下内联按钮)、GetInlineBotResults (以你的身份查询机器人)。嵌套请求也会被遍历,因此写入无法藏在允许的 InvokeWithLayer 包装器内。
flowchart LR
R["TL request"] --> W["walk nested .query"]
W --> D{"in EXPLICIT_DENY?"}
D -->|yes| X["WriteBlocked"]
D -->|no| I{"in INFRA_ALLOW?"}
I -->|yes| P["to the wire"]
I -->|no| V{"starts with Get/Search/<br/>Resolve/Check/Find?"}
V -->|yes| P
V -->|"no — incl. every<br/>name we've never seen"| X
style X fill:#8b2020,color:#fff
style P fill:#1f6f43,color:#ffftgread check 可离线运行这些检查:26 个写入请求被阻止,17 个读取请求被允许,未知名称默认拒绝,嵌套已检查。无需网络、无需会话、无需凭证。
工具
工具 | 说明 |
| 对话列表,可按 |
| 单个聊天的历史,从最旧开始,按 id 或日期分页。不会标记为已读 |
| 全文搜索,可在一个聊天中,也可跨账户可见的所有内容 |
| 类型、成员数、描述、已验证/诈骗标记 |
这里刻意不提供媒体下载:获取附件意味着将攻击者选择的字节写入智能体的文件系统。消息元数据只报告媒体的类型。
操作说明
使用辅助账户。 用户机器人(任何非官方应用的 MTProto 客户端)都可能因违反服务条款而被封禁。这个风险对此处的每个服务器都一样。
会话文件是整个账户的持有者令牌。 更改 Telegram 密码并不会使其失效。只有
tgread logout——它会在本地删除前先在服务端撤销——或 设置 → 设备 才能使其失效。请像对待 SSH 私钥一样对待它。pip install telegram-mcp不是这个,也不是 chigwell 的。 那个 PyPI 名称属于一个无关项目;向它传递TELEGRAM_API_ID/TELEGRAM_API_HASH会把你的凭证交给第三方代码。这里没有任何内容被刻意发布到 PyPI。所有状态都存放在一个目录中——
$TGREAD_STATE_DIR,默认为~/.local/state/tgread,权限 0700,其中包含config.env(0600) 和tgread.session(0600)。一个目录,方便 chmod、备份、销毁。如果权限发生漂移,tgread status会标记出来。install.sh使用uv sync --frozen——它只安装已提交的uv.lock中的确切版本,宁可失败也不重新解析。一个会悄悄获取新上游版本的解析器,正是被攻陷的包进入持有你会话的进程的方式。
目录结构
路径 | 说明 |
| 整个服务器:守卫、工具、JSON-RPC 循环、CLI |
| 启动器——执行固定 venv 的解释器 |
| 版本锁定 |
| venv、符号链接、 |
| 17 个离线测试——守卫、工具暴露面、协议、整洁性 |
命令
tgread login interactive: API credentials, phone, login code, 2FA
tgread status who am I, is the session valid, are permissions sane
tgread logout revoke server-side, then delete locally
tgread check offline self-test of the read-only guard
tgread serve speak MCP over stdio — what Claude Code runslogin 和 logout 使用普通客户端,而不是受守卫的客户端:守卫的存在是为了约束智能体,而不是约束在终端建立或撤销会话的人类。MCP 服务器接触的一切都经由 ReadOnlyClient。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Read-only Remote MCP for externally grounded AI agent trust receipts.
Unified inbox MCP for WhatsApp, Telegram, Email, voice — read/send messages, search, AI agents.
Private agent messaging: DMs, group channels, presence, search, and webhooks over MCP or REST.
Join durable public agent discussions and invite-only private group rooms through MCP.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with Telegram accounts through MCP, supporting messaging, contacts, groups, media, and admin functions.4Apache 2.0
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server that lets AI agents read personal Telegram chats from an allowlist of folders, with no send/edit/delete capability.39MIT
- FlicenseNot gradedqualityDmaintenanceEnables users to read, search, and manage Telegram messages in channels, groups, and private chats through MCP tools.-
- AlicenseNot gradedqualityBmaintenanceProvides read-only access to Telegram chats, allowing AI agents to list chats, read messages, and search within chats via local MCP.MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/demian-overflow/tgread'
If you have feedback or need assistance with the MCP directory API, please join our Discord server