This server allows you to connect Claude to your Telegram account, enabling it to read and send messages on your behalf. With this integration, Claude can interact with your Telegram chats, helping you manage conversations and respond to messages.
# 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
# Copy the example configuration 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
cd src/mcp_telegram
python telethon_auth.py
During the authentication process:
Locate your Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
Add the following configuration:
{
"mcpServers": {
"telegram": {
"command": "/path/to/python",
"args": ["/path/to/mcp-telegram/src/mcp_telegram/main.py"]
}
}
}
To find the correct paths:
which python
(Mac) or where.exe python
(Windows)Remember to restart Claude Desktop after making these changes.
Once properly set up, you can ask Claude to perform the following actions:
Claude can list your Telegram chats with:
Claude can fetch and read messages from any chat and will automatically mark them as read.
You can ask Claude to mark all unread messages in a specific chat as read.
Claude can send messages to any chat and supports replying to specific messages.
Create a file at src/mcp_telegram/convostyle.txt
with instructions about your texting style:
I text casually with friends, formally with work contacts.
I use emojis sparingly and prefer short messages.
This helps Claude analyze your chat style and match your texting patterns when responding.
If you encounter authentication issues:
.env
file.env
python telethon_auth.py
again to re-authenticate.env
fileTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "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"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"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"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"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"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect