mcp-telegram-agent
Sends messages and notifications to Telegram chats, supports onboarding, control checkpoints, and polling for replies.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-telegram-agent send a Telegram notification saying 'Hello from AI agent'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ค If you are an AI agent: read AGENTS.md first, then AGENT_SETUP.md.
๐ค MCP Telegram Agent
Send Telegram notifications directly from any MCP-compatible AI agent.
This project is a TypeScript MCP server over stdio, designed to be easy to run locally and easy to distribute via npm + npx.
โจ Features
โ Send a message to Telegram with one MCP tool call
โ Guided onboarding flow: token โ
setup codeverification โ auto config snippetโ Validate Telegram config before sending anything
โ Read recent Telegram updates to discover
chat_idandmessage_idโ Works with
npx mcp-telegram-agentin MCP configโ Token-first setup (safer than hardcoding full API URL)
Related MCP server: tgmcp
๐ฆ Installation
Option A: Use directly with npx (recommended for MCP clients)
No local clone required in production:
npx -y mcp-telegram-agentOption B: Local development
npm install
npm run check
npm run build
npm run dev๐ง Environment Variables
Recommended (default behavior)
BOT_TELEGRAM_TOKEN(required)BOT_TELEGRAM_CHAT_ID(required)
Compatibility aliases
BOT_TELEGRAM_ID(alias for chat ID)BOT_TELEGRAM_URL(legacy fallback, full sendMessage URL)
Optional
BOT_TELEGRAM_TIMEOUT_MS(default:10000)BOT_TELEGRAM_THREAD_ID(for Telegram forum topics)BOT_TELEGRAM_API_BASE_URL(advanced/testing override, default:https://api.telegram.org)
Security note: Prefer
BOT_TELEGRAM_TOKENoverBOT_TELEGRAM_URLso your secret is managed as a single token value.
๐ง MCP Client Configuration
npx setup (recommended)
{
"mcpServers": {
"telegram-agent": {
"command": "npx",
"args": ["-y", "mcp-telegram-agent"],
"env": {
"BOT_TELEGRAM_TOKEN": "123456789:AAxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"BOT_TELEGRAM_CHAT_ID": "123456789"
}
}
}
}Local build setup
{
"mcpServers": {
"telegram-agent": {
"command": "node",
"args": ["/ABSOLUTE/PATH/mcp_telegram_agent/dist/index.js"],
"env": {
"BOT_TELEGRAM_TOKEN": "123456789:AAxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"BOT_TELEGRAM_CHAT_ID": "123456789"
}
}
}
}๐ ๏ธ Exposed MCP Tools
telegram_onboarding_prepare
Prepares onboarding for a fresh token and returns:
a setup code
exact message to send (plain setup code)
MCP config template
if
botTokenis omitted and client supports elicitation, MCP requests secure token input UI
telegram_onboarding_verify
Verifies onboarding by scanning updates for the setup code (plain message, or /start <code>) and then:
discovers
chat_id+message_idbuilds a ready-to-paste MCP config JSON
optionally sends a test message automatically
supports cautious mode with explicit
chat_idconfirmation (requireChatIdConfirmation+expectedChatId)if
botTokenis omitted and client supports elicitation, MCP requests secure token input UI
send_telegram_notification
Send a message to your configured Telegram chat.
Input:
message(string, required)parseMode(HTML|Markdown|MarkdownV2, optional)disableNotification(boolean, optional)
Output example:
Notification sent to Telegram (status 200, message_id=207).
telegram_config_status
Validate env config and show active source (BOT_TELEGRAM_TOKEN vs BOT_TELEGRAM_URL).
telegram_get_updates
Fetch recent updates from Telegram to inspect:
chat_idmessage_idmessage text
username
Useful when you are still wiring your bot and need IDs.
Supports incremental polling:
fromUpdateId(fetch newer updates only)waitSeconds(Telegram long polling timeout)
telegram_send_control_checkpoint
Sends a structured checkpoint message (title + summary + control metadata) so users can reply with control actions.
Typical usage:
agent says "task done"
user replies to that checkpoint with
continue CODE123,stop CODE123, etc.
telegram_poll_control_replies
Reads new updates and filters control replies by:
replyToMessageIdcontrolCodeinstanceIdoptional
actionFilter
This is designed for multi-IDE safety and uses long polling (waitSeconds) to reduce API churn.
telegram_ack_control_reply
Sends an acknowledgement as a direct reply to the user control message, including status and summary.
๐งญ Agent Command (/setup-mcp-telegram-agent)
This repository ships:
AGENTS.mdAGENT_SETUP.md.cursor/commands/setup-mcp-telegram-agent.md
Suggested chat command:
/setup-mcp-telegram-agentExpected flow:
Install/activate MCP first with
npx -y mcp-telegram-agent(no token required yet)Ask for bot token (or direct user to create one at
https://telegram.me/BotFather#)Run
telegram_onboarding_prepareAsk user to send
<code>(plain message) to the botRun
telegram_onboarding_verifyin confirmation mode to list candidatesAsk user to confirm exact
chat_idRun
telegram_onboarding_verifyagain withexpectedChatIdApply generated MCP config
Send one test notification
๐ฒ Telegram Bot Setup (BotFather)
1) Open BotFather
Search for @BotFather in Telegram and open it.
2) Create a new bot
Send:
/newbotThen follow prompts:
Bot display name (example:
My MCP Notifier)Bot username ending in
bot(example:my_mcp_notifier_bot)
BotFather returns your token:
123456789:AAxxxxxxxxxxxxxxxxxxxxxxxxxxxxSave it securely as BOT_TELEGRAM_TOKEN.
3) Start a chat with your bot
Open your new bot and click Start (or send any message).
4) Get your chat_id and message_id
Call:
curl "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates"Then look for:
message.chat.idโ this is yourchat_idmessage.message_idโ this is the message ID
Visual guide:
๐งช Quick Test
Use your real values:
curl -sS -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage" \
-H "Content-Type: application/json" \
-d '{"chat_id":"<YOUR_CHAT_ID>","text":"โ
MCP test message"}'๐ Publish to npm
Publishing is automated with GitHub Actions + semantic-release.
After the first release, users can run:
npx -y mcp-telegram-agentโ๏ธ GitHub Actions Auto Publish
This repository includes:
.github/workflows/release.yml.releaserc.json
Behavior:
Runs on each push to
mainUses Conventional Commits to decide release type (
fix= patch,feat= minor,BREAKING CHANGE= major)Creates GitHub release + publishes to npm
Required GitHub secret:
NPM_TOKEN(npm automation token with publish permissions)
Required commit style examples:
fix: first automated release setup
feat: add support for telegram topicsFirst release target (v0.0.1):
Create and push baseline tag
v0.0.0once.Push a
fix:commit tomain.Action will publish
v0.0.1.
Commands:
git tag v0.0.0
git push origin v0.0.0
git commit --allow-empty -m "fix: bootstrap first semantic release"
git push origin main๐งฉ GitHub Repository Setup
If this is a fresh local directory:
git init
git add .
git commit -m "Initial MCP telegram agent server"
git branch -M main
git remote add origin https://github.com/tecnomanu/mcp-telegram-agent.git
git push -u origin mainโ ๏ธ Troubleshooting
chat not found:Ensure you started chat with the bot first.
Re-check
BOT_TELEGRAM_CHAT_IDfromgetUpdates.
401 Unauthorized:Token is invalid, regenerated, or malformed.
No updates in
getUpdates:Send a message to your bot, then retry.
๐ License
MIT
Available Tools
6 toolssend_telegram_notificationA
Send a notification to the configured Telegram chat. Supports: plain text, photo, audio, or document โ with an optional caption. You can send text only, media only, or media + caption together. For media: provide a media object with type and either a public url or base64Data.
Inputs: media, message, parseMode, disableNotification.
telegram_config_statusA
Check whether Telegram configuration is valid for this MCP server.
Inputs: no named parameters.
telegram_edit_messageA
Edit a previously sent Telegram message by its message_id. Use to replace the ACK with a final response.
Inputs: text (required), messageId (required), parseMode.
telegram_onboarding_prepareC
Prepare onboarding instructions to link a Telegram bot and auto-generate MCP config.
Inputs: botToken, setupCode, serverName, packageName.
telegram_onboarding_verifyB
Verify setup code in Telegram updates, require explicit chat_id confirmation, generate ready MCP config, and optionally send a test message.
Inputs: setupCode (required), limit, botToken, serverName, +5 more.
telegram_send_and_wait_replyA
Send a message to Telegram and block until a reply arrives in the same chat. Supports: plain text, photo, audio, or document โ with an optional caption. You can send text only, media only, or media + caption together. For media: provide a media object with type and either a public url or base64Data. Sends an instant ACK back to Telegram when a reply is received. Returns reply text + ack_message_id so you can later edit the ACK with your final response.
Inputs: media, ackText, message, parseMode, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 6 tools
The two sending tools (send_telegram_notification and telegram_send_and_wait_reply) overlap in message types and could be confused, though the blocking/waiting behavior distinguishes them. Other tools are clearly distinct.
Most tools follow a 'telegram_' prefix convention, but send_telegram_notification breaks the pattern by placing 'telegram' at the end. Additionally, telegram_config_status is a noun phrase rather than a verb, mixing command and state check styles.
With 6 tools, the set is well-scoped for a Telegram agent, covering onboarding, sending, waiting for replies, and editing messages without unnecessary redundancy.
The main workflow is supported: onboarding verification, sending messages, and replying via edit. A notable gap is the lack of a tool to handle incoming Telegram updates initiated by the user, but the core lifecycle is covered.
Maintenance
Related MCP Connectors
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Let AI assistants post to your Telegram chats, groups and channels. Not affiliated with Telegram.
Push notifications for AI agents - send instant iPhone notifications from any MCP client.
Send AI results to Telegram as private notifications or channel posts. No copy-pasting - connect your Telegram account and publish directly from AI assistants.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to send messages and interact with Telegram chats through MCP tools, with support for user management, conversation history, and bot command handling.1-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Telegram accounts through MCP, supporting messaging, contacts, groups, media, and admin functions.4Apache 2.0
- AlicenseBqualityDmaintenanceEnables AI agents to send notifications and media (text, photos, documents, videos) via a Telegram bot.4138 npm4Do What The F*ck You Want To Public
- AlicenseAqualityDmaintenanceEnables AI assistants to publish, edit, search, and manage messages in Telegram channels via a set of MCP tools.8MIT