mcp-telegram-agent

io.github.a19901201由 GitHub 帳號 a19901201 發布v0.1.8更新於 Nov 5, 2026

Full Telegram Bot control for AI agents via pure Bot API: zero login risk, one Bot Token.

已驗證STDIO僅桌面檔案與儲存溝通與協作

概覽

AI 產生的概覽

Telegram 機器人伺服器,讓助理傳送訊息、本機檔案、媒體、投票與位置到聊天,並編輯或刪除自己送出的訊息。

可以做什麼
  • 傳送帶行內按鈕或底部鍵盤的格式化文字訊息,並顯示輸入中、上傳中等狀態
  • 上傳本機檔案:文件、圖片、影片、音訊或語音,以及 2 至 10 個圖片或影片組成的相簿
  • 發布互動卡片:投票與測驗、地圖位置、名片聯絡人與動畫骰子
  • 編輯先前訊息的文字或鍵盤,或刪除機器人自己送出的訊息
適用情境
適合讓助理把通知、報告、日誌或截圖推送到手機、群組或頻道,也適合在 Telegram 聊天中發起簡單的投票與測驗,而不必使用個人帳號。
執行需求
以 Python 套件在本機執行,通常透過 uvx 啟動。需要 BotFather 提供的機器人權杖與預設聊天 ID,透過 TELEGRAM_BOT_TOKEN 與 TELEGRAM_DEFAULT_CHAT_ID 環境變數提供;兩者在啟動時可省略,但實際傳送時需要。目標使用者須先與機器人開始對話,機器人須為群組或頻道成員或管理員。需要連線至 Telegram Bot API 的網路。
安裝前請注意
機器人權杖可控制該機器人,須妥善保密。工具會把本機檔案傳送到 Telegram 聊天,檔案路徑與內容會離開本機。傳送、編輯與刪除都是聊天中的實際操作;刪除僅對機器人自己送出的訊息有效。明確指定 chat_id 可向機器人能觸及的任一聊天發布內容。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

📬 mcp-telegram-agent

Give your AI agent full Telegram Bot superpowers — zero login risk, zero setup.

A Model Context Protocol (MCP) server empowering AI agents with Telegram Bot capabilities. Built with Python (SDK-compatible with both mcp 1.x FastMCP and 2.x MCPServer), designed to work seamlessly out-of-the-box with uvx and modern AI coding agents like VS Code Cline and Claude Desktop. Also includes the ultra-short command alias tg-agent.

[PyPI Version] [Python Versions] [PyPI Downloads] [License: MIT]

English · 繁體中文 · 简体中文

🔐 Stop giving AI your personal Telegram account credentials.

mcp-telegram-agent is a lightweight, zero-login-risk notification and delivery tool — just one Bot Token sends local files, reports, interactive keyboards, and rich notifications straight to your phone.


✨ Highlights

  • Pure Bot API Architecture — Zero login session risk, no SMS codes or sensitive credential files needed.
  • Dual CLI Entry Points — Call via standard mcp-telegram-agent or the compact tg-agent alias.
  • Full Keyboard Support — Effortlessly construct dynamic Inline Keyboards (with URLs or callback data) and custom Reply Keyboards.
  • Rich Media & Local Files — Deliver logs, reports, source code, images, audio, voice notes, videos, and multi-image albums (2–10 files).
  • Interactive Tooling — Launch quizzes, single/multiple-choice polls, GPS coordinates, digital contact cards, and animated dice.
  • Message Lifecycle — Broadcast bot statuses (typing, uploading) and edit or delete messages on the fly.
  • Instant uvx Execution — Run directly with no virtual environments or manual package installs.

🚀 Quick Start

1️⃣ Create a Telegram Bot & Get the Token

  1. Open Telegram and search for @BotFather (verified blue check).
  2. Send /newbot and follow the prompts: choose a display name, then a username ending in bot (e.g. my_alert_bot).
  3. BotFather replies with your Bot Token, e.g. 123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Keep it secret — anyone with this token can control your bot.
  4. Important: open your new bot's chat and press Start (or send /start). A bot cannot message a user who has never started a conversation with it.

2️⃣ Get Your Personal Chat ID

  1. Send any message (e.g. "hi") to your new bot.
  2. Open this URL in a browser, replacing <YOUR_BOT_TOKEN> with your token: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
  3. In the JSON response, locate "chat":{"id": 123456789, ...} — that number is your Chat ID.
    • Alternative: send any message to @userinfobot and it replies with your ID.

