tg-mcp
This server provides full read/write access to a personal Telegram account from any MCP client.
Check account identity (
tg_whoami): See which Telegram account is signed in.List recent chats (
tg_list_chats): Retrieve recent Telegram chats with numeric IDs (configurable limit, default 40).Read messages (
tg_read_chat): Read messages from a chat by numeric ID, @username, or 'me' for Saved Messages, with optionalsince/untildate filters (YYYY-MM-DD).Search messages (
tg_search): Search message text across all chats or within a specific chat/peer.Download media (
tg_download_media): Download media attachments from a specific message to local disk, returning the local file path.Send text messages (
tg_send_message): Send a text message to any Telegram chat or user (irreversible).Send files (
tg_send_file): Send a file with optional caption to any Telegram chat or user (irreversible).
Provides tools to interact with a personal Telegram account, including reading chats, searching messages, downloading media, and sending messages or files.
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., "@tg-mcp check my last message from Anna"
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.
tg-mcp
MCP server for a personal Telegram account. Read, search, download media, and send messages or files, from any MCP client.
Credentials stay on the machine in ~/.tg/ and are never returned by any tool.
Setup on a new machine
Needs uv and nothing else. Python, dependencies and the package are all fetched on demand.
1. Sign in (once per machine, interactive because Telegram sends a code):
uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcp-loginIt prompts for api_id / api_hash from https://my.telegram.org (API development
tools), then your phone number, then the code Telegram sends to the app. It writes
~/.tg/credentials.json and ~/.tg/session.session, both mode 600, and prints your
recent chats with their ids.
2. Register the server:
claude mcp add telegram -- uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcpThat is the whole setup. claude mcp list should show telegram ✔ Connected.
Related MCP server: telegram-mcp
Setting it up for other agents
The sign-in is per machine, not per agent. Run tg-mcp-login once and every agent on
that machine shares ~/.tg/. Adding a second or third client is config only.
There is no single config format across MCP clients, so this package ships an installer that writes each one in its own shape:
uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcp-installIt configures every supported client it finds and leaves the rest alone. --list shows
what it detected, --dry-run prints the changes without making them, --name sets the
server name, and naming clients (tg-mcp-install opencode cursor) limits it to those.
Existing config is merged rather than replaced, a .bak is kept, and a config file it
cannot parse is skipped with a warning rather than overwritten.
Client | How it is registered |
Claude Code |
|
Codex |
|
opencode |
|
Claude Desktop |
|
Cursor |
|
Windsurf |
|
The rest of this section is the same thing by hand. Under every format it is one command and three arguments:
command |
|
args |
|
Claude Code
claude mcp add telegram -- uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcpAdd --scope user to make it available in every project rather than just the current one.
Claude Desktop, Cursor, Windsurf, Continue, and most others
These share the same mcpServers block. Add:
{
"mcpServers": {
"telegram": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Abdk4Moura/tg-mcp", "tg-mcp"]
}
}
}to the client's config file:
Client | File |
Claude Desktop (macOS) |
|
Claude Desktop (Windows) |
|
Cursor |
|
Windsurf |
|
Continue |
|
Restart the client afterwards. Most only read MCP config at startup.
opencode
opencode does not use mcpServers. Its key is mcp, the command is a single array rather
than a command plus args, and each server declares its type. Add to
~/.config/opencode/opencode.json (or opencode.json / .opencode/opencode.json in a
project, for that project only):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"telegram": {
"type": "local",
"command": ["uvx", "--from", "git+https://github.com/Abdk4Moura/tg-mcp", "tg-mcp"],
"enabled": true
}
}
}Environment variables go in an environment object, not env. opencode mcp list shows
the server and whether it connected.
opencode reads opencode.json and opencode.jsonc and merges them, so if your config is
a commented .jsonc you can drop the block above into a plain opencode.json beside it
and leave the commented file alone. That is what tg-mcp-install does.
opencode mcp add telegram also works, but it prompts for the command interactively, so
it is not scriptable for a local server the way claude mcp add is. The --url flag on
that command is for remote servers only.
Codex
codex mcp add telegram -- uvx --from git+https://github.com/Abdk4Moura/tg-mcp tg-mcpCodex stores this in ~/.codex/config.toml. codex mcp list shows it.
Anything else
Give the client the same command and args from the table at the top of this section, in whatever shape its own MCP documentation specifies.
If uvx is not on PATH
Some clients launch with a minimal environment and will not find uvx. Use its absolute
path as the command (which uvx to find it, commonly ~/.local/bin/uvx).
Tools
Tool | What it does |
| Which account is signed in |
| Recent chats with their numeric ids |
| Read messages; |
| Search message text across all chats or within one peer |
| Fetch a message's attachment to disk |
| Sends text. Real, immediate, not recallable by this server |
| Sends a file with an optional caption |
Sessions
Each machine that runs tg-mcp-login creates its own Telegram session, listed
separately under Settings → Devices and revocable on its own.
Copying session.session between machines also works, but both then share one session
identity: revoking it logs out both, and a login from a very different IP can trip
Telegram's security checks. Prefer a fresh login per machine.
That file is full account access. Anyone holding it can read and send as you.
Configuration
Variable | Default | Purpose |
|
| Where |
|
| Where |
Local development
uv run --directory /path/to/tg-mcp tg-mcpAvailable Tools
7 toolstg_download_mediaA
Download the media attached to one message. Returns the local path. message_id comes from tg_read_chat or tg_search.
Inputs: peer (required), message_id (required). Returns: result
tg_list_chatsA
List recent Telegram chats with their numeric ids, newest first.
Inputs: limit. Returns: result
tg_read_chatA
Read messages from a chat, oldest first. peer is a numeric id, an @username, or 'me' for Saved Messages. Optional since/until are YYYY-MM-DD.
Inputs: peer (required), limit, since, until. Returns: result
tg_searchA
Search messages by text, across all chats or within one peer.
Inputs: query (required), peer, limit. Returns: result
tg_send_fileA
SEND a file to a Telegram chat, with an optional caption. Delivers immediately and cannot be unsent by this server. Use 'me' for Saved Messages.
Inputs: path (required), peer (required), caption. Returns: result
tg_send_messageA
SEND a text message to a Telegram chat. This delivers immediately to a real person and cannot be unsent by this server. Use 'me' to write to Saved Messages.
Inputs: peer (required), text (required). Returns: result
tg_whoamiA
Which Telegram account this server is signed in as.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a distinct action: listing chats, reading messages, searching, downloading media, sending text, sending files, and identifying the account. There is no overlap, and the boundaries between tools are clear.
All tools share the 'tg_' prefix and most follow a verb_noun pattern (list_chats, read_chat, download_media, send_message, send_file). Two exceptions are 'search' (verb only) and 'whoami' (question format), which are minor deviations from the otherwise consistent pattern.
Seven tools is well-scoped for a Telegram server, covering core operations without being either too sparse or overly heavy. Each tool has a clear purpose and earns its place in the set.
The set covers the primary Telegram workflows: discovering chats, reading and searching messages, downloading media, sending text and files, and checking account identity. Minor gaps like message editing/deletion or chat management exist, but they are not critical for the server's apparent purpose.
Maintenance
Related MCP Connectors
Unofficial Telegram MCP server — read, search, reply and react in your own Telegram account.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Hosted Telegram MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- FlicenseBqualityDmaintenanceAn MCP server that enables interaction with Telegram messaging platform, allowing users to retrieve unread messages, fetch entity information, and send messages through natural language interfaces.610-
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables interaction with Telegram to send, read, and search messages across chats and dialogs. It supports waiting for incoming messages and retrieving conversation history through natural language commands.17 npm3MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that connects to Telegram as your real user account and exposes read-only tools to read and search messages, list chats and folders, inspect group info, and download media.19 npmMIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that automates a single Telegram user account via the Telegram user API, enabling chat listing, reading/sending messages, searching, and additional actions through natural language.11 npmMIT