Telegram MCP Server
Allows interaction with Telegram through the Telegram Bot API, enabling AI agents to send messages, read recent messages, and retrieve chat information.
Click on "Install 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., "@Telegram MCP ServerSend a welcome message to chat 987654321"
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.
Telegram MCP Server
MCP server for interacting with Telegram via the Telegram Bot API. The server provides an LLM client with a set of tools for sending messages, reading the latest available messages, and retrieving chat information.
Features
The server provides three MCP tools:
send_message— sends a text message to a specified Telegram chat.get_recent_messages— retrieves the latest available messages from a specified chat.get_chat_info— returns basic information about a Telegram chat.
The server uses stdio transport, so it can be connected to MCP Inspector and other MCP clients without a separate HTTP server.
Related MCP server: agent-telegram-mcp
Architecture
MCP client / MCP Inspector
│
│ MCP over stdio
▼
src/server.py
│
▼
src/telegram_client.py
│
│ HTTPS
▼
Telegram Bot APIserver.py handles the MCP interface and tool registration.
telegram_client.py encapsulates HTTP interaction with the Telegram Bot API.
config.py loads the token from an environment variable.
Stack
Python 3.10+
MCP Python SDK 2.x
Telegram Bot API
httpxpython-dotenv
Project Structure
telegram-mcp/
├── src/
│ ├── __init__.py
│ ├── config.py
│ ├── telegram_client.py
│ └── server.py
├── .env.example
├── .gitignore
├── requirements.txt
└── README.mdRequirements
Python 3.10 or later
A Telegram bot created via
@BotFatherNode.js and
npx— only if using MCP Inspector viamcp dev
Installation
Clone the repository and navigate to its directory:
git clone <repository-url>
cd telegram-mcpCreate a virtual environment:
python3 -m venv .venv
source .venv/bin/activateInstall dependencies:
pip install -r requirements.txtSetting Up a Telegram Bot
Open Telegram and find
@BotFather.Execute
/newbot.Create a bot and obtain the Bot API token.
Do not add the token to the source code or Git.
Create a .env file:
cp .env.example .envSpecify the token:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here.env is added to .gitignore.
Chat Preparation
Private Chat
Open the created bot.
Click
Startor send it a message.To test
get_recent_messages, send several text messages.
Group
Create a test group.
Add the bot to the group.
If the bot needs to see regular group messages, disable its privacy mode via
@BotFather(/setprivacy→Disable).Send several messages to the group.
To obtain a chat_id, it is convenient to first call get_chat_info or get_recent_messages after the bot has received a message from the desired chat.
Running
From the project root directory:
python src/server.pyThe server runs via stdio and expects an MCP connection. Therefore, the absence of standard terminal output after startup is normal behavior.
For development and testing, you can use the MCP CLI:
mcp dev src/server.pyThe command launches the server and MCP Inspector. Inspector uses npx, so Node.js must be available in PATH.
MCP tools
send_message
Sends a text message to Telegram.
Parameters:
chat_id: string — ID чата
text: string — текст сообщенияExample:
chat_id: 123456789
text: Привет! Сообщение отправлено через MCP.The server returns a confirmation of sending and the message_id.
get_recent_messages
Retrieves the latest available messages from a specified chat.
Parameters:
chat_id: string — ID чата
limit: integer — количество сообщений, по умолчанию 10limit is constrained to a range from 1 to 100.
Example:
chat_id: 123456789
limit: 10The result includes the sender and text of each available message.
get_chat_info
Retrieves basic information about a chat.
Parameters:
chat_id: string — ID чатаThe response displays available fields, including ID, type, title, username, first name, and last name.
How Message Retrieval Works
The Telegram Bot API does not provide a bot with a separate method for reading an arbitrary chat history. To receive incoming messages, the server uses getUpdates.
get_recent_messages requests up to 100 of the latest available updates and then filters them by chat_id. Therefore, the tool works with messages that Telegram provides to the bot through the updates queue, not with the full chat history.
This means the tool is not a replacement for a Telegram client with access to the entire message history. For testing, it is sufficient to send messages after adding the bot to the chat and then call get_recent_messages.
Important: getUpdates is not used simultaneously with an active webhook. If a webhook is configured for the bot, first remove it so that long polling via getUpdates can receive updates.
Example Scenario
Launch MCP Inspector.
Connect
src/server.py.Ensure the following are available:
send_messageget_recent_messagesget_chat_info
Call
get_chat_infoto verify the connection to the chat.Call
send_messageand confirm the message appears in Telegram.Send a few messages in Telegram.
Call
get_recent_messagesand verify the received message list.
Security
The Telegram Bot API token is transmitted only through the TELEGRAM_BOT_TOKEN environment variable.
The actual .env file must not be committed to Git. Only .env.example without a working token is stored in the repository.
Limitations
The bot does not have access to the entire Telegram chat history via the Bot API.
get_recent_messagesworks with available bot updates.In groups, the set of messages the bot receives depends on Telegram's privacy settings.
getUpdatesand webhook are mutually exclusive methods for receiving updates.
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 Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to read, send, and organize Telegram messages and chats. Supports tools for listing chats, fetching messages, sending/reply, archiving, muting, and folder management.1MIT
- AlicenseAqualityDmaintenanceEnables AI agents to send and receive messages, media, and files on Telegram, and manage chats via a bot token.17MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with the Telegram Bot API, allowing them to send messages, forward messages, get bot information, and receive updates.273MIT
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to send notifications and receive responses via Telegram.174MIT
Related MCP Connectors
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API
Gateway between LLM agents and world data through eight tools and a bundled endpoint catalog.
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/polinenysh/telegram-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server