3️⃣ Send to Groups or Channels (Optional)

  • Add the bot to the group first (via group settings → Add members). For channels, the bot must be added as an administrator to post.
  • Group IDs are negative numbers (e.g. -1001234567890). To find one:
    • Temporarily add @userinfobot to the group and forward a group message to it, or
    • Disable the bot's Group Privacy via @BotFather (/setprivacy → select your bot → Disable), post a message in the group, then check getUpdates as above.
  • Once the bot is a member of the group/channel, it can send messages there — no extra configuration needed.

4️⃣ Sending to Any Chat at Runtime

TELEGRAM_DEFAULT_CHAT_ID is only the fallback target. Every tool accepts an optional chat_id parameter, so you can simply ask your AI agent to "send this to chat ID -1001234567890":

  • chat_id omitted → the message goes to the TELEGRAM_DEFAULT_CHAT_ID from your config.
  • chat_id provided → the message goes to that user/group/channel instead.
  • Requirement: the bot must be a member of that group/channel (or the target user must have pressed Start on the bot).

5️⃣ Configuration for AI Clients

Add the configuration below to your MCP settings file (e.g., cline_mcp_settings.json or claude_desktop_config.json).

✅ Example A — Universal Default (Recommended)

A universal configuration that works with every MCP client — just fill in your bot token and chat ID:

json
{  "mcpServers": {    "Telegram": {      "command": "uvx",      "args": ["mcp-telegram-agent"],      "env": {        "TELEGRAM_BOT_TOKEN": "YOUR_TELEGRAM_BOT_TOKEN",        "TELEGRAM_DEFAULT_CHAT_ID": "YOUR_CHAT_ID"      }    }  }}

💡 Both env variables are optional. If they are missing, the server still starts normally — it returns a clear, human-readable error only when a tool call actually needs the token or the fallback chat ID. This also allows a credential-free trial run with no env block at all:

json
{  "mcpServers": {    "Telegram": {      "command": "uvx",      "args": ["mcp-telegram-agent"]    }  }}

🧰 Available Tools

ToolDescription
send_text_messageSend Markdown/HTML text with inline buttons or custom reply keyboards.
send_local_documentSend any local file (PDF, CSV, code, logs, archives).
send_local_photoSend image files with captions and inline buttons.
send_local_videoSend video files as native players.
send_local_audio_or_voiceSend music tracks or native voice audio notes.
send_media_albumDeliver 2 to 10 photos or videos as a grouped carousel.
send_pollCreate interactive single/multiple choice polls or scored quizzes.
send_locationBroadcast map location points via coordinates.
send_contactShare phone contact cards.
send_diceSend animated dice, basketball, football, or slot machines.
send_chat_actionDisplay temporary bot statuses (typing, uploading).
edit_message_textDynamically update previously sent text and keyboards.
delete_messageClean up or remove specific messages.

💬 Usage Examples

Once configured, simply talk to your AI agent in natural language — it picks the right tool automatically. Below are typical requests together with the tool calls the agent makes:

📢 Send a formatted notification

"Tell me in Telegram that the nightly build succeeded, with a button linking to https://example.com"

json
{  "tool": "send_text_message",  "arguments": {    "text": "✅ *Nightly build succeeded!*",    "parse_mode": "Markdown",    "inline_buttons": [[{"text": "Dashboard", "url": "https://example.com"}]]  }}

📁 Share local files

"Upload logs/app.log to my Telegram and summarize the errors"

json
{  "tool": "send_local_document",  "arguments": {    "file_path": "logs/app.log",    "caption": "Error log summary: 3 timeout warnings"  }}

🖼️ Send an album

"Send the three screenshots in screenshots/ to my Telegram as one album"

json
{  "tool": "send_media_album",  "arguments": {    "file_paths": ["screenshots/1.png", "screenshots/2.png", "screenshots/3.png"],    "caption": "Latest UI screenshots"  }}

🗳️ Run a quiz in a group

"Post a quiz to chat ID -1001234567890: which port does HTTPS use? Options 80 / 443 / 8080, the answer is 443, with a short explanation"

json
{  "tool": "send_poll",  "arguments": {    "chat_id": "-1001234567890",    "question": "Which port does HTTPS use?",    "options": ["80", "443", "8080"],    "type": "quiz",    "correct_option_id": 1,    "explanation": "HTTPS defaults to port 443."  }}

♻️ Update or clean up messages

"Change that deployment notice to 'finished', then delete the old reminder (ID 120)"

json
{  "tool": "edit_message_text",  "arguments": { "message_id": 123, "text": "🚀 Deployment **finished**" }}
json
{  "tool": "delete_message",  "arguments": { "message_id": 120 }}

💡 When chat_id is omitted, messages go to TELEGRAM_DEFAULT_CHAT_ID; pass it explicitly to reach any user, group, or channel — see step 4️⃣ above.


🛠️ Development & Release Flow

  • Develop against main — all feature work and PRs land here.
  • Publishing happens only from the release branch: open a PR main → release, bump version in pyproject.toml within the PR, then merge — CI builds and publishes to PyPI automatically, and creates a matching GitHub Release (v* tag + auto-generated notes).
  • If the version was not bumped, the workflow skips publishing with a clear warning — docs-only PRs won't break CI.
  • Direct pushes to release are blocked by branch protection; always go through a PR.

📄 License

This project is licensed under the MIT License.

來源:README.md,提交 69e7f86

工具

13

send_text_message

Send text messages with Markdown/HTML formatting, silent mode, protection, inline buttons, or custom reply keyboards. 發送文字訊息。支援 Markdown 與 HTML 格式解析、靜音推播、內容保護、行內按鈕與底部鍵盤。

輸入參數text必填chat_idparse_modeinline_buttonsreply_keyboardprotect_contentremove_keyboardone_time_keyboarddisable_notification

send_chat_action

Broadcast ongoing bot status to the user (e.g., typing, uploading document, recording). 向使用者廣播機器人當前的操作狀態,如打字中、上傳檔案中等。

輸入參數actionchat_id

send_local_document

Send any local file (code, reports, logs, zip, pdf) as a general document. 傳送本機任何檔案給使用者,涵蓋程式碼、日誌、PDF 與壓縮檔等。

輸入參數captionchat_idfile_path必填parse_modeinline_buttonsdisable_notification

send_local_photo

Send a local image file as a full-preview photo. 發送本機圖片檔案,以照片預覽格式呈現。

輸入參數captionchat_idparse_modephoto_path必填inline_buttons

send_local_video

Send a local video file (MP4, etc.) as a playable streaming video. 發送本機影片檔案,以內嵌播放器形式呈現,支援串流播放。

輸入參數widthheightcaptionchat_iddurationvideo_path必填inline_buttonssupports_streaming

send_local_audio_or_voice

Send a local audio file as a music track or a native voice note (OGG/Opus recommended). 發送本機音訊檔案:mode=audio 以音樂曲目呈現(可附標題與演出者); mode=voice 以原生語音訊息呈現(建議使用 OGG/Opus 編碼)。

輸入參數modetitlecaptionchat_iddurationfile_path必填performerinline_buttons

send_media_album

Send 2 to 10 local photos or videos as a single grouped album (carousel). 批次發送 2 至 10 個本機圖片或影片,組合成輪播相簿。

輸入參數captionchat_idfile_paths必填protect_contentdisable_notification

send_poll

Send a poll or quiz card with clickable options. 發送投票或測驗卡片,供使用者點選。type=quiz 時可指定正確選項與解析說明。

輸入參數typechat_idoptions必填question必填explanationis_anonymouscorrect_option_idallows_multiple_answers

send_location

Send a geographic location card that opens directly in the map app. 發送地理位置卡片,可直接開啟地圖導航。

輸入參數chat_idlatitude必填longitude必填

send_contact

Send a vCard contact so the user can save it to their address book. 發送名片聯絡人,可儲存至通訊錄。

輸入參數chat_idlast_namefirst_name必填phone_number必填

send_dice

Send an animated random-value emoji (dice, dart, basketball, football, bowling, slot machine). 發送擲骰子等動態隨機結果的動畫元件。

輸入參數emojichat_id

edit_message_text

Edit the text or keyboard of a previously sent message (does not work for media albums). 編輯先前已發送的文字訊息內容或鍵盤佈局。

輸入參數text必填chat_idmessage_id必填parse_modeinline_buttonsreply_keyboardremove_keyboardone_time_keyboard

delete_message

Delete a specific message by ID (can only delete messages sent by the bot). 刪除指定 ID 的訊息(僅能刪除機器人自己發送的訊息)。

輸入參數chat_idmessage_id必填

版本歷史

1
  1. v0.1.8最新Nov 5, 2026

評分

已滿足適用檢查項的 90%

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

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

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

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分