Skip to main content

telethon-mcp

Telegram MCP Server — control Telegram through Claude using the Telethon library.

PyPI version License: MIT Python

46 tools across messaging, chats, contacts, media, admin, and advanced features — powered by Telethon, the full-featured Telegram MTProto client.

Tools

Messaging (8)

Tool Description
send_message Send a message to a chat or user
edit_message Edit a sent message
delete_message Delete a message
forward_message Forward a message to another chat
reply_to_message Reply to a specific message
get_messages Get messages from a chat
search_messages Search messages across chats
pin_message Pin or unpin a message

Chats (8)

Tool Description
list_chats List all chats and groups
get_chat_info Get details about a chat
create_group Create a new group
create_channel Create a new channel
join_chat Join a chat via link or username
leave_chat Leave a chat
archive_chat Archive or unarchive a chat
mute_chat Mute or unmute a chat

Contacts (6)

Tool Description
list_contacts List all contacts
add_contact Add a new contact
delete_contact Remove a contact
block_user Block a user
unblock_user Unblock a user
get_user_info Get detailed info about a user

Media (6)

Tool Description
send_photo Send a photo
send_document Send a file/document
send_voice Send a voice message
send_video Send a video
download_media Download media from a message
get_profile_photo Get a user or chat's profile photo

Admin (9)

Tool Description
ban_user Ban a user from a group/channel
unban_user Unban a user
kick_user Kick a user from a group
promote_admin Promote a user to admin
demote_admin Remove admin rights from a user
set_chat_title Change a chat's title
set_chat_photo Change a chat's photo
get_participants List all members of a group/channel
invite_user Invite a user to a group/channel

Advanced (9)

Tool Description
send_reaction Add a reaction to a message
create_poll Create a poll in a chat
schedule_message Schedule a message for later
get_scheduled_messages List scheduled messages
delete_scheduled_message Delete a scheduled message
set_typing Send typing indicator
mark_as_read Mark messages as read
get_drafts Get saved drafts
save_draft Save a message draft

Setup

Prerequisites

  • Python 3.10+
  • uv package manager
  • Telegram API credentials (free from Telegram)

Step 1 — Get Telegram API Credentials

  1. Go to my.telegram.org/apps
  2. Log in with your Telegram phone number
  3. Click "Create new application"
  4. Fill in the form (App title and short name can be anything)
  5. Copy your API ID (number) and API Hash (string)

Step 2 — Install

pip install telethon-mcp
# or with uv:
uv add telethon-mcp

Step 3 — Generate Session String

python -m telethon_mcp.generate_session
# or after install:
generate-session

This opens an interactive flow:

  1. Enter your API ID and API Hash
  2. Enter your phone number (with country code)
  3. Enter the OTP sent to your Telegram
  4. Enter your 2FA password if enabled
  5. Copy the generated session string

Step 4 — Configure

Create a .env file in your working directory:

TELEGRAM_API_ID=your_api_id
TELEGRAM_API_HASH=your_api_hash
TELEGRAM_SESSION_STRING=your_session_string

Step 5 — Add to Claude Code

claude mcp add telegram -- uvx telethon-mcp

Or manually in your Claude config (~/.claude/claude_desktop_config.json):

{
  "mcpServers": {
    "telegram": {
      "command": "uvx",
      "args": ["telethon-mcp"],
      "env": {
        "TELEGRAM_API_ID": "your_api_id",
        "TELEGRAM_API_HASH": "your_api_hash",
        "TELEGRAM_SESSION_STRING": "your_session_string"
      }
    }
  }
}

Security

  • Session string gives full access to your Telegram account — treat it like a password
  • Never commit your .env file or session string to version control
  • Add .env to your .gitignore
  • To revoke access: go to Telegram Settings → Privacy → Active Sessions → terminate the session

Troubleshooting

"TELEGRAM_SESSION_STRING not set": Run generate-session and add the output to your .env.

"AuthKeyError" or session invalid: Your session expired or was revoked. Run generate-session again.

Flood wait errors: Telegram rate-limits heavy usage. The server will wait automatically.

2FA required during session generation: Enter your Two-Step Verification password when prompted.


Requirements

  • Python 3.10+
  • A Telegram account
  • Telegram API credentials (free from my.telegram.org)

License

MIT — Hitesh Gupta

Metadata

Release files for telethon-mcp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for telethon-mcp 1.0.0
File Size Uploaded Provenance
telethon_mcp-1.0.0.tar.gz 20.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for telethon-mcp 1.0.0
File Interpreter ABI Platform
telethon_mcp-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 44.0 kB

Release files / telethon_mcp-1.0.0.tar.gz

Download URL telethon_mcp-1.0.0.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4325f3938b13a7b076917520135d3fae12508af2f76c34e8e46e65d6063d3412
BLAKE2b-256 checksum
How to use checksums
0a21aa4befde72c64738dad1d0aea12e5a684bd1ac81bfa60a2102bbec18175d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / telethon_mcp-1.0.0-py3-none-any.whl

Download URL telethon_mcp-1.0.0-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
071cb58428f03a6a3a0c0a092740cfca826a5518248fbea6f1105a200010e9aa
BLAKE2b-256 checksum
How to use checksums
e9ac00d940d9f9473299073e48f47600ab2f03401f191f486d24d72320f8705e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for telethon-mcp 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page