telegram-mcp-server
telegram-mcp-server
Telethon ベースのTelegram MCPサーバー — 永続クライアント、フラッドセーフ、9つのグループ化されたツール。
コード内にAPIキーは不要。 セッションファイルはローカルに保存。ユーザーアカウント(2FA)とボットの両方に対応。
1. インストール
git clone <this-repo> telegram-mcp-server
cd telegram-mcp-server
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
pip install -e .API認証情報を取得
my.telegram.org にアクセス
電話番号でログイン
アプリを作成 → API ID と API Hash を取得
初回認証
# User account (with 2FA support)
export TG_API_ID=12345
export TG_API_HASH="your_hash_here"
telegram-mcp-server --auth --phone +33612345678
# Or via MCP tool: tg_session(action="auth", api_id=12345, api_hash="...", phone="+33612345678")Related MCP server: telegram-mcp
2. MCPクライアントに登録
Claude Desktop / OpenCode
{
"mcpServers": {
"telegram": {
"command": "telegram-mcp-server",
"env": {
"TG_API_ID": "12345",
"TG_API_HASH": "your_hash_here"
}
}
}
}PATHにない場合:
{
"mcpServers": {
"telegram": {
"command": "/path/to/.venv/bin/python",
"args": ["-m", "telegram_mcp_server"],
"env": {
"TG_API_ID": "12345",
"TG_API_HASH": "your_hash_here"
}
}
}
}Docker
docker build -t telegram-mcp .
docker run -i --rm \
-v ~/.telegram-mcp/sessions:/root/.telegram-mcp/sessions \
-e TG_API_ID=12345 \
-e TG_API_HASH="your_hash" \
telegram-mcp3. ツールカタログ(9ツール、8アクション)
tg_session — セッション管理
action | 必須引数 | 説明 |
|
| 認証(2FA対応) |
| — | ログイン状態を確認 |
| — | セッションを削除 |
tg_message — 送信、転送、削除、返信
action | 必須引数 | 説明 |
|
| メッセージを送信 |
|
| メッセージを転送 |
|
| メッセージを削除 |
|
| メッセージに返信 |
tg_chat — チャット操作
action | 必須引数 | 説明 |
| — | 最近のチャットを一覧 |
|
| チャット情報を取得 |
|
| チャットメンバーを一覧 |
|
| チャットから退出 |
tg_search — 検索
action | 必須引数 | 説明 |
|
| メッセージを検索( |
|
| 連絡先・ユーザーを検索 |
|
| チャンネルを検索 |
tg_history — チャット履歴
action | 必須引数 | 説明 |
|
| メッセージ履歴を取得 |
|
| メディアのみの履歴を取得 |
|
| ファイルのみの履歴を取得 |
tg_user — ユーザー操作
action | 必須引数 | 説明 |
| — | 自分の情報を取得 |
|
| ユーザー情報を取得 |
|
| ユーザーをブロック |
|
| ユーザーのブロックを解除 |
tg_media — メディア送信
action | 必須引数 | 説明 |
|
| 写真を送信 |
|
| 動画を送信 |
|
| ドキュメントを送信 |
|
| 音声メモを送信 |
tg_channel — チャンネル管理
action | 必須引数 | 説明 |
|
| スーパーグループ/チャンネルを作成 |
|
| チャンネルに参加 |
|
| チャンネルから退出 |
|
| チャンネル情報を取得 |
tg_draft — 下書きメッセージ
action | 必須引数 | 説明 |
|
| 下書きを保存 |
| — | すべての下書きを一覧 |
|
| 下書きを削除 |
4. 環境変数
変数 | デフォルト | 説明 |
|
| Telegram API ID(my.telegram.org から) |
|
| Telegram API Hash |
|
| セッションファイルの保存場所 |
5. 安全性
レートリミッター: 送信アクションは毎分5回まで。読み取りアクションは無制限。
FloodWaitError 自動リトライ: 必要な時間だけ待機(最大5分)。
セッションファイル: ローカルのみに保存され、git にコミットされることはありません。
2FA対応: 二段階認証が有効なアカウントを完全サポート。
6. MCPリソース
tg://version— サーバーバージョンtg://session/status— ログイン状態
ライセンス
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Telegram: FASTEST real time Telegram API. Retrieve channel's info and messages in milliseconds..
Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API
I use your linked Telegram MTProto session (Integrations → Telegram) to list groups, members, and s…
Telegram CRM: manage contacts, conversations, tickets, campaigns and analytics.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceConnects AI agents to Telegram via the official TDLib library, enabling tools like getting user info, listing dialogs, and searching messages.-
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Telegram Bot API for sending messages, photos, editing messages, answering callbacks, and fetching updates.MIT
- AlicenseNot gradedqualityBmaintenanceEnables sending Telegram messages, photos, and documents, and retrieving bot information through the Telegram Bot API.31 npm1MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with a user's Telegram account: list chats, read history, search, and send messages through Telegram's MTProto API.1MIT