telegram-commandcode
MCP server for Telegram integration with Command Code, enabling AI agents to send messages, photos, files, and read updates via Telegram.
README
telegram-commandcode
Full Telegram ↔ Command Code bridge — control your AI coding agent from Telegram and get notifications back.
Telegram
↕
┌──────────┴──────────┐
│ bot.js (daemon) │ Telegram → Command Code
│ index.js (MCP) │ Command Code → Telegram
└──────────┬──────────┘
↕
command code CLI
Two Modes
| Mode | File | Direction | What it does |
|---|---|---|---|
| MCP Server | index.js |
CC → Telegram | Command Code agent sends you messages, files, photos |
| Bot Daemon | bot.js |
Telegram → CC | You type prompts on Telegram → Command Code executes → result back to Telegram |
Mode 1: Bot Daemon (Telegram → Command Code)
Control Command Code from Telegram like you're sitting at the terminal.
Setup
# 1. Get bot token from @BotFather
# 2. Start the daemon
TELEGRAM_BOT_TOKEN=*** \
TELEGRAM_ALLOWED_USERS=any \
node bot.js
Env vars
| Variable | Default | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN |
(required) | Bot token from @BotFather |
TELEGRAM_ALLOWED_USERS |
any |
Comma-separated user IDs for access control |
COMMAND_CODE_CMD |
cmd |
Path to Command Code binary |
COMMAND_CODE_YOLO |
true |
false → read-only mode (no file writes/shell) |
COMMAND_CODE_MAX_TURNS |
20 |
Max conversation turns per prompt |
Slash Commands
Type / in the Telegram message box — all 27 Command Code commands are registered:
🟢 CLI-mapped (run directly)
| Command | Action | Maps to |
|---|---|---|
/feedback <msg> |
Submit feedback | cmd feedback |
/learntaste |
Learn taste from other agents | cmd learn-taste |
/login |
Authenticate | cmd login |
/logout |
Remove auth | cmd logout |
/mcp [list/add/remove] |
Manage MCP servers | cmd mcp |
/skills [list/add/remove] |
Manage skills | cmd skills |
/taste [list/push/pull] |
Manage taste | cmd taste |
/status |
Version, auth, session info | cmd whoami + cmd --version |
/model [name] |
List models or /model claude-sonnet-4-6 to switch |
cmd --list-models or cmd -m <name> |
/resume |
Continue last session | cmd -p --continue |
/clear |
Fresh session (forget context) | drops --continue |
/plan [task] |
Toggle plan mode or /plan <task> for one-shot |
cmd -p --plan |
/review <PR#> |
Review a pull request | cmd -p prompt |
/init |
Create AGENTS.md | cmd -p prompt |
/cmd <prompt> |
Explicit prompt alias | cmd -p prompt |
ℹ️ TUI-only (informational)
/agents · /compact · /effort · /ide · /memory · /pr-comments · /provider · /rewind · /terminal-setup · /add-dir
Bot politely explains these require interactive TUI mode.
⛔ N/A remotely
/exit · /share · /unshare
Usage
You (Telegram): Build a CLI that tells the date, using TypeScript
Bot: 🚀 Running: `Build a CLI that tells the date...`
✅ Done: Built date-cli with TypeScript, tsup, vitest...
You: /resume
Bot: 🔄 Resuming last headless session...
📋 *Session resumed:* The previous task was building a date CLI...
You: /clear
Bot: 🧹 Session cleared. Next prompt starts fresh.
You: /status
Bot: 🔧 Command Code Status
Binary: `cmd`
Auth: qrak
Session: active (use /resume, /clear)
YOLO mode: on (all tools)
Max turns: 20
How it works
- Daemon polls Telegram via
getUpdates(long polling, 30s timeout) - Incoming message →
cmd -p "prompt" --yolo --max-turns 20 cmd -pruns headless (non-interactive), outputs response to stdout- Response sent back to Telegram (auto-split for long messages)
- Session chaining via
cmd -p --continue(context preserved between messages) /cleardrops--continue→ fresh session
Mode 2: MCP Server (Command Code → Telegram)
Let your Command Code agent send you notifications while it works.
Register in Command Code
cmd mcp add telegram \
-e TELEGRAM_BOT_TOKEN=*** \
-e TELEGRAM_DEFAULT_CHAT_ID=1141080547 \
-- npx github:qrak/telegram-commandcode
MCP Tools
| Tool | What it does |
|---|---|
telegram_send_message |
Send a text message (MarkdownV2 or HTML) |
telegram_send_photo |
Send a photo (URL or local file) |
telegram_send_file |
Send any file/document |
telegram_get_updates |
Read recent incoming messages |
Usage
> Run the build, and if it passes send "✅ Build OK" to Telegram
[Command Code builds...]
Using telegram tool: telegram_send_message
→ You get notified on your phone 📱
Running Both
Use both modes for full two-way interaction:
# Terminal 1 — Telegram → Command Code daemon
TELEGRAM_BOT_TOKEN=*** node bot.js
# Terminal 2 — Register MCP in your project
cd my-project
cmd mcp add telegram -e TELEGRAM_BOT_TOKEN=*** -- node index.js
cmd # start interactive session
Now you can:
- Send prompts from your phone → executed by
cmd - Agent sends you notifications when done
/resumeto continue sessions from anywhere
Quick Install
# Clone
git clone https://github.com/qrak/telegram-commandcode.git
cd telegram-commandcode
npm install
# Bot daemon
TELEGRAM_BOT_TOKEN=*** node bot.js
# MCP server (for Command Code registration)
TELEGRAM_BOT_TOKEN=*** node index.js
Or via npx (for MCP mode):
cmd mcp add telegram -e TELEGRAM_BOT_TOKEN=*** -- npx github:qrak/telegram-commandcode
Troubleshooting
| Symptom | Fix |
|---|---|
TELEGRAM_BOT_TOKEN not set |
Export it or create .env file from .env.example |
cmd: command not found |
Command Code not installed: npm i -g command-code |
| Bot doesn't respond | Check TELEGRAM_ALLOWED_USERS — your user ID must be in the list |
| Session context lost | Use /resume (not /clear) to keep context between messages |
| File not found (MCP) | Use absolute paths. For project files: /home/user/project/file.pdf |
| Exit code 3 (auth) | Run cmd login on the machine first |
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。