Telegram to Claude Code CLI sync bot. Setup it to be able to speak to via voice messages, send files and receive detailed html reports via telegram.
Telegram Bot MCP Server for Claude Code. Bridges Claude Code sessions and Telegram via forum topics.
Claude Code sends messages to Telegram forum topics and polls for replies — enabling async human oversight of long-running agent sessions.
/newbotЛюда)_bot (например: LLuda_bot)1234567890:AAH.... Скопировать и сохранить.Рекомендация: отключить Group Privacy, чтобы бот видел все сообщения в группе (не только ответы на него):
/mybots → выбрать бота → Bot Settings → Group Privacy → Turn offClaude Code PRO)После включения Topics группа автоматически станет супергруппой с форумом. Теперь у неё будет раздел "General" и возможность создавать тематические топики.
@LLuda_bot)Без прав администратора бот не сможет создавать топики.
Способ 1 — через API (универсальный):
https://api.telegram.org/bot<BOT_TOKEN>/getUpdates(заменить <BOT_TOKEN> на токен из шага 1)"chat":{"id":-100...} — это и есть Chat ID (отрицательное число вида -1001234567890)Способ 2 — через URL (для public групп):
https://web.telegram.org/a/#-1001234567890 или для legacy https://t.me/c/1234567890/1-100 + число из URL → -1001234567890198019340Этот ID нужен для ADMIN_USER_ID. Бот будет принимать сообщения только от этого пользователя и игнорировать всех остальных.
cd ~/tg-cc-sync-bot-mcp/main
cp .env.example .envОткрыть .env и заполнить:
BOT_TOKEN=1234567890:AAH...
CHAT_ID=-1001234567890
ADMIN_USER_ID=198019340
PORT=8000cd ~/tg-cc-sync-bot-mcp/main
docker compose up -d --buildПроверить, что сервер запустился:
curl http://localhost:17005/api/health
# Ожидаемый ответ: {"status":"ok","timestamp":"..."}
curl http://localhost:17005/api/bot-info
# Ожидаемый ответ: имя и username ботаclaude mcp add-json tg-cc-sync-bot '{"type":"http","url":"http://localhost:17005/mcp"}'Если используется claude-setup-alexmak — достаточно выполнить /setup-apply, MCP-сервер будет добавлен автоматически.
Запустить новую сессию Claude Code в любом проекте. Если всё настроено правильно:
.telegram-chat появится в директории проектаБот не создаёт топики:
Бот не видит сообщения из группы:
/mybots → Bot Settings → Group Privacy → Turn offADMIN_USER_ID совпадает с вашим реальным Telegram IDКонтейнер не запускается:
docker compose logs --tail=50Health check не проходит:
curl -v http://localhost:17005/api/healthSingle Node.js process: three components run concurrently via Promise.all.
┌─────────────────────────────────────────────────────┐
│ Node.js Process │
│ │
│ grammY (long polling) → MessageBuffer (in-memory)│
│ ↓ │
│ MCP Server (HTTP :17005/mcp) ←──┘ │
│ REST API (HTTP :17005/api) ←──┘ │
└─────────────────────────────────────────────────────┘
↕ long polling
Telegram Bot API
↕ forum topics
Supergroup ChatADMIN_USER_ID, stores in bufferMap<topicId, Message[]>, indexed by message ID for deduplication/mcp, exposes 5 tools to Claude Code/api/*, for shell scripts and hooks| Tool | Parameters | Description |
|---|---|---|
send_message | topic_id, text, parse_mode? | Send text to a forum topic. parse_mode: HTML, Markdown, MarkdownV2 |
send_file | topic_id, file_path, caption? | Send a file from server filesystem to a topic |
poll_messages | topic_id, since_id? | Fetch new messages from buffer. Returns messages with IDs > since_id |
create_topic | title, icon_color? | Create a new forum topic. Returns {topic_id, name} |
get_topics | (none) | Lists known topics (discovered via incoming messages) |
| Endpoint | Method | Description |
|---|---|---|
/api/health | GET | Health check. Returns {status: "ok", timestamp} |
/api/poll?topic_id=N&since_id=M | GET | Poll messages for topic. Returns {messages: [...]} |
/api/send | POST | Send message. Body: {topic_id, text, parse_mode?} |
claude mcp add-json tg-cc-sync-bot '{"type":"http","url":"http://localhost:17005/mcp"}'In your project root, create .telegram-chat:
{"topic_id": 123}Add to .gitignore:
.telegram-chatEach project gets its own forum topic — all notifications are organized in one supergroup.
Add telegram-check.sh as a PostToolUse hook in ~/.claude/settings.json. The hook reads .telegram-chat from the current project and polls /api/poll after each tool call. If new messages are present, Claude Code sees them.
See $CLAUDE_SETUP_REPO/hooks/ for the hook implementation.
Send a status update to Telegram:
→ send_message(topic_id=123, text="Starting deployment...", parse_mode="HTML")
Check for human replies:
→ poll_messages(topic_id=123, since_id=0)
Create a topic for a new project:
→ create_topic(title="my-project")Set NOTELEGRAM=1 to disable all Telegram hooks without changing config:
NOTELEGRAM=1 claudeAll hook scripts check this variable and exit immediately. The MCP server itself is unaffected — only hooks are skipped.
| Variable | Required | Default | Description |
|---|---|---|---|
BOT_TOKEN | Yes | — | Telegram bot token from @BotFather |
CHAT_ID | Yes | — | Supergroup chat ID (negative number) |
ADMIN_USER_ID | Yes | — | Your Telegram user ID (messages from others are ignored) |
PORT | No | 8000 | Internal server port (docker maps to 17005) |
NOTELEGRAM | No | — | Set to 1 to disable hooks |
DEPLOY_CONFIRMED_BY_ADMIN | No | no | Deploy guard for docker-compose |
| Command | Description |
|---|---|
npm start | Run with Node.js 22 native TypeScript |
npm run dev | Watch mode (restarts on file changes) |
npm test | Run vitest test suite (offline, no real connections) |
npm run test:watch | Vitest in watch mode |
npm run typecheck | TypeScript check without emit |
npm run lint | ESLint |
npm run format | Prettier format |
npm run format:check | Prettier check |
All tests run offline. Bot and HTTP connections are mocked — no real Telegram API calls in tests.
MIT
alexmakeev/tg-cc-sync-bot-mcp
March 19, 2026
April 13, 2026
TypeScript