telegram-mcp
This MCP server lets an AI assistant access Telegram on behalf of your user account to read, search, and manage chats.
Fetch recent messages from channels, groups, or private chats with limits and time-window filters (
sinceMinutes,sinceHours,sinceDate).Search messages in a chat by text query, also with limits and time windows.
Get metadata for a channel, group, or private chat.
List available channels and optionally groups the user can access.
Retrieve private conversation messages.
Mark messages as read by specific IDs or up to a max ID; not supported for broadcast channels.
Check for unread messages, optionally including channels.
Inspect chat read/unread status and capabilities.
Per the README, authorize/log out and manage Telegram sessions, including 2FA and pre-generated session strings.
Provides tools for interacting with Telegram channels, groups, and private conversations, including retrieving recent messages, searching messages, getting chat information, listing available chats, marking messages as read, checking unread messages, and getting chat status.
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-mcp show recent messages from @technews"
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.
MCP Telegram Server
A Model Context Protocol (MCP) server that lets AI assistants read, search and manage Telegram channels, groups and private conversations on behalf of your user account (not a bot).
Contents: Features · Quick start · Setup · Tools · MCP client configuration · Development · Testing · Contributing · Releases · Security · Troubleshooting
Quick start
git clone https://github.com/Maxsh/telegram-mcp.git && cd telegram-mcp
npm ci && npm run build
export TELEGRAM_API_ID=... TELEGRAM_API_HASH=... # from https://my.telegram.org/apps
npm start # stdio MCP server; authorize via the telegram_authorize toolThen register node /absolute/path/to/telegram-mcp/dist/index.js in your MCP client (see MCP client configuration). A step-by-step walkthrough lives in SETUP.md.
Related MCP server: telegram-mcp-connect
Features
User-account access — acts on behalf of the authenticated Telegram user, not a bot token
Read anywhere — recent messages, search and chat info across channels, groups and private chats, plus discovery of available channels
Pagination and time windows —
offsetIdpaging for busy channels;sinceMinutes/sinceHours/sinceDatewindows with IANA time zones (DST-correct)Batch fetch — up to 25 channels in one call, each with its own result or error
Digest-friendly output —
maxTextLength,fields,excludeMedia; media captions, t.me links,forwardedFromSession management — interactive authorization with 2FA, pre-generated session strings, logout
Setup
Set the environment variables (.env file or exports):
TELEGRAM_API_ID=your_api_id # from https://my.telegram.org/apps
TELEGRAM_API_HASH=your_api_hash
TELEGRAM_SESSION=your_session_string # optionalAuthentication options
Interactive (easiest start): use any tool and the server asks for authorization — call
telegram_authorizewith your phone number, thentelegram_verify_codewith the code (and your 2FA password, if enabled). The session lives in memory for the server's lifetime.Pre-generated session: run
npm run generate-sessiononce (prompts for phone, code, 2FA) and store the printed string asTELEGRAM_SESSION— it persists across restarts. Never commit it.
telegram_logout invalidates the current session at any time.
Available tools
Tool | Purpose |
| Recent messages from a channel, group or private chat; |
| Batch-fetch recent messages from up to 25 channels, with per-channel results and errors |
| Private conversation messages with contact formatting |
| Metadata for any chat, including a ready-to-use |
| Text search within a chat |
| List channels and groups the user can access |
| Mark messages as read (groups and private chats; broadcast channels don't support read status) |
| Find chats with unread messages |
| Diagnostics for read status and chat capabilities |
| Start the interactive authorization |
| Complete authorization with the code and optional 2FA password |
| Log out and invalidate the session |
MCP clients also receive each tool's exact input schema via tools/list, so arguments are validated before a call is dispatched.
Full parameters, examples and response schemas: docs/TOOLS.md. Response shapes are a stable contract: fields may be added, but removing or renaming one is a breaking change.
MCP client configuration
Add to your Claude Desktop claude_desktop_config.json (other MCP clients are configured analogously):
{
"mcpServers": {
"telegram": {
"command": "node",
"args": ["/path/to/mcp-telegram-server/dist/index.js"],
"env": {
"TELEGRAM_API_ID": "your_api_id",
"TELEGRAM_API_HASH": "your_api_hash",
"TELEGRAM_SESSION": "your_session_string"
}
}
}
}Development
npm run dev # run from source with tsx
npm run watch # rebuild on changeProject rules for agents and contributors: AGENTS.md.
Testing
npm test # unit tests + smoke test
npm run test:unit # unit tests only (tests/*.test.ts, fake Telegram client)
npm run test:smoke # spawns the built server and checks tools/list
npm run test:coverage # unit tests with a coverage reportThe unit suite (tests/*.test.ts) runs on Node's built-in test runner with a
fake Telegram client — no network access and no credentials. It covers every
tool (get_recent_messages pagination and output options, get_messages_multi,
get_channel_info, search_messages, get_available_channels,
mark_messages_read, check_unread_messages, get_private_messages,
get_chat_status, the authorization flow), the pure helpers (time zones, id
normalization, media typing, output shaping), and the tool catalog/dispatch
contract.
scripts/live-check.ts is a manual end-to-end check against the real Telegram
API (needs credentials in ~/.secrets/telegram-*) and is intentionally not part
of CI.
Continuous integration
.github/workflows/ci.yml runs on every push and
pull request, on Node 22, 24 and 26:
build (
tsc, strict), unit tests under c8, smoke test;run Summary with passed/failed/skipped counts, per-suite breakdown, failure details and coverage (statements/branches/functions/lines);
JUnit check run with failure annotations (
dorny/test-reporter);coverage comment on pull requests (Cobertura,
irongut/CodeCoverageSummary);raw reports (JUnit XML, Cobertura, LCOV) as downloadable artifacts.
The tests and coverage badges above are
shields.io endpoint badges generated
by scripts/ci-summary.ts and published to the badges branch on every push to
main, so they always show the latest main build.
Reproduce the CI report locally:
npm run test:ci && npm run ci:summary # markdown summary on stdout, reports in reports/ and coverage/Contributing
All changes go through pull requests with tests — see CONTRIBUTING.md and the full rules in AGENTS.md (which also apply to AI coding agents). Changes are recorded in CHANGELOG.md.
Releases
Versions follow SemVer; release notes come from
CHANGELOG.md (Keep a Changelog).
Pushing a vX.Y.Z tag on main runs
.github/workflows/release.yml, which verifies
the tag, builds, tests and publishes the
GitHub Release with an
npm pack tarball. The process is described in AGENTS.md → Releases.
Security notes
Session security: Keep your session string secure. It provides full access to your Telegram account.
API credentials: Never share your API ID and hash publicly.
Channel access: The server can only access channels that your Telegram account has permission to read.
Rate limiting: Telegram has rate limits. The server doesn't implement rate limiting, so use responsibly.
Reporting vulnerabilities: privately, see SECURITY.md.
Troubleshooting
Quick checks:
"Authorization required" →
telegram_authorize, thentelegram_verify_code(addpasswordfor 2FA). Invalid code? Codes expire within minutes — request a new one.mark_messages_readdoesn't stick → debug withget_chat_status; broadcast channels and secret chats don't support read status.Rate limits / network errors → retry later; the server already retries connections.
The full guide lives in docs/TROUBLESHOOTING.md.
License
Available Tools
12 toolscheck_unread_messagesC
Check for unread messages in private chats and groups
Inputs: limit, onlyWithUnread, includeChannels.
get_available_channelsB
Get list of available channels and groups that the user has access to
Inputs: limit, includeGroups.
get_channel_infoC
Get information about a Telegram channel, group, or private chat
Inputs: channel (required).
get_chat_statusC
Get detailed status information about a chat including unread count and read status
Inputs: chat (required).
get_messages_multiA
Get recent messages from multiple Telegram channels in one call (1-25 channels). Returns per-channel results and per-channel errors, so one bad channel does not fail the call. Same response fields as get_recent_messages per channel.
Inputs: channels (required), tz, limit, sinceDate, +4 more.
get_private_messagesC
Get messages from a private chat conversation
Inputs: contact (required), tz, limit, offsetId, +4 more.
get_recent_messagesA
Get recent messages from a Telegram channel, group, or private chat. Returns resolved channel info (id/peer/username/type), hasMore/nextOffsetId for pagination, and lastMessageDate so an empty window can be told apart from a dead channel.
Inputs: channel (required), tz, limit, fields, +6 more.
mark_messages_readB
Mark messages as read in a Telegram chat, group, or private conversation (not supported for broadcast channels)
Inputs: channel (required), maxId, messageIds.
search_messagesC
Search for messages in a Telegram channel, group, or private chat
Inputs: query (required), channel (required), tz, limit, +5 more.
telegram_authorizeB
Start Telegram authorization process with phone number
Inputs: phoneNumber (required).
telegram_logoutB
Logout from Telegram and invalidate the current session
Inputs: no named parameters.
telegram_verify_codeB
Complete Telegram authorization with verification code and optional 2FA password
Inputs: code (required), password.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Several read-oriented tools overlap: get_recent_messages already covers private chats that get_private_messages targets, check_unread_messages overlaps with get_chat_status and get_recent_messages, and get_messages_multi is a batched variant of get_recent_messages. Descriptions clarify some distinctions, but boundaries remain fuzzy enough to cause misselection.
Most tools follow a clear verb_noun pattern such as get_channel_info, search_messages, and mark_messages_read. The telegram_ prefix on authorization tools is a minor deviation but still readable and predictable.
Twelve tools is a well-scoped size for a Telegram client MCP covering authorization, channel discovery, message retrieval, search, unread tracking, and read marking. Each tool has a plausible role in that surface.
The server covers reading, searching, auth, and read receipts, but there is no tool to send a message, which is a core Telegram operation. Other lifecycle gaps such as editing, deleting, forwarding, or joining/leaving chats further limit the surface for a messaging integration.
Maintenance
Related MCP Connectors
Telegram CRM MCP: search chats, message existing chats, manage tickets and CRM across accounts.
Unofficial Telegram MCP server — read, search, reply and react in your own Telegram account.
Unified inbox MCP for WhatsApp, Telegram, Email, voice — read/send messages, search, AI agents.
Schedule posts, read analytics and manage Telegram channels in TGStudio from any MCP client.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to publish, edit, search, and manage messages in Telegram channels via a set of MCP tools.8MIT
- AlicenseNot gradedqualityDmaintenanceEnables reading Telegram chats and searching messages through natural language, connecting to MCP clients like Claude Code, Codex, and Cursor.13 npm1MIT
- AlicenseNot gradedqualityBmaintenanceThis MCP server enables agents to connect to Telegram accounts and bots to search chats, review unread messages, build sourced digests, inspect media and documents, and prepare or execute confirmed actions with scoped permissions.1MIT
- AlicenseBqualityBmaintenanceEnables MCP clients to read and search personal Telegram chats, manage messages and chats, clean up spam or deleted-account conversations, and adjust privacy and login settings through Telegram’s official MTProto API. Destructive actions preview by default and require confirmation before execution.182MIT