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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.