telegram-mcp
Provides read-only access to Telegram chats, allowing agents to list allowed chats, retrieve chat metadata, fetch recent message history (up to 100 messages), and search messages by text within an explicitly allowed chat.
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., "@telegram-mcpshow the last 10 messages in @your_group"
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
Минимальный read-only MCP сервер для Telegram.
Агент в Cursor (или другом MCP-клиенте) может читать историю и искать сообщения только в явно разрешённых чатах. Отправки, правок и удаления нет.
Стек: Python 3.10+, Telethon (MTProto), официальный MCP Python SDK.
Зачем свой, а не чужой
Сторонние Telegram MCP обычно дают полный user-session и десятки write-tools. Здесь наоборот:
fail-closed allowlist (
TELEGRAM_ALLOWED_CHAT_IDSобязателен);только чтение;
маленький код, который можно просмотреть целиком.
Related MCP server: telegram-mcp
Tools
Tool | Описание |
| Диалоги из allowlist |
| Метаданные чата |
| История (до 100 сообщений, newest first) |
| Поиск по тексту внутри одного чата |
Требования
Python 3.10+
uv (рекомендуется)
Telegram API ID / Hash с my.telegram.org/apps
Аккаунт, который уже состоит в нужных группах (лучше отдельный, не основной)
Быстрый старт
git clone https://github.com/SHTIKOV/telegram-mcp.git
cd telegram-mcp
uv sync --extra dev
cp .env.example .envЗаполни в .env:
TELEGRAM_API_ID=...
TELEGRAM_API_HASH=...
TELEGRAM_SESSION_PATH=~/.local/state/telegram-readonly-mcp/session
TELEGRAM_ALLOWED_CHAT_IDS=-1001234567890,@your_groupАвторизация (код придёт в Telegram / 2FA при необходимости):
uv run telegram-readonly-loginПроверка тестов:
uv run pytest -qЗапуск MCP (stdio):
uv run telegram-readonly-mcpCursor
Добавь в ~/.cursor/mcp.json (путь к клону подставь свой):
{
"mcpServers": {
"telegram-readonly": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/telegram-mcp",
"run",
"telegram-readonly-mcp"
],
"env": {
"TELEGRAM_API_ID": "YOUR_API_ID",
"TELEGRAM_API_HASH": "YOUR_API_HASH",
"TELEGRAM_SESSION_PATH": "/home/YOU/.local/state/telegram-readonly-mcp/session",
"TELEGRAM_ALLOWED_CHAT_IDS": "-1001234567890,@your_group"
}
}
}
}Перезапусти MCP в Cursor. Дальше можно просить: «покажи последние сообщения в группе X» / «найди в чате Y обсуждение деплоя».
Allowlist
TELEGRAM_ALLOWED_CHAT_IDS — обязательный список через запятую:
numeric id:
-1001234567890username:
@groupилиgroup
Пустое значение → сервер не стартует. Запросы вне списка → access_denied.
Как узнать id: временно добавь @username в allowlist, вызови list_allowed_chats, возьми id из ответа.
Безопасность
Session file / session string = полный доступ к аккаунту. Не коммить
.env,*.session,TELEGRAM_SESSION_STRING.Предпочтительно отдельный Telegram-аккаунт только в нужных группах.
Не ставь
TELEGRAM_ALLOWED_CHAT_IDSшире, чем нужно.Опциональная транскрипция / отправка сообщений в этом проекте не реализованы намеренно.
Структура
src/telegram_readonly_mcp/
allowlist.py # парсинг и проверка чатов
client.py # Telethon client из env
format.py # сериализация сообщений/чатов
login.py # CLI авторизации
server.py # MCP tools (stdio)
service.py # read-only операции
tests/ # unit-тесты с моками (без сети)Лицензия
MIT — используй и меняй как удобно.
Related MCP Connectors
Read-only MCP access to sessions, funnels, campaigns, errors, live visitors, and anomalies.
Unofficial Telegram MCP server — read, search, reply and react in your own Telegram account.
Read-only MCP access to authorized Vocci sessions, notes, files, and memory search.
- AskingOAuthbr.com.asking
Asking support MCP: read conversations, contacts and reports, and reply with scoped consent.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables users to read, search, and manage Telegram messages in channels, groups, and private chats through MCP tools.8MIT
- AlicenseNot gradedqualityBmaintenanceA read-only Telegram MCP server that only exposes a user-defined allowlist of chats, providing tools to list chats, fetch messages, search, and get context while stripping untrusted text and with no write capabilities.MIT
- AlicenseBqualityBmaintenanceProvides read-only access to Telegram chats, allowing AI agents to list chats, read messages, and search within chats via local MCP.14MIT
- AlicenseAqualityBmaintenanceEnables reading Telegram channels, groups, and direct messages through an MCP interface, with enforced read-only access so the agent cannot write to them.15MIT