Skip to main content

A Telegram MCP server for reading and writing messages.

Project description

Telegram MCP Server

Connect Claude to your Telegram account to read and send messages.

Features

Available Tools

  1. get_chats - List your Telegram chats

    • Returns paginated list with chat names, IDs, and unread counts
    • For page 1, just provide page number
    • For subsequent pages, use the pagination parameters from the previous response
  2. get_messages - Read messages from a specific chat

    • Fetches paginated message history
    • Automatically marks messages as read
  3. mark_messages_read - Mark all unread messages in a chat as read

  4. send_message - Send messages to any chat

    • Supports replying to specific messages
  5. get_conversation_context - Analyze chat style for natural responses

    • Reads your conversation style guide from convostyle.txt
    • Helps Claude match your texting patterns

Setup Guide

Step 1: Get Telegram API Credentials

  1. Go to https://my.telegram.org/apps
  2. Log in and create an application
  3. Save your API ID and API Hash

Step 2: Install

# Clone the repository
git clone https://github.com/alexandertsai/mcp-telegram
cd mcp-telegram

# Set up Python environment
pip install uv
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv sync

Step 3: Configure

# Copy the example file
cp .env.example .env

# Edit .env and add your API credentials:
# TELEGRAM_API_ID=your_api_id_here
# TELEGRAM_API_HASH=your_api_hash_here

Step 4: Authenticate

cd src/mcp_telegram
python telethon_auth.py

Follow the prompts:

  • Enter your phone number (with country code, e.g., +1234567890)
  • Enter the code sent to your Telegram
  • Enter your 2FA password if you have one

Step 5: Add to Claude Desktop

Find your Claude Desktop config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add this configuration:

{
  "mcpServers": {
    "telegram": {
      "command": "/path/to/python",
      "args": ["/path/to/mcp-telegram/src/mcp_telegram/main.py"]
    }
  }
}

To find paths:

  • Python: Run which python (Mac) or where.exe python (Windows)
  • main.py: Right-click the file and select "Copy Path"

Restart Claude Desktop.

Usage

After setup, you can ask Claude to:

  • "Check my Telegram messages"
  • "Send a message to [contact name]"
  • "What are my unread chats?"
  • "Reply to the last message from [contact name]"

Style Guide (Optional)

Create src/mcp_telegram/convostyle.txt to help Claude match your texting style:

I text casually with friends, formally with work contacts.
I use emojis sparingly and prefer short messages.

Troubleshooting

Authentication Issues

If authentication fails:

  1. Check your API credentials in .env
  2. Remove the TELEGRAM_SESSION_STRING line from .env
  3. Run python telethon_auth.py again

Common Errors

  • "Please set TELEGRAM_API_ID and TELEGRAM_API_HASH": Missing .env file or credentials
  • "Session string is invalid or expired": Re-run authentication
  • 2FA password not showing: This is normal - keep typing

Requirements

  • Python 3.10+
  • Claude Desktop
  • Telegram account

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_telegram_mcp-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_telegram_mcp-0.1.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_telegram_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: iflow_mcp_telegram_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"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}

File hashes

Hashes for iflow_mcp_telegram_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0af187f93b066a73ad21b92f3e8508c75ed66dd0252354a2975870b04d111339
MD5 3fc57e0de1ad2a01e4f5ee421e8e9151
BLAKE2b-256 0c997a1e52b2bcab40bb04e864b438de8445c612c0e91654b0d74435c54244e8

See more details on using hashes here.

File details

Details for the file iflow_mcp_telegram_mcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_telegram_mcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"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}

File hashes

Hashes for iflow_mcp_telegram_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 146ade6fcec26b1162a2b4f4f53a7adc2280b16c1f17bdd6192a0b411aa8fd68
MD5 249a39e335f084c97f5fcf0acd4ce10f
BLAKE2b-256 c2f9fff60ecd9c3dd188db6a021185051e300633fafd33c4a62e97c42c5502e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page