Telegram MCP Server

Telegram MCP Server

A simple MCP server that allows Claude to access your Telegram account to read and send messages on your behalf.

Category
Visit Server

README

Telegram MCP Server

This is a simple MCP server that lets Claude access your Telegram account to read and send messages.

Functions

  1. get_chats: Get a list of your Telegram chats
  2. send_message: Send a message to a chat
  3. get_message: Gets messages from a chat and prints the unread messages
  4. mark_messages_read: Mark messages as read
  5. get_conversation_context: Gets past 20 messages and reads convostyle.txt to determine an appropriate reply

Setup

Step 1: Get Your Telegram API Credentials

  1. Go to https://my.telegram.org/apps
  2. Log in and create an application (or use an existing one)
  3. Note down your API ID and API Hash

Step 2: Set Up Python Environment

Install the required packages:

# Clone the repository within your desired directory (if you haven't already)
git clone https://github.com/alexandertsai/mcp-telegram
cd mcp-telegram

Set up the virtual environment. Use pip3 instead if applicable.

# Set up virtual environment
pip install uv mcp
uv venv
source .venv/bin/activate
# .venv\Scripts\activate for windows
uv add "mcp[cli]" telethon python-dotenv nest_asyncio

Step 3: Add IDs

For Mac (bash):

In the virtual environment, run the following:

export TELEGRAM_PHONE=phone number with country code and no spaces
export TELEGRAM_API_ID=api_id
export TELEGRAM_API_HASH=api_hash

Check to see if they have been exported with printenv in terminal.

For Windows (Powershell):

In the virtual environment, run the following. Make sure to include the quotation marks otherwise powershell may struggle:

$env:TELEGRAM_PHONE="phone number with country code and no spaces"
$env:TELEGRAM_API_ID="api_id"
$env:TELEGRAM_API_HASH="api_hash"

Check to see if they have been exported with gci env: in powershell.

Step 4: Run authentication

Run this to authenticate. If you have 2FA, when typing in your password you will not see any text appear in the terminal. This is normal! Try not to make a typo during 2FA - it makes you restart the entire process if you do... Use python or python3 depending on which you have installed.:

cd src/mcp_telegram
python3 telethon_auth.py

You'll be asked for:

  • Your phone number (in international format with +) (do not leave any spaces)
  • The code Telegram sends to your account
  • Your 2FA password (if enabled)

This creates a session file in your home directory so you don't need to authenticate again.

Step 5: Add to Claude Desktop

Edit your Claude Desktop configuration:

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

Alternatively, go to settings, click on Developer and then Edit Config. Make sure developer mode is enabled.

Add this to your config (replace with your actual credentials) :

"mcpServers": {
      "telegram": {
      "command": "/your/path/to/python3",
      "args": ["/full/path/to/mcp-telegram/main.py"],
      "env": {
          "TELEGRAM_API_ID": "your_api_id_here",
          "TELEGRAM_API_HASH": "your_api_hash_here",
          "TELEGRAM_PHONE": "+65945678900"
          }
      }
  }

main.py: To get the full path, go to your IDE or desktop, find the file, right click on it, and click "COPY PATH".

python: Run where.exe python (Windows) or where python (Mac) in your terminal to get the full path (replace with python3 if needed). If on Windows, you may need to replace the backslashes in your path with forward slash because of JSON formatting (ctrl+f "\", replace all (ctrl + h) with "/").

VERY IMPORTANT:

  1. Use the full absolute path to both Python and the main.py script
  2. Replace API credentials with your actual values from Step 1
  3. Set your phone number in international format

Step 6 (optional):

Feel free to configure convostyle.txt in src/mcp_telegram if you want the chatbot to respond and sound like you.

That's It!

Restart Claude Desktop (quit and reopen), and you can now ask Claude to:

  • Show your recent Telegram chats
  • Read messages from specific chats
  • Mark certain messages as "read"
  • Send messages to your contacts or groups while sounding natural

Make sure to include the word "Telegram" when asking Claude a prompt or it might not understand. For example, "Claude do I have any unread telegram messages?"

Pesky troubleshooting

While in the virtual environment, try running:

ls -la ~/.mcp_telegram_*

Then terminate your session files with (just copy and paste the path of the files with rm in front)

rm /Users/username/.mcp_telegram_numberininternationalformat*

Try step 3 again.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured