Telegram MCP Server
Enables remote control of AI coding assistants (Claude Code/Codex) via Telegram, allowing you to manage long-running tasks, send commands, and receive notifications from anywhere. Supports unattended mode with smart polling for up to 7 days and multi-session management.
README
Telegram MCP Server
Remote control AI coding assistants (Claude Code / Codex) via Telegram
English | 简体中文
Why This Project?
Have you ever encountered these scenarios:
- 💤 Late at night in bed, you suddenly think of a bug that needs fixing, but don't want to get up and open your laptop?
- 🚇 On your commute, you want AI to refactor code for you, but your laptop isn't with you?
- 🏢 Multiple Claude Code or Codex sessions running on remote servers, and you want to check their progress anytime?
- ⏰ Long-running tasks (testing, building, refactoring) that take hours, but you don't want to sit in front of the computer?
Telegram MCP Server was created to solve these problems!
Through the MCP (Model Context Protocol), this project allows you to:
- 📱 Anytime, anywhere view and control AI coding assistants via Telegram
- 🔄 Multi-session management: Use
screenon remote servers to manage multiple projects simultaneously - 🌙 True unattended mode: Wait up to 7 days with smart polling, minimal system resources
- 💬 Simple interaction: Send messages via Telegram to give AI assistants next instructions
Perfect for:
- 24/7 remote servers
- Long-running tasks
- Multi-project parallel development
- Remote work from anywhere
Features
- 🌙 True Unattended Mode - Wait up to 7 days with smart progressive polling
- 📱 Remote Control - Control AI assistants from anywhere via Telegram
- 🔄 Two-way Communication - Send notifications, receive replies, continuous dialogue
- 📁 File Operations - View and download project files
- 🎯 Multi-session Management - Manage multiple projects simultaneously
- 🤖 Universal Support - Works with both Claude Code and Codex
Quick Start
1. Installation
# Recommended: using uv
uv tool install telegram-mcp-server
# Or using pip
pip install telegram-mcp-server
2. Setup
telegram-mcp-server --setup
Interactive wizard will help you:
- Create Telegram Bot
- Get credentials
- Auto-configure AI assistant
3. Usage
# Recommended: Start with bypass permissions mode
# Avoid interruptions due to permission confirmations during AI-Telegram interaction
# Note: Cannot run as root due to security mechanisms
# Claude Code
claude --permission-mode bypassPermissions
# Codex
codex --dangerously-bypass-approvals-and-sandbox
# In the AI assistant
> Enter unattended mode. Task: analyze project structure
Check results in Telegram and continue the conversation!
How It Works
AI Assistant (Claude Code/Codex)
↓ MCP Protocol
MCP Server (telegram-mcp-server)
├─ 8 tools (notify, wait, file operations, etc.)
└─ Telegram Bot (background process)
↓ Telegram API
Your Telegram Client
Core Features
MCP Tools (8 tools)
telegram_notify- Send structured notifications (recommended)telegram_wait_reply- Wait for user reply (blocking poll)telegram_unattended_mode- Unattended mode (smart loop)telegram_send_code- Send code (with syntax highlighting)telegram_send_image- Send imagestelegram_send_file- Send filestelegram_send- Send free-form messagestelegram_get_context_info- Get session context info
Telegram Commands (6 commands)
/sessions- List all sessions/status <id>- Check session status/to <id> <msg>- Send message to session/file <id> <path>- View file/delete <id>- Delete session/help- Show help
Smart Polling
Progressive polling strategy, wait up to 7 days:
| Wait Time | Check Frequency | Response Delay |
|---|---|---|
| 0-30 min | Every 30s | Max 30s |
| 30-60 min | Every 60s | Max 60s |
| 1+ hour | Every 120s | Max 120s |
Use Cases
Scenario 1: Overnight Tasks
# 10 PM
> Enter unattended mode. Task: run full test suite and fix all errors
# 8 AM - check results in Telegram
Scenario 2: Remote Work
# At office
> Enter unattended mode. Task: refactor database access layer
# On the road - monitor and control via Telegram
Scenario 3: Multi-project Management (Remote Server + screen)
# SSH to remote server
ssh user@server
# Create multiple screen sessions
screen -S project-a
cd /path/to/project-a
TELEGRAM_SESSION="proj-a" claude --permission-mode bypassPermissions
# Ctrl+A D to detach
screen -S project-b
cd /path/to/project-b
TELEGRAM_SESSION="proj-b" codex --dangerously-bypass-approvals-and-sandbox
# Ctrl+A D to detach
# Manage both projects in Telegram
# Sessions keep running even after closing SSH
Scenario 4: Late Night in Bed
# During the day, start session on server
screen -S night-task
TELEGRAM_SESSION="night-fix" claude --permission-mode bypassPermissions
# At night in bed, send commands via Telegram
/to night-fix Fix null pointer exception in auth.py
# Next morning, check results
/status night-fix
Configuration
Claude Code
Supports three configuration scopes:
- User scope:
~/.claude/mcp.json- Global config - Project scope:
.mcp.json- Team shared - Local scope:
.claude/mcp.json- Project specific
Codex
Global config: ~/.codex/config.toml
Auto-includes tool_timeout_sec = 604800 (7 days timeout)
Environment Variables
# Custom session name
TELEGRAM_SESSION="my-task" claude
# Custom max wait time
TELEGRAM_MAX_WAIT=86400 claude # 24 hours
# Custom poll intervals
TELEGRAM_POLL_INTERVAL="10,30,60" claude
Troubleshooting
Issue: Telegram Bot Not Responding
# Check logs
tail -f /tmp/telegram-mcp-server.log
# Quick fix
cd telegram-mcp-server
./quick_fix.sh
Issue: Codex 60s Timeout
# Auto fix
./fix_codex_timeout.sh
Issue: Session Not Registered
# Reconfigure
telegram-mcp-server --setup
Documentation
- Configuration Guide - Detailed configuration
- Polling Mechanism - Smart polling explained
- Troubleshooting - Common issues
- How MCP Works - Technical architecture
Requirements
- Python 3.10+
- Claude Code or Codex
- Telegram account
Contributing
Contributions welcome! See CONTRIBUTING.md
License
MIT License - see LICENSE
Support
- 🐛 Report Issues
- 💬 Discussions
- ⭐ Star if you find it useful!
Let AI coding assistants work for you, not you waiting for them 🚀
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。