mcpField
M
MCP Telegram

MCP Telegram

Local
npmjs.comCommunication33Updated 23w ago

About MCP Telegram

An MCP server built on MTProto that signs in as a real Telegram user account rather than a bot, for use from clients such as Claude, Cursor, and VS Code. It offers over 100 tools to read, search, and send messages, and to manage channels, stories, contacts, and folders. Sign-in runs in a local browser flow, and sessions are stored on the local machine.

Key features

  1. 01Real user account access via MTProto, no bot required
  2. 02Read, search, and send messages, including global search
  3. 03Channel and group moderation, invite links, and admin logs
  4. 04Stories, contacts, drafts, notifications, and folder management
  5. 05Raw MTProto method calls through invoke_mtproto

Use cases

  1. 01Searching Telegram message history by keyword and summarizing results
  2. 02Bulk managing channel settings, admin rights, and invite links
  3. 03Transcribing voice messages or downloading media from chats

MCP support

This is an MCP server that exposes Telegram user account tools for messages, media, and channel management to MCP clients. Sessions are stored in ~/.telegram-agent/ and should be protected like passwords.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"telegram-tacticlaunch": {
"command": "npx",
"args": [
"-y",
"mcp-telegram"
]
}
}
}
Run commandnpx -y mcp-telegram

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmmcp-telegram

Tools

111

Saved tool list · updated 3w ago

This tool takes no parameters.

Details

From the project README

mcp-telegram

mcp-telegram

Telegram MCP server for Claude, Codex, Cursor, Claude Code, VS Code, Cline, Windsurf, and other MCP clients. Real Telegram user account via MTProto, browser-based local sign-in, 100+ tools. Need lazy-loading + lower context cost? See telegram-agent, the skill-based companion.

npm version License Node

A Model Context Protocol (MCP) server that connects Claude Desktop, Codex CLI, Cursor, Claude Code, VS Code, Cline, Windsurf, Goose, and any other MCP-compatible client to a real Telegram user account via MTProto—so your agent can read, search, send, moderate, and manage Telegram chats from chat or automated tool calls instead of clicking through the Telegram UI.

Use it to: read dialogs and search messages globally · send/edit/forward/react/poll · download media and transcribe voice notes · moderate channels (ban/restrict/promote, invite links, slow-mode, admin log, forum topics) · manage stories, contacts, drafts, notifications, folders, privacy · or fall through to the raw MTProto bridge for anything else. All against a single signed-in user account—no bot required.

Warning

This server signs in as a real Telegram user (not a bot). Sessions live in ~/.telegram-agent/. Treat that directory like a password.

Prerequisites

  1. Node.js >=20
  2. Telegram API credentials from my.telegram.org/apps — api_id and api_hash

Want a lighter transport?

This package is the MCP server — every tool schema (~12,700 tokens) sits in your agent's context on every turn. Good for any MCP client and for hosted runtimes that can't shell out.

If your agent is Claude Code / Codex CLI / Cursor / Gemini CLI / Cline / Windsurf, there's a companion package — telegram-agent — that ships the same Telegram surface as a universal agent skill. The agent only loads the skill instructions when your prompt mentions Telegram — ~50× lower context cost in idle. Standalone (no MCP server in the loop), but uses the same ~/.telegram-agent/ session store as this package — sign in once, use either or both.

npm i -g telegram-agent
telegram-agent login
npx skills add beautyfree/telegram-agent -a claude-code -g

Continue below for the MCP install path.

Install

Option A — automatic, all clients:

npx add-mcp mcp-telegram \
  --env TELEGRAM_API_ID=123456 \
  --env TELEGRAM_API_HASH=abc...

add-mcp (from Neon) writes the correct config for Claude Desktop, Claude Code, Cursor, VS Code, Codex, Gemini CLI, Cline, Zed, Goose, OpenCode, and others. Pick the client in the interactive prompt.

Important

Both env vars are required. Get them from my.telegram.org/apps.

Option B — manual config:

Claude Desktop (claude_desktop_config.json)
{
  "mcpServers": {
    "telegram": {
      "command": "npx",
      "args": ["-y", "mcp-telegram"],
      "env": {
        "TELEGRAM_API_ID": "123456",
        "TELEGRAM_API_HASH": "abc..."
      }
    }
  }
}
Cursor (~/.cursor/mcp.json)
{
  "mcpServers": {
    "telegram": {
      "command": "npx",
      "args": ["-y", "mcp-telegram"],
      "env": {
        "TELEGRAM_API_ID": "123456",
        "TELEGRAM_API_HASH": "abc..."
      }
    }
  }
}
VS Code (.vscode/mcp.json)
{
  "servers": {
    "telegram": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mcp-telegram"],
      "env": {
        "TELEGRAM_API_ID": "123456",
        "TELEGRAM_API_HASH": "abc..."
      }
    }
  }
}
Claude Code
claude mcp add telegram \
  -e TELEGRAM_API_ID=123456 \
  -e TELEGRAM_API_HASH=abc... \
  -- npx -y mcp-telegram
Codex CLI (~/.codex/config.toml) — install
[mcp_servers.telegram]
command = "npx"
args = ["-y", "mcp-telegram"]
env = { TELEGRAM_API_ID = "123456", TELEGRAM_API_HASH = "abc..." }

First-time sign in

Ask your agent:

Sign in to my Telegram.

The agent calls the login tool. A browser tab opens. Enter your phone number, the SMS code, and 2FA password if you have one. The tab shows a green checkmark — you can close it. The session is now stored locally and the agent can read your Telegram.

To add another account, ask the agent to call login again.

Tools

102 tools covering the full Telegram user-account surface. Common ones below; the rest are grouped under collapsibles. Every tool accepts an optional accountId (omit when only one account is signed in). peer accepts a numeric chat id, an @username, or the literal "me" (Saved Messages).

Top of the menu:

ToolWhat it does
loginOpen the browser-based sign-in flow. Adds an account.
list_accountsList signed-in accounts.
list_dialogsList dialogs/chats/channels. Filters: unread, archived, ignorePinned, folder, limit.
list_messagesList messages in a dialog. Newest first.
search_messagesSearch inside one dialog: query, filter (photos/videos/url/voice/...), fromUser, date range.
search_globalSearch across every chat you have.
search_dialogsFind dialogs by name/title/username substring.
send_messageSend text. Supports replyTo, topMsgId, parseMode, schedule, silent.
send_fileSend a file (local path or https:// URL). Pass an array for an album.
download_mediaSave the media on a message to disk.
transcribe_messageTranscribe a voice/video note (Premium).
invoke_mtprotoCall any raw MTProto method by name. Auto-resolves peer/channel/user strings.
Sessions (local) (4)

These are local-only: they manage which Telegram sessions live in ~/.telegram-agent/ and the settings UI. No Telegram API call beyond the sign-in flow itself.

ToolWhat it does
list_accountsList signed-in accounts.
loginBrowser-based sign-in. Adds an account.
logoutDrop a local session and revoke it on Telegram.
open_settingsOpen the local settings page (tool surface + read-only).
Profile (5)
ToolWhat it does
get_meReturn the profile of the authenticated user.
update_profileChange own first/last name and bio.
update_my_usernameSet or clear own @username.
set_birthdaySet the account birthday.
set_profile_photoUpload a new avatar (local path or URL).
Dialog discovery (5)
ToolWhat it does
list_dialogsList dialogs. Filters: unread, archived, ignorePinned, folder, limit.
search_dialogsFind dialogs by name/title/username substring.
resolve_usernameResolve @username to a user/channel/chat entity.
list_foldersList custom dialog folders (chat filters).
list_contactsList contacts.
Messages — read & search (6)
ToolWhat it does
list_messagesList messages in a dialog.
search_messagesSearch inside one dialog (text, type filter, sender, date range).
search_globalSearch across every chat.
get_messageFetch one or more messages by id.
get_message_reactionsGet reactions on messages.
mark_as_readMark messages read up to an id.
Messages — write (8)
ToolWhat it does
send_messageSend text.
edit_messageEdit a previously sent message.
delete_messagesDelete by id (optionally revoke for all).
forward_messagesForward messages between dialogs.
pin_message / unpin_messagePin / unpin in a dialog.
send_reactionSet reactions on a message.
send_message_to_phoneSend to a phone number, auto-creates a temporary contact.
Media (4)
ToolWhat it does
send_fileSend a file (path or URL). Albums via array.
download_mediaSave a message's media to disk.
download_profile_photoSave a peer's avatar to disk.
transcribe_messageTranscribe voice/video (Premium).
Polls (4)
ToolWhat it does
send_pollSend a poll. Supports quiz, multiple-choice, anonymous, close period.
vote_pollCast a vote.
close_pollFinalize a poll.
get_poll_resultsFetch tally.
Reactions (3)
ToolWhat it does
send_reactionSet emoji reactions on a message.
get_message_reactionsRead reactions.
set_default_reactionSet account-wide default.
Stories (6)
ToolWhat it does
list_storiesFeed of contacts' stories.
get_peer_storiesOne peer's stories.
send_storyPost a story (photo or video).
delete_storyDelete own stories.
view_storyMark stories viewed.
get_story_viewersList who viewed your story.
Channel / group moderation (11)
ToolWhat it does
ban_userFull ban (optional untilDate).
unban_userLift restrictions.
restrict_userApply a custom rights mask.
promote_adminGrant admin rights (with rank).
demote_adminStrip admin rights.
invite_userAdd users to a channel/supergroup.
kick_participantKick from chat/channel.
get_participantSingle participant info.
list_participantsMembers with filter (admins/banned/bots/...) and substring search.
delete_user_historyRemove every message by a user.
get_admin_logRecent admin events with event-type filter.
Channel / group settings (12)
ToolWhat it does
edit_titleChange title (works for channels, supergroups, and basic groups).
edit_aboutChange description.
edit_photoChange avatar (path or URL).
update_usernameSet/clear public @username.
check_usernameCheck availability.
set_slow_modeSet slow-mode seconds.
toggle_signaturesAuthor signatures on channel posts.
toggle_pre_history_hiddenHide history from new members.
toggle_join_requestRequire admin approval to join.
leave_channelLeave a channel/supergroup.
get_channel_infoExtended info (about, counts, linked chat, slow-mode).
get_user_infoExtended user info (bio, common chats).
Channel / group lifecycle (4)
ToolWhat it does
create_channelNew broadcast channel or supergroup (optional forum mode).
delete_channelPermanently delete.
migrate_chatBasic group → supergroup.
transfer_ownershipHand over creator rights (requires 2FA password).
Invite links (4)
ToolWhat it does
create_invite_linkNew link with optional expiry, usage cap, join-request gate.
list_invite_linksList active or revoked links.
revoke_invite_linkRevoke a specific link.
list_invite_joinersList users that joined via a link.
Forum topics (3)
ToolWhat it does
list_topicsList forum topics.
create_topicCreate a new topic.
edit_topicRename, re-icon, close, hide.
Drafts (3)
ToolWhat it does
save_draftSave a draft for a dialog.
clear_draftDrop the draft for a dialog.
list_draftsList all dialog drafts.
Notifications (4)
ToolWhat it does
mute_peerMute a chat (optional untilDate).
unmute_peerUnmute.
get_notify_settingsRead settings.
set_notify_settingsUpdate mute, previews, sound, story-mute.
Folders (chat filters) (4)
ToolWhat it does
create_folderNew folder with include/exclude rules.
edit_folderReplace folder rules.
delete_folderRemove a folder.
reorder_foldersSet display order.
Contacts (4)
ToolWhat it does
list_contactsAll contacts.
add_contactAdd a user to contacts.
delete_contactRemove users from contacts.
search_contactsSearch contacts + global directory.
Privacy & blocking (5)
ToolWhat it does
block_user / unblock_userBlock / unblock.
list_blockedBlock list.
get_privacyRead a privacy key.
set_privacyUpdate a privacy key (mode + allow/disallow lists).
Stickers (3)
ToolWhat it does
get_my_stickersInstalled sticker sets.
install_sticker_setInstall by short name.
add_recent_stickerPin a sticker to recent.
Premium boosts (2)
ToolWhat it does
get_my_boostsList your boost slots.
apply_boostApply slots to a channel.
Bots & raw MTProto (2)
ToolWhat it does
get_inline_bot_resultsRun an inline bot query.
invoke_mtprotoCall any MTProto method by qualified name (e.g. messages.SendMessage, stories.GetAllStories). String values for peer/channel/user/fromPeer/toPeer/bot/chat are auto-resolved to InputPeer / InputUser.
Gating which tools are exposed

Three env vars, applied in order:

VariableEffect
MCP_TELEGRAM_READONLY=1Hide every destructive / mutating tool.
MCP_TELEGRAM_TOOLS=name1,name2,prefix*Strict allowlist — only these tools register.
MCP_TELEGRAM_DISABLE=name1,prefix*Blocklist applied after the allowlist.

Examples:

MCP_TELEGRAM_READONLY=1                                    # read-only agent
MCP_TELEGRAM_TOOLS='login,list*,search*,get*'              # discovery-only
MCP_TELEGRAM_DISABLE='delete*,ban*,kick*,create_channel,delete_channel,transfer_ownership,invokeMtproto'  # safer write set

Environment

VariableRequiredDefaultNotes
TELEGRAM_API_IDyes—From my.telegram.org/apps. If unset, the auth page prompts for it and saves to state.json.
TELEGRAM_API_HASHyes—Same as above.
TELEGRAM_AGENT_HOMEno~/.telegram-agentState + per-account session storage. Legacy MCP_TELEGRAM_HOME still accepted. If only ~/.mcp-telegram exists from a previous install, it's used automatically.
TELEGRAM_AGENT_DOWNLOADSno$TELEGRAM_AGENT_HOME/downloadsWhere download_media / download_profile_photo save files. Legacy MCP_TELEGRAM_DOWNLOADS still accepted.
MCP_TELEGRAM_READONLYno—Set to 1/true/yes to hide every destructive tool.
MCP_TELEGRAM_TOOLSno—Strict allowlist. Comma-separated tool names; supports prefix* wildcards. If set, anything not matched is hidden.
MCP_TELEGRAM_DISABLEno—Blocklist applied after the allowlist. Same syntax.
LOG_LEVELnoinfodebug for verbose stderr.
Choosing which tools the agent sees

The three gating vars stack — MCP_TELEGRAM_READONLY → MCP_TELEGRAM_TOOLS → MCP_TELEGRAM_DISABLE.

# Read-only agent — every mutating tool is hidden
MCP_TELEGRAM_READONLY=1

# Discovery-only — only login + the list/search/get tools
MCP_TELEGRAM_TOOLS='login,list*,search*,get*,resolveUsername'

# Allow writes but keep destructive ones away from the agent
MCP_TELEGRAM_DISABLE='delete*,ban*,kick*,create_channel,delete_channel,transfer_ownership,invokeMtproto'

# Specific surface: read + send/edit only
MCP_TELEGRAM_TOOLS='login,list_accounts,list_dialogs,list_messages,search_messages,search_global,send_message,editMessage'

In an MCP client config, drop these into the same env block as TELEGRAM_API_ID/TELEGRAM_API_HASH. To verify, re-open your client — the tools the server advertises are exactly the ones registered after the gates run.

Data layout

~/.telegram-agent/
├── state.json          known accounts (no secrets in here)
└── sessions/
    └── <account_id>/   per-account MTProto session

If a Telegram session is invalidated server-side (logged out from another device, password rotated, etc.), the next tool call returns an error telling the agent to call login to re-authorize.

Development

git clone https://github.com/beautyfree/mcp-telegram
cd mcp-telegram
npm install
echo "TELEGRAM_API_ID=...\nTELEGRAM_API_HASH=..." > .env
npm run dev

Layout:

src/
├── index.ts           bin entry — stdio MCP server, tool registrations
├── telegram.ts        MTProto client + login state machine
├── auth-browser.ts    ephemeral HTTP server that drives the browser flow
├── auth-page.ts       inline HTML for the auth page
├── state.ts           persistent state in ~/.telegram-agent/
└── logger.ts

License

MIT — see LICENSE.


Also known as

Telegram MCP · MCP Telegram · Telegram MCP server · Telegram for Claude · Telegram for Cursor · Telegram for Claude Code · Telegram for VS Code · Telegram for Codex · Telegram for Cline · Telegram for Windsurf · Telegram for AI agents · Telegram MTProto MCP · Telegram user-account MCP · Telegram automation MCP · Model Context Protocol Telegram · MCP server Telegram · gramjs MCP

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.