Telegram MCP Server

Telegram MCP Server

Enables Claude to interact with your Telegram account, including reading messages, searching conversations, and sending messages.

Category
访问服务器

README

Telegram MCP Server

This server gives Claude direct access to your Telegram account — read messages, search conversations, send messages, and more. Once installed, you can ask Claude things like "what did Daniel say in the Stellar group today?" or "send a message to [person] saying [thing]".

10 tools for full Telegram access. Built by Gonçalo.


What you'll need before starting

  • Python 3.10 or higher
  • Claude Desktop app installed (download here)
  • Claude Code installed (see below)
  • Your Telegram account (with the app on your phone for verification)
  • About 15 minutes

Installation

Step 1: Install Claude Code

If you don't have Claude Code yet, open your terminal (Terminal on Mac, Command Prompt or PowerShell on Windows) and run:

npm install -g @anthropic-ai/claude-code

If you don't have npm, install Node.js first from https://nodejs.org (download the LTS version, run the installer, then try the command above again).

Step 2: Get your Telegram API credentials

Before starting the installation, you need to get API credentials from Telegram:

  1. Go to https://my.telegram.org on your browser
  2. Log in with your phone number (the one linked to your Telegram)
  3. Click "API development tools"
  4. Fill in the form:
    • App title: anything (e.g., "Claude MCP")
    • Short name: anything (e.g., "claudemcp")
    • Platform: Desktop
    • Description: leave blank or put anything
  5. Click Create application
  6. You'll see your API ID (a number) and API Hash (a long string). Keep this page open.

Step 3: Let Claude Code do the rest

Open your terminal and run:

claude

Then paste this prompt:


Prompt to paste into Claude Code:

I need you to install a Telegram MCP server on my machine. Here's what to do:

1. Check that Python 3.10+ is installed (run python3 --version on Mac/Linux, or python --version on Windows)

2. Create a Projects folder in my home directory if it doesn't exist

3. Clone the repo:
   cd ~/Projects (or %USERPROFILE%\Projects on Windows)
   git clone https://github.com/goncaloreis/telegram-mcp.git
   cd telegram-mcp

4. Set up Python virtual environment:
   python3 -m venv venv (or python -m venv venv on Windows)
   Activate it and install requirements: pip install -r requirements.txt

5. Run the session generator:
   python3 generate_session.py (or python generate_session.py on Windows)
   
   This will ask me for:
   - API ID (I have it ready)
   - API Hash (I have it ready)  
   - Phone number (my Telegram number with country code)
   - Verification code (Telegram will send it to my phone)
   
   Wait for me at each prompt. After it completes, it will print a session string — save this.

6. Create the .env file by copying .env.example:
   cp .env.example .env (or copy .env.example .env on Windows)
   
   Then edit .env and fill in:
   - TELEGRAM_API_ID=<my API ID>
   - TELEGRAM_API_HASH=<my API hash>
   - TELEGRAM_SESSION_STRING=<the session string from step 5>

7. Test the server by running: python server.py
   If it starts without errors, Ctrl+C to stop it.

8. Configure Claude Desktop by editing the config file:
   - Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
   - Windows: %APPDATA%\Claude\claude_desktop_config.json
   
   Add this to the mcpServers section (adapt paths for my OS):
   
   On Mac:
   {
     "mcpServers": {
       "telegram": {
         "command": "/bin/bash",
         "args": ["-c", "cd $HOME/Projects/telegram-mcp && source venv/bin/activate && python server.py"]
       }
     }
   }
   
   On Windows:
   {
     "mcpServers": {
       "telegram": {
         "command": "cmd",
         "args": ["/c", "cd /d %USERPROFILE%\\Projects\\telegram-mcp && venv\\Scripts\\activate && python server.py"]
       }
     }
   }

   If the file already has other MCP servers (like google-workspace), merge this into the existing mcpServers object — don't overwrite them.

9. Tell me to restart Claude Desktop (Cmd+Q on Mac, or close fully on Windows) and reopen it.

Start by checking my OS and Python version, then proceed step by step. Ask me if anything is unclear.

Step 4: Verify it works

After restarting Claude Desktop, click the tools icon (🔨) at the bottom of the chat input. You should see tools like telegram_list_chats, telegram_read_messages, telegram_send_message, etc.

Try asking Claude: "List my 5 most recent Telegram chats"

If it works, you're done! 🎉


Troubleshooting

"FloodWaitError" during session generation Telegram rate-limits login attempts. Wait the indicated time and try again.

"Session string error" or "auth key not found" The session string was probably copied incorrectly. Run python3 generate_session.py again.

Tools don't show up in Claude Desktop

  • Check the config file for typos (especially commas between MCP entries)
  • Paste the config into https://jsonlint.com to check it's valid JSON
  • Restart Claude Desktop fully

Any other error Paste the error message to Gonçalo on Slack.


What can it do?

Once installed, you can ask Claude things like:

  • "What are my most recent Telegram messages?"
  • "Search my Telegram for messages about [topic]"
  • "What did [person] say in [group] today?"
  • "Send a message to [person] saying [thing]"
  • "Read the last 10 messages in the Stellar group"
  • "Find my conversation with [person]"

Claude will use the tools automatically — you just ask in plain language.


Security notes

  • The .env file contains your Telegram session string, which is equivalent to being logged in to your account. Never share this file.
  • The .gitignore is configured to exclude .env and session files from git.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选