telegram-commandcode
Provides tools for sending messages, photos, files, and reading updates from Telegram, allowing AI agents to communicate via Telegram chats.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@telegram-commandcodeSend the test results to Telegram"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
telegram-commandcode v2
Async Python Telegram bot for Command Code CLI — Hermes Agent architecture patterns.
Control your AI coding agent from Telegram with streaming progress, persistent sessions,
and resilient message delivery. Rewritten in Python with python-telegram-bot 20.x.
Telegram
↕
┌──────────┴──────────┐
│ bot.py (gateway) │ Async Python PTB bot
│ index.js (MCP) │ Node.js MCP server (unchanged)
└──────────┬──────────┘
↕
command code CLITwo Modes
Mode | File | Language | Direction | Purpose |
Bot Daemon |
| Python | Telegram → CC | Async gateway with streaming progress |
MCP Server |
| Node.js | CC → Telegram | Agent sends messages, files, photos |
Related MCP server: mcp-telegram
Architecture (v2)
telegram_commandcode/
├── bot.py # PTB Application — entry point & lifecycle
├── gateway.py # Async event router — non-blocking dispatch
├── commands.py # 46+ slash command handlers
├── executor.py # Async subprocess runner for `cmd`
├── session.py # Persistent session state (JSON-backed)
├── formatter.py # MarkdownV2 escaping & safe formatting
├── chunking.py # Smart 4096-char split + file fallback
└── __init__.pyKey Architectural Patterns
Pattern | Implementation |
Decoupled Gateway | PTB message handler is thin — never blocks. Long work dispatched via |
Persistent Sessions |
|
Streaming Progress | Edit-in-place: one status message, progressively edited with stages (🤔→✅/❌). No message flooding |
Resilient Chunking |
|
Error Boundaries | Every |
Quick Install
# Clone and install
git clone https://github.com/qrak/telegram-commandcode.git
cd telegram-commandcode
pip install -e "."
# Or with voice transcription support
pip install -e ".[voice]"Requirements
Python 3.11+
python-telegram-bot[job-queue]>=20.8Command Code CLI (
cmd) installed and on PATH(Optional)
openaifor voice transcription
Setup
# 1. Get bot token from @BotFather
# 2. Set environment variables
export TELEGRAM_BOT_TOKEN="123456:ABC..."
export TELEGRAM_ALLOWED_USERS="any" # or comma-separated user IDs
# 3. Start the bot
telegram-commandcode
# or: python -m telegram_commandcode.botEnv Vars
Variable | Default | Description |
| (required) | Bot token from @BotFather |
|
| Comma-separated user IDs |
|
| Path to Command Code binary |
|
|
|
|
| Max conversation turns per prompt |
| (optional) | For voice message transcription |
systemd Service (persistent)
# ~/.config/systemd/user/telegram-commandcode.service
[Unit]
Description=Telegram Command Code Bot
After=network-online.target
[Service]
Type=simple
ExecStart=/home/user/.local/bin/telegram-commandcode
Environment="TELEGRAM_BOT_TOKEN=your_token"
Environment="COMMAND_CODE_YOLO=true"
Restart=always
RestartSec=5
[Install]
WantedBy=default.targetsystemctl --user daemon-reload
systemctl --user enable --now telegram-commandcode.serviceFeatures
Feature | Description |
👀 Reactions | 👀 while processing, ✅ on success, ❌ on error |
📷 Photo reception | Photos downloaded and passed to |
📄 File reception | Documents sent to |
🎤 Voice transcription | OpenAI Whisper (requires |
📎 Auto-send files |
|
👥 Group chat | Responds when @mentioned or replied to |
✏️ Single-message editing | Status message edited in-place — no chat clutter |
🔄 Session chaining |
|
🎯 Goal tracking |
|
🧭 Mid-session steering |
|
📋 Prompt queueing |
|
🔄 Background tasks |
|
⚙️ Config persistence | Model/provider/effort persist to |
Slash Commands
All 46+ commands from the Node.js version are implemented. Type / in Telegram to see the menu.
CLI-mapped: /feedback, /learntaste, /login, /logout, /mcp, /skills, /taste, /info, /version, /update
Config & session: /status, /model, /effort, /provider, /add-dir, /goal, /steer, /plan, /compact-mode, /configure-models, /context
Session control: /resume, /clear, /new, /fork, /rename, /undo, /retry, /queue, /background, /stop, /reload
Prompt-based: /review, /init, /memory, /pr-comments, /agents, /cmd
MCP Server (unchanged)
The Node.js MCP server (index.js) remains for Command Code → Telegram direction:
cmd mcp add telegram \
-e TELEGRAM_BOT_TOKEN=*** \
-e TELEGRAM_DEFAULT_CHAT_ID=1141080547 \
-- npx github:qrak/telegram-commandcodeLicense
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
Unofficial Telegram MCP server — read, search, reply and react in your own Telegram account.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Related MCP Servers
- FlicenseAqualityDmaintenanceAn MCP server for interacting with Telegram bots and channels using the Telegraf library. It allows AI agents to send messages, manage channels, forward content, and intelligently respond to Telegram conversations.519 npm8-
- AlicenseBqualityDmaintenanceA Telegram MCP server that connects agents to a real Telegram user account via MTProto, enabling reading, searching, sending, moderating, and managing Telegram chats through natural language or automated tool calls.10090 npm29MIT
- FlicenseNot gradedqualityCmaintenanceMCP server that enables AI agents to send messages, photos, polls, and receive replies via Telegram with persistence and rate limiting.29 npm-
- AlicenseNot gradedqualityDmaintenanceAn MCP server enabling AI agents to interact with users via Telegram, supporting message and image sending, inline quick replies, and waiting for user responses.5 npmMIT