
通过这个功能,你可以搜索个人的Telegram消息,搜索联系人,并向个人或群组发送消息。
概览
这是一个Telegram的模型上下文协议(MCP)服务器。 通过这个功能,你可以搜索个人的Telegram消息,搜索联系人,并向个人或群组发送消息。 它通过Telegram API(使用Telethon库)直接连接到你的邮箱。你所有的消息都存储在本地的SQLite数据库中,只有当代理通过你控制的工具访问时才会发送给LLM(比如Claude)。 - Python 3.6+ - 拟人版Claude桌面应用(或光标) 创建一个Python虚拟环境并激活它:安装依赖: 这是一个既可用于运行 也可用于 的环境。 - 访问https://my.telegram.org/auth - 登录并进入“API 开发工具” - 创建新应用 - 记录你的 API ID 和 API 哈希 导航到telegram-bridge目录:
概述(AI 翻译)
这是一个Telegram的模型上下文协议(MCP)服务器。
通过这个功能,你可以搜索个人的Telegram消息,搜索联系人,并向个人或群组发送消息。
它通过Telegram API(使用Telethon库)直接连接到你的个人Telegram账户。你所有的消息都存储在本地的SQLite数据库中,只有当代理通过你控制的工具访问时才会发送给大型语言模型(比如Claude)。
安装
先决条件
- Python 3.6+
- Anthropic Claude桌面应用(或光标)
步伐
- 克隆此仓库
创建一个Python虚拟环境并激活它:
安装依赖:
该环境既可用于运行Telegram桥接也可用于MCP服务器。
- 获取你的Telegram API凭证
- 前往https://my.telegram.org/auth
- 登录并进入“API 开发工具”
- 创建一个新应用
- 记录你的API ID和API哈希
- 运行电报桥接
导航到telegram-bridge目录:
将你的API凭据设置为环境变量,可以通过导出它们:
或者通过创建一个“。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Telegram MCP Server
This is a Model Context Protocol (MCP) server for Telegram.
With this you can search your personal Telegram messages, search your contacts, and send messages to either individuals or groups.
It connects to your personal Telegram account directly via the Telegram API (using the Telethon library). All your messages are stored locally in a SQLite database and only sent to an LLM (such as Claude) when the agent accesses them through tools (which you control).
Installation
Prerequisites
- Python 3.6+
- Anthropic Claude Desktop app (or Cursor)
Steps
-
Clone this repository
git clone https://github.com/Muhammad18557/telegram-mcp.git cd telegram-mcpCreate a Python virtual environment and activate it:
python3 -m venv myenv source myenv/bin/activateInstall dependencies:
pip install -r requirements.txtThis is the environment that can be used both for running the Telegram bridge and the MCP server.
-
Get your Telegram API credentials
- Go to https://my.telegram.org/auth
- Log in and go to “API development tools”
- Create a new application
- Note your API ID and API hash
-
Run the Telegram bridge
Navigate to the telegram-bridge directory:
cd telegram-bridgeSet up your API credentials as environment variables either by exporting them:
export TELEGRAM_API_ID=your_api_id export TELEGRAM_API_HASH=your_api_hashOr by creating a
.envfile based on the provided.env.example:cp .env.example .env nano .env # or use your preferred text editorThen update the values in the
.envfile:TELEGRAM_API_ID=your_api_id TELEGRAM_API_HASH=your_api_hashRun the Python application:
python main.pyThe first time you run it, you will be prompted to enter your phone number and the verification code sent to your Telegram account.
-
Connect to the MCP server
First, update the
run_telegram_server.shscript with your absolute repository path:# Open the script in your preferred editor nano run_telegram_server.sh # Update line 4 with your absolute path to the repository # Change this: BASE_DIR="/Users/muhammadabdullah/Desktop/mcp/telegram-mcp" # To your actual BASE_DIR path (get it by running `pwd` in the telegram-mcp directory)Then, configure the MCP server by creating a JSON configuration file with the following format. Use the
BASE_DIRfrom above.{ "mcpServers": { "telegram": { "command": "/bin/bash", "args": [ "{{BASE_DIR}}/run_telegram_server.sh" ] } } }
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"telegram": {
"command": "/bin/bash",
"args": [
"{{BASE_DIR}}/run_telegram_server.sh"
]
}
}
}