Tdl Mcp

io.github.rixile9999由 GitHub 账号 rixile9999 发布v1.1.0更新于 Oct 24, 2026

Read-only Telegram MCP server wrapping the tdl CLI: list chats, read messages, download media.

已验证STDIO仅桌面文件与存储沟通与协作

概览

AI 生成的概览

基于 tdl 命令行的只读 Telegram MCP 服务器:列出会话、读取消息、下载媒体,均针对你自己的账号。

可以做什么
  • 检查本地 tdl 会话是否已登录,以及可见会话数量
  • 按名称、用户名或 ID 的子串筛选并列出会话
  • 读取某个会话的近期消息,可限定条数、起始消息 ID 和是否含文本
  • 从会话下载媒体文件,可按扩展名筛选并指定保存目录
  • 按指定的 Telegram 消息链接下载其中的媒体
适用场景
适合让助手检索你自己的 Telegram 会话、汇总或提取频道近期消息,或把频道里发布的 PDF、表格等文件归档到本地目录,同时不授予其发送或删除消息的能力。
运行要求
以 stdio 方式在本机运行,需要 Node.js 22 或更高版本;需先安装 tdl 命令行工具,并由用户在终端完成一次扫码登录,会话保存在 ~/.tdl。可选环境变量 TDL_BIN(tdl 可执行文件路径)和 TDL_NS(用于区分不同账号的命名空间)。
安装前请注意
~/.tdl 中的会话是完整的用户账号凭据,能读取它的人即可操作你的 Telegram 账号,请勿放入代码仓库或共享备份。下载会把文件写入指定目录,默认为 ~/Downloads/telegram。按 Telegram 服务条款,对本人账号进行过于频繁的抓取可能导致账号受限,应控制消息范围。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Tdl Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

tdl-mcp

[CI] [npm] [License: MIT]

Read-only Telegram access for Claude and other MCP hosts, powered by the tdl CLI.

List your chats, read recent messages, and download media — from your own Telegram account — with five simple tools. It never sends messages, never modifies anything, and never touches your login.

🇰🇷 한국어 문서는 여기 있습니다 → README.ko.md

Why tdl-mcp?

Most Telegram MCP servers embed an MTProto library (Telethon, gramjs, …), ask you to create your own Telegram application at my.telegram.org to get an api_id/api_hash, and many of them can send messages on your behalf.

tdl-mcp takes a different, deliberately boring approach:

  • Read-only by design. The server can list chats, export messages and download files. That's all. There is no code path that sends, edits, deletes, or logs in.
  • No api_id/api_hash setup. Login is handled once, by you, in your terminal with tdl login -T qr — scan a QR code with your phone and you're done. No Telegram app registration needed.
  • Built on a battle-tested downloader. tdl (7.5k+ ⭐) does the heavy lifting: fast parallel downloads, resume, --skip-same deduplication.
  • Tiny and auditable. One plain-JavaScript file, two dependencies (@modelcontextprotocol/sdk, zod), no build step. You can read the whole server in five minutes.
Claude / MCP host  ←stdio→  tdl-mcp (Node)  →subprocess→  tdl CLI  →MTProto→  Telegram

Quick start

1. Install tdl

sh
# macOSbrew install telegram-downloader
# Linux / WSLcurl -sSL https://docs.iyear.me/tdl/install.sh | sudo bash
# Windows (PowerShell)iwr -useb https://docs.iyear.me/tdl/install.ps1 | iex

Any version from the one pinned in .tdl-version upward should work — CI continuously tests against that pin (see Compatibility).

2. Log in to Telegram (once)

sh
tdl login -T qr

Scan the QR code with the Telegram mobile app (Settings → Devices → Link Desktop Device). The session is stored in ~/.tdl on your machine and shared by every MCP host — you log in exactly once. tdl-mcp itself never performs or refreshes logins.

3. Add the server to your MCP host

You need Node.js ≥ 22.

Claude Code:

sh
claude mcp add --scope user telegram -- npx -y tdl-mcp

Claude Desktop / any other MCP host (generic mcpServers JSON):

json
{  "mcpServers": {    "telegram": {      "command": "npx",      "args": ["-y", "tdl-mcp"]    }  }}

4. Try it

Ask your assistant things like:

"What Telegram chats do I have? Find the one about quant trading."

"Show me the last 20 messages in @some_channel."

"Download every PDF posted in that channel since message 1500 to ~/Papers."

If a tool reports that you are not logged in, run tdl login -T qr in a terminal and retry — that's the only manual step there is.

Tools

ToolArgumentsWhat it does
tg_status—Checks whether the tdl session is logged in. Never errors: returns {logged_in:true, chats:N} or {logged_in:false, hint}.
tg_chatsfilter?Lists dialogs as [{id, type, name, username}]; filter is a case-insensitive substring match on name/username/id.
tg_messageschat, last_n? (default 50, max 500), since_id?, with_text? (default true)Exports recent media messages from a chat as compact {id, date, file, text} objects (at most 200 returned; truncation is noted). since_id fetches only messages after a known id — handy for incremental reads.
tg_downloadchat, since_id?, last_n? (default 100), extensions? (csv, e.g. "xlsx,pdf"), dest? (default ~/Downloads/telegram)Downloads media from a chat with --skip-same; returns absolute paths of newly downloaded files, or a friendly "no matching files" note.
tg_download_urlurls (array of https://t.me/... links), extensions?, dest?Downloads the media of specific messages by link. Validates every url starts with https://t.me/.

chat accepts either a numeric id or an @username/domain, exactly as shown by tg_chats.

Environment variables

VariableEffect
TDL_BINPath to the tdl binary. Default: tdl on PATH, falling back to /opt/homebrew/bin/tdl (GUI-launched MCP hosts often don't inherit the Homebrew PATH).
TDL_NStdl namespace, passed as -n <ns> on every call. Use it to keep separate Telegram accounts/sessions apart.

Set them in your host's server config, e.g.:

json
{  "mcpServers": {    "telegram": {      "command": "npx",      "args": ["-y", "tdl-mcp"],      "env": { "TDL_NS": "work" }    }  }}

Compatibility & staying up to date

tdl-mcp shells out to the tdl CLI, so its real dependency is tdl's command-line surface. That surface is guarded automatically:

  • .tdl-version pins the tdl release this package is tested against.
  • scripts/contract.mjs verifies — without logging in — that every flag the server uses (chat ls -o json, chat export -c/-T/-i/-o/--with-content, dl -f/-u/-i/-d/--skip-same, global -n) still exists in that tdl binary. CI runs it on every push and PR.
  • A scheduled workflow watches tdl releases. When a new version appears it runs the contract test against the new binary and scans the release notes for breaking-change markers. Routine updates become a simple version-bump PR; anything suspicious is escalated to an AI-assisted upgrade PR that adapts the wrapper code.

So if you're on a newer tdl than the pin, chances are excellent everything just works — and if it ever wouldn't, this repo finds out before you do.

Development

sh
git clone https://github.com/rixile9999/tdl-mcp.gitcd tdl-mcpnpm installnpm test          # smoke (MCP protocol, login-free) + contract (tdl CLI surface)
  • npm run smoke spawns the server over stdio and checks the tool catalog, tg_status shape, and input validation — passes whether or not you are logged in.
  • npm run contract checks the installed tdl binary against the CLI surface the server uses. scripts/install-tdl.sh [vX.Y.Z] installs a specific (checksum-verified) tdl release if you want to test against another version.

PRs welcome. Please keep the server read-only — tools that send, edit or delete are out of scope for this project.

Security notes

  • The tdl session in ~/.tdl is a full user-account credential — anyone who can read it can act as your Telegram account. Protect it like an SSH key: don't copy it into repos, shared backups, or other machines.
  • tdl-mcp never reads or transmits the session itself; it only runs the tdl binary locally. Nothing leaves your machine except tdl's own Telegram traffic.
  • Downloads go to a directory you choose (dest), defaulting to ~/Downloads/telegram.

Telegram terms-of-service note

tdl drives a regular user session (MTProto), not a bot. Quiet, read-only, personal-use automation of your own account is generally tolerated, but aggressive crawling can get an account limited: keep ranges modest (last_n, since_id), avoid large parallel pulls, and let --skip-same do its job instead of re-downloading.

License

MIT for everything in this repository.

tdl itself is a separate project licensed under AGPL-3.0. tdl-mcp does not bundle, link, or modify tdl — it invokes the binary you installed as a separate process, so the AGPL applies to tdl, not to this wrapper. You install tdl yourself through official channels (step 1 above).

来源:README.md,提交 73115bf

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.1.0最新Oct 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分