MCP Telegram
Supports chat summarization using Google's Gemini API as one of the available LLM providers for analyzing and summarizing Telegram conversations.
Supports chat summarization using Ollama's local LLM as one of the available LLM providers for analyzing and summarizing Telegram conversations without requiring external API keys.
Provides comprehensive Telegram integration, enabling AI assistants to manage chats, send/receive messages, search conversations, schedule messages, resolve links, backup messages, and summarize chats using Telegram's API.
mcp-telegram
MCP server for Telegram — let AI assistants interact with your Telegram account
Features
Chat Management: List, search, mute/unmute chats, organize into folders
Messages: Read, search, inspect context, send, draft, schedule, link-resolve, and backup messages
AI Summarization: Summarize chat conversations using multiple LLM providers
Secure: Session stored in macOS Keychain (file-based storage on Linux/Windows)
Related MCP server: Telegram MCP Server & Channel Monitor
Installation
go install github.com/tolmachov/mcp-telegram@latestOr build from source:
git clone https://github.com/tolmachov/mcp-telegram.git
cd mcp-telegram
makeSetup
1. Get Telegram API Credentials
Go to my.telegram.org/apps
Create an application
Copy
api_idandapi_hash
2. Configure Environment
Store credentials (macOS Keychain; plaintext JSON at ~/.local/state/mcp-telegram/config.json with 0600 perms on Linux/Windows):
mcp-telegram config set api-id 123456789
mcp-telegram config set api-hash abcd1234efgh5678Or use a .env file:
cp .env.example .env
# Edit .env with your credentials3. Login to Telegram
mcp-telegram login --phone +1234567890You'll be prompted for a verification code sent to your Telegram.
4. Configure MCP Client
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"telegram": {
"command": "mcp-telegram",
"args": ["run"],
"env": {
"TELEGRAM_API_ID": "your_api_id",
"TELEGRAM_API_HASH": "your_api_hash"
}
}
}
}Claude Code
claude mcp add telegram -- /path/to/mcp-telegram runSet environment variables in your .env file or pass them via --env.
Available Tools
29 tools exposed to MCP clients. Messages are identified by opaque string
handles ("42" for regular, "s:42" for scheduled) — copy them back
verbatim from tool outputs to follow-up calls, never parse or construct
them manually.
Tool | Description |
| Get current user information |
| List all chats, groups, and channels |
| Fuzzy search for chats by name |
| Get detailed information about a chat |
| Get messages from a chat (set |
| Search within one chat by substring, with optional date / sender / media / thread filters |
| Search by substring across all chats with opaque cursor-based pagination |
| Get messages around a specific anchor message in chronological order |
| Get the messages of a reply thread / comment section under a root message |
| List a forum supergroup's topics with opaque cursor-based pagination |
| Send, reply, schedule, or draft a message. |
| Edit a message; for scheduled handles, |
| Delete a message; |
| Forward a delivered message (scheduled handles are rejected) |
| Set or clear your emoji reactions on a message (empty list clears) |
| Join a channel/group/supergroup by @username, numeric ID, or invite link ( |
| Leave a channel/group/supergroup by @username or numeric ID (asks for confirmation) |
| Parse |
| Mark one or more chats as read |
| Export messages to a text file. Filters mirror the read tools: |
| Resolve @username to user/chat info |
| Mute or unmute chat notifications ( |
| AI-powered chat summarization via sampling / Gemini / Ollama / Anthropic |
| Download photo media from a media resource URI; returns MCP image content |
| List chat folders (dialog filters) with their ID, title, flags, and included/excluded/pinned chat IDs |
| Create a folder from a title plus chats and/or category flags (e.g. |
| Delete a folder by ID; chats are untouched (asks for confirmation) |
| Add chats/groups/channels to a folder by ID (@username or numeric ID) |
| Remove chats/groups/channels from a folder by ID |
Server Variants
The server implements experimental server variants
(SEP-2053): one server that offers several selectable capability sets. A client
sends hints during initialize, the server ranks the variants, and the client
picks one. Clients that don't understand the extension transparently get the
full variant, so nothing changes for them.
Variant | Status | Tools | For |
| stable (default) | all 29, full descriptions | interactive research + administration with a human |
| stable | all 29, descriptions trimmed to the first sentence (~50% smaller) | autonomous agents on a tight context budget |
| experimental | 16 Telegram read-only tools, descriptions trimmed like | read-heavy context-loading agents |
Pin a single variant with --variant (or TELEGRAM_VARIANT) for clients that
can't negotiate — e.g. --variant research exposes only the read-only subset:
mcp-telegram run --variant researchLeave it unset to expose all three and let the client choose.
Note on pinned-chat resources. In multi-variant mode (no
--variant), pinned-chat resources are exposed on every variant and kept fresh by a single poller, but proactiveresources/list_changednotifications are not delivered — the variants proxy can't forward the background watcher's notifications (an upstream library limitation). Clients pick up pin changes on their nextresources/list. Pin a single--variantto restore live notifications.
Available Resources
URI | Description |
| Current user info |
| All chats list |
| Detailed info for any chat ID via resource template |
| Last 100 messages from a pinned chat (dynamic resource, only for currently pinned chats) |
Pinned chat resources are created dynamically for each pinned chat and refreshed in the background; clients receive resources/list_changed when the set changes (except in multi-variant mode — see the note under Server Variants).
Available Prompts
3 parameterized prompts that MCP clients expose as slash-commands or quick actions.
Prompt | Arguments | Description |
|
| Walks active chats and produces a per-chat digest of key updates and action items. Read-only. |
|
| Summarizes a specific chat and lists messages that look like they need a reply. Read-only. |
|
| Searches for a message, shows a draft reply, and sends only after explicit user confirmation. |
Prompt Examples
Here are some example prompts you can use with AI assistants:
Message Management
"Check for any unread important messages in my Telegram"
"Summarize all my unread Telegram messages"
"Read and analyze my unread messages, prepare draft responses where needed"
"Check non-critical unread messages and give me a brief overview"
"Find messages mentioning 'invoice' in my work chat from last week"
"Open the context around this Telegram link: https://t.me/example/123"
Organization
"Analyze my Telegram dialogs and suggest a folder structure"
"Help me categorize my Telegram chats by importance"
"Find all work-related conversations and suggest how to organize them"
Communication
"Monitor specific chat for updates about [topic]"
"Draft a polite response to the last message in [chat]"
"Check if there are any unanswered questions in my chats"
"Resolve this Telegram message link and show me the thread context"
Backup & Export
"Backup my conversation with [contact] to a file"
"Export the last week of messages from [group]"
"Backup media-only updates too so nothing is silently skipped"
Chat Summarization
The SummarizeChat tool supports multiple LLM providers:
sampling (experimental): Uses the MCP client's LLM via MCP Sampling. Only works with clients that support sampling: VS Code, fast-agent, Continue. Does NOT work with Claude Desktop or Claude Code.
ollama: Local LLM via Ollama - no API key required
gemini: Google Gemini API
anthropic: Anthropic Claude API
Configure via environment variables:
SUMMARIZE_PROVIDER=ollama # or: sampling, gemini, anthropic
SUMMARIZE_MODEL= # provider-specific model nameCommands
# Run MCP server (used by MCP clients)
mcp-telegram run
# Login to Telegram
mcp-telegram login --phone +1234567890
# Logout and delete session
mcp-telegram logout
# Securely store config values (macOS Keychain / file on Linux)
mcp-telegram config set api-id 123456789
mcp-telegram config set api-hash abcd1234
# List stored keys
mcp-telegram config list
# Delete a stored value
mcp-telegram config delete api-idAllowed keys: api-id, api-hash, anthropic, gemini.
Credentials resolve in this priority order (higher wins): CLI flags (--api-id, --api-hash) → environment variables (including .env) → secure store values set via config set. This lets you keep stable values in the keychain and override per-run from the command line without editing the store.
Configuration Options
Environment Variable | Description | Default |
| Telegram API ID | Required |
| Telegram API Hash | Required |
| Allowed directories for backups | OS app data dir |
| LLM provider for summarization |
|
| Model name | Provider default |
| Tokens per summarization batch |
|
| Ollama API URL |
|
| Google Gemini API key | - |
| Anthropic API key | - |
| Max bytes |
|
| RPS ceiling for history-fetching calls to Telegram. Exceeding Telegram's FLOOD_WAIT thresholds pauses all tools. |
|
| Polling interval (seconds) for the pinned-chat resource watcher. |
|
| Max seconds to wait out a Telegram |
|
Destructive Actions
Tools like DeleteMessage request user confirmation via MCP elicitation before proceeding. If your MCP client does not support elicitation, the server proceeds automatically without a confirmation dialog.
Session Storage
macOS: Stored securely in Keychain.
Linux/Windows: Stored in
~/.local/state/mcp-telegram/session.jsonwith0600file permissions. The file is plaintext — keep the containing user account trusted, and prefer running on macOS when handling sensitive accounts.
Config values set via mcp-telegram config set (API keys, Telegram credentials) follow the same backend: Keychain on macOS, plaintext JSON on Linux/Windows.
Note on the plaintext store (Linux/Windows): the session file grants full access to your Telegram account. Place it on an encrypted filesystem (LUKS/BitLocker) and do not sync
~/.local/state/mcp-telegram(or~/.config) to an unencrypted cloud backup — a leakedsession.jsonis equivalent to a leaked login.
Development
make build # build the binary with version metadata
make lint # golangci-lint
make test # unit tests
make test-integration # end-to-end tests (need a real account + TEST_* vars)Unit tests run without credentials. The integration suite in test/ is behind
the integration build tag and drives the server over a real stdio pipe using a
second MCP implementation (mark3labs/mcp-go) as the client, to catch wire-level
interop issues. It reads the TEST_* variables documented in .env.example
(e.g. TEST_CHAT_ID, TEST_GROUP_ID) and skips any test whose variable or
Telegram credentials are unset.
License
This server cannot be installed
Maintenance
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/tolmachov/mcp-telegram'
If you have feedback or need assistance with the MCP directory API, please join our Discord server