Skip to main content
Glama
telegram-mcp-connector

telegram-mcp-connector

by nitatsuu

telegram-mcp-connector

An MCP server that lets Claude (Claude Code, Claude Desktop) read and search your own Telegram account, and, if you turn it on, send messages from it.

It logs in as you over MTProto (via Telethon), not as a bot, so Claude sees the same chats you do.

Security. The session file gives full access to your Telegram account. It stays on your machine, in .data/ inside this folder, with mode 0600, and is never committed. Write access is off by default.

Tools

Tool

What it does

whoami

Which account is connected

list_chats

Chats with unread counts and a last-message preview; can filter by type or unread, or list the Archive

get_messages

A chat's history, filterable by date range or sender, with pagination

get_message_context

A message plus its neighbours (handy after a search hit)

search_messages

Server-side full-text search in one chat or in all chats

get_unread

Unread messages grouped by chat (does not mark them read)

get_chat_info

Bio/description, member count, etc.

send_message ✋

Send text as you. Only to chats on the allowlist

mark_read ✋

Mark a chat as read

✋ These tools only exist when TG_ALLOW_WRITE=true.

A chat argument accepts a numeric id, @username, a t.me link, me (Saved Messages) or a chat title.

Related MCP server: Telegram MCP Server

Install

Everything installs inside this folder: the virtualenv in .venv/, the uv cache in .uv-cache/ (see uv.toml), and the session and config in .data/. Deleting the folder removes all of it. Requires uv and Python ≥ 3.11.

git clone https://github.com/nitatsuu/telegram-mcp-connector.git
cd telegram-mcp-connector
uv sync

1. Get API credentials

Go to https://my.telegram.org, open API development tools, and create an app (any name). You get an api_id and an api_hash.

2. Log in (once)

uv run telegram-mcp-connector login

It asks for api_id/api_hash (saved to .data/.env), then your phone number, the code Telegram sends you, and your 2FA password if you use one. The device shows up as telegram-mcp-connector under Telegram → Settings → Devices.

Check the result:

uv run telegram-mcp-connector status

3. Connect to Claude

Claude Code:

claude mcp add telegram -s user -- uv run --directory "$(pwd)" telegram-mcp-connector

Claude Desktop: add this to claude_desktop_config.json, using absolute paths:

{
  "mcpServers": {
    "telegram": {
      "command": "/opt/homebrew/bin/uv",
      "args": ["run", "--directory", "/path/to/telegram-mcp-connector", "telegram-mcp-connector"]
    }
  }
}

Then ask Claude something like "what did I miss in Telegram today?" or "find where Alex sent the contract".

Enabling writes

Edit .data/.env:

TG_ALLOW_WRITE=true
# ids and/or @usernames, comma-separated. "me" = Saved Messages, "*" = any chat.
TG_SEND_ALLOWLIST=me, @alice, -1001234567890

Restart Claude (or the MCP server) for the change to take effect. Get chat ids from list_chats.

Why the allowlist: messages Claude reads are written by other people. A message could contain instructions aimed at an AI. The server tells Claude to ignore such instructions, Claude asks before calling write tools, and the allowlist adds a hard limit on top of both.

Configuration

Values are read from environment variables, then from <data dir>/.env. Environment variables take priority.

Variable

Default

TG_API_ID, TG_API_HASH

—

From my.telegram.org

TG_ALLOW_WRITE

false

Expose send_message / mark_read

TG_SEND_ALLOWLIST

empty

Where send_message may post

TG_DATA_DIR

<project>/.data

Session and config location

Uninstall

uv run telegram-mcp-connector logout   # revokes the session on Telegram's side
claude mcp remove telegram -s user     # if added to Claude Code
cd .. && rm -rf telegram-mcp-connector

You can also revoke the session from Telegram → Settings → Devices.

Notes

  • Only one process can use the session at a time (it is an SQLite file). If login or status reports database is locked, close Claude first.

  • Telegram rate limits: short flood waits are slept through automatically. This tool is meant for personal use, not bulk messaging.

Development

uv run pytest

License

MIT

Available Tools

7 tools
get_chat_infoGet Chat InfoC
Read-only

Details about a chat or person: bio/description, member count, etc.

Inputs: chat (required). Returns: object

get_message_contextGet Message ContextA
Read-only

Show a message together with the messages around it (e.g. after a search hit).

Inputs: chat (required), message_id (required), radius. Returns: object

get_messagesGet MessagesA
Read-only

Read the latest messages of a chat, returned oldest to newest. If older_messages_before_id is present, pass it as before_id to page back.

Inputs: chat (required), limit, since, until, +2 more. Returns: object

get_unreadGet UnreadA
Read-only

Unread messages grouped by chat (main list, not Archive). Does not mark anything as read.

Inputs: per_chat, max_chats, include_muted. Returns: result

list_chatsList ChatsB
Read-only

List chats in the order Telegram shows them (most recent first), with unread counts and a preview of the last message.

Inputs: kind, limit, archived, unread_only. Returns: result

search_messagesSearch MessagesB
Read-only

Full-text search (Telegram server-side search), newest first.

Inputs: query (required), chat, limit. Returns: object

whoamiWhoamiA
Read-only

Show which Telegram account is connected.

Inputs: no named parameters. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools target clearly distinct needs (account identity, chat listing, message listing, search, unread aggregation, chat metadata). The closest overlap is get_messages vs get_message_context vs get_unread, but descriptions clarify that one pages through a chat, one shows a window around a message, and one aggregates unread across chats.

    Naming Consistency4/5

    Six of seven tools follow a predictable verb_noun pattern (list_chats, get_messages, get_message_context, search_messages, get_unread, get_chat_info). The lone 'whoami' is a conventional but inconsistent exception that breaks the pattern slightly.

    Tool Count4/5

    Seven tools is a reasonable, well-scoped surface for a read-oriented Telegram connector, with no obviously redundant entries. It sits comfortably in the typical 3-15 range and each tool maps to a distinct read operation.

    Completeness2/5

    The surface is entirely read-only: there is no send_message, reply, or mark-as-read operation, which are core Telegram actions an agent would expect from a connector. Reading is well covered (list, page, search, context, unread, metadata), but the missing write side is a significant gap that will cause agent failures for common tasks.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Read-only Telegram access for Claude and other MCP hosts. Provides tools to list chats, read recent messages, and download media from your own Telegram account without needing an api_id/api_hash.
      5
      66 npm
      MIT
    • F
      license
      Not graded
      quality
      F
      maintenance
      Enables Claude to interact with your Telegram account, including reading messages, searching conversations, and sending messages.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to interact with Telegram, including listing chats, reading messages, sending messages, searching, and managing contacts.
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connect Claude to your personal Telegram account via MTProto to read messages, search chats, send replies, forward files, and more using your real account.
      6 npm
      3
      MIT