telegram-mcp
Connects to a Telegram group chat via the Telegram Bot API, enabling reading recent messages, searching message history, sending messages, and retrieving chat metadata.
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-mcpget the last 10 messages"
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
An MCP server that connects to a Telegram group chat via the Telegram Bot API, persists messages to a local SQLite database, and exposes them over Server-Sent Events (SSE). Designed to be deployed on Railway with a persistent volume so you can query the full 7-day history.
How it works
Telegram Bot API
│
│ getUpdates (daily at midnight UTC + on startup)
▼
SQLite DB (/data/messages.db)
│
│ SQL queries
▼
MCP tools ──SSE──► Claude / MCP clientA background thread runs a daily fetch at midnight UTC. On startup it also fetches immediately to cover any gap since the last run.
Each fetch drains the Telegram update queue and writes new messages to SQLite, deduplicating by
message_id.The MCP tools (
get_recent_messages,search_messages) query the local database — not Telegram — so they can return any time range within the stored history.
Related MCP server: telegram-mcp
Tools
Tool | Parameters | Description |
|
| Return the N most recent messages, oldest → newest |
|
| Full-text keyword search over the past N days |
|
| Post a message to the chat (also stored in DB) |
| — | Chat metadata + DB stats (count, date range) |
History depth: The database accumulates messages indefinitely. The Telegram Bot API's update queue only holds messages from the last 24 hours (max 100 per poll), so a daily fetch captures everything as long as the chat doesn't exceed ~100 messages per day. A startup fetch ensures no messages are missed across restarts.
Step 1 — Create a Telegram bot and get your credentials
Bot token
Open Telegram and message @BotFather.
Send
/newbot, follow the prompts, and copy the token (e.g.123456:ABCdef…).Add the bot to your group chat with at least Read messages and Send messages permissions (admin is easiest).
Chat ID
Add the bot to the group and send any message in the group.
Open this URL in a browser (replace
<TOKEN>):https://api.telegram.org/bot<TOKEN>/getUpdatesFind
"chat": {"id": ...}in the response — that is yourCHAT_ID.Regular groups: negative integer like
-987654321Supergroups / channels: large negative integer like
-1001234567890
Webhook conflict: If you previously set a webhook on this bot, clear it or
getUpdateswill return a 409:https://api.telegram.org/bot<TOKEN>/deleteWebhook
Step 2 — Deploy on Railway
Option A — Deploy from GitHub (recommended)
Push this folder to a GitHub repository.
Go to railway.app → New Project → Deploy from GitHub repo.
Select the repository. Railway detects the
Dockerfileautomatically.Open the service's Variables tab and add:
Variable
Value
BOT_TOKENyour bot token
CHAT_IDyour chat ID (include the leading
-)Click Deploy. Railway builds the image and starts the service.
Create the persistent volume:
In the Railway dashboard, open the service → Volumes tab → Add Volume.
Set the mount path to
/data.Railway will restart the service with the volume attached.
The
railway.tomlalready includes[[mounts]] mountPath = "/data"which Railway respects after the volume is created.
Go to Settings → Networking → Generate Domain to get a public URL.
Your SSE endpoint:
https://<your-service>.railway.app/sseOption B — Railway CLI
npm install -g @railway/cli
railway login
railway init
railway up
railway variables set BOT_TOKEN=<token> CHAT_ID=<id>
railway volume create --mount /data
railway domainStep 3 — Connect your MCP client
Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"telegram": {
"url": "https://<your-service>.railway.app/sse"
}
}
}Restart Claude Desktop. The four Telegram tools appear in the tool list.
Claude Code (CLI / VS Code extension)
claude mcp add telegram --transport sse https://<your-service>.railway.app/sseLocal development
pip install -r requirements.txt
export BOT_TOKEN=your_token
export CHAT_ID=your_chat_id
export DB_PATH=./messages.db # override the /data default for local dev
python server.py
# Listens on http://localhost:8080/sseTest with the MCP inspector:
npx @modelcontextprotocol/inspector http://localhost:8080/sseSecurity
No message content is logged to stdout — the server emits no application-level logs containing message text.
No analytics or tracking — the only outbound connection is to
api.telegram.org.Secrets are environment variables —
BOT_TOKENandCHAT_IDare never written to disk or echoed.Data at rest — messages are stored in SQLite on the Railway volume, which is private to your project.
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.
Latest Blog Posts
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/davidphc/telegram-mcp-bot'
If you have feedback or need assistance with the MCP directory API, please join our Discord server