Skip to content
Conduit

mcp server

simply-telegram-bridge

Control Claude Code from Telegram with an allowlisted local bot.

Set up

Runs on your computer. Pick your agent and operating system.

This project does not publish an install method we can turn into a config. Follow the README instead.

README

synced Oct 23, 2026

Problem

You want to check on Claude Code from your phone without exposing a full remote shell or copying your private automation stack into a public repo.

This template gives you a small local Telegram control surface for Claude Code. It keeps the bot local, requires an explicit allowlist by default, and leaves deployment choices to you.

Install

One command. Takes 60 seconds.

curl -fsSL https://raw.githubusercontent.com/nardovibecoding/simply-telegram-bridge/main/install.sh | bash

Clones the repo, installs dependencies, prompts for bot token + settings, writes .env. Just run python3 bot.py after. The installer requires ALLOWED_USERS unless you explicitly opt into ALLOW_ALL_USERS=true.

Prerequisites:


Quickstart

export BOT_TOKEN="000000000:FAKE_TELEGRAM_BOT_TOKEN_FOR_LOCAL_TESTS"
export ALLOWED_USERS="123456789"   # your Telegram user ID
export WORKING_DIR="/path/to/project"
export MODEL="sonnet"              # haiku | sonnet | opus

python bot.py

Then open your bot in Telegram and start messaging:

You:  What's the git status?

Bot:  Working...
        $ git status
        Read README.md

Bot:  Clean — on branch main, 3 commits ahead of origin.
      Last commit: "fix: handle edge case in parser"
      (4.2s, 2 tool calls)

How It Works

Telegram message
      │
      ▼
  Bot (bot.py)
      │   auth check → allowed users only
      │
      ▼
Claude Code SDK (sdk_client.py)
      │   persistent connection, auto-reconnect
      │
      ├──▶ Bash      $ git status, pytest, npm run build …
      ├──▶ Read      open any file in the working directory
      ├──▶ Write     create new files
      ├──▶ Edit      patch existing files
      ├──▶ Grep      search file contents
      ├──▶ Glob      find files by pattern
      ├──▶ WebSearch research from the web
      ├──▶ WebFetch  fetch a URL
      └──▶ Agent     spawn sub-agents for complex tasks
             │
             ▼
      streaming response
      (tool calls shown live as they happen)
             │
             ▼
      Telegram reply with timing stats

Cold start: ~6 s once. Subsequent messages: 2–3 s.


Features

CapabilityDetail
Full tool accessBash, Read, Write, Edit, Grep, Glob, WebSearch, WebFetch, Agent
Live tool progressEach tool call shown in real-time as Claude works
Streaming textResponse text updates as it arrives, not just at the end
Long message splittingResponses >4096 chars split automatically
Task cancellation/cancel stops a running task mid-execution
Auto-reconnectPersistent SDK connection restarts transparently on crash
Multi-modelSwitch between Haiku, Sonnet, and Opus via env var
Allowlist authRestrict access to specific Telegram user IDs
Custom working dirPoint Claude at any directory on the host machine
Custom system promptOverride the default assistant persona
Markdown renderingBot responses rendered as HTML — bold, code, links preserved
Rate limitingConfigurable per-user message rate limit (default: 5 req/min)
File/image inputSend photos or documents — bot passes them to Claude as input
Multi-sessionPer-chat working directories via JSON mapping
3-file footprintbot.py + sdk_client.py + requirements.txt — ~300 lines total

Setup Guide

1. Create a Telegram Bot

  1. Open @BotFather in Telegram
  2. Send /newbot and follow the prompts
  3. Copy the token. Public examples in this repo use fake token placeholders.

2. Find Your Telegram User ID

Message @userinfobot — it replies with your numeric user ID.

3. Configure Environment

export BOT_TOKEN="000000000:FAKE_TELEGRAM_BOT_TOKEN_FOR_LOCAL_TESTS"
export ALLOWED_USERS="111222333"          # your user ID (comma-separated for multiple)
export WORKING_DIR="$HOME/myproject"      # directory Claude operates in
export MODEL="sonnet"                     # haiku | sonnet | opus
export SYSTEM_PROMPT="You are a helpful coding assistant."  # optional

4. Run

python bot.py

To keep it running in the background:

nohup python bot.py > bridge.log 2>&1 &

Or as a systemd service (Linux):

[Unit]
Description=Claude Telegram Bridge

[Service]
ExecStart=/usr/bin/python3 /opt/simply-telegram-bridge/bot.py
EnvironmentFile=/opt/simply-telegram-bridge/.env
Restart=always

[Install]
WantedBy=multi-user.target

Configuration Reference

VariableRequiredDefaultDescription
BOT_TOKENYes—Telegram bot token from BotFather
ALLOWED_USERSYes by defaultemptyComma-separated Telegram user IDs
ALLOW_ALL_USERSNofalseSet true only for a private test bot
WORKING_DIRNo~Directory Claude operates in
MODELNosonnethaiku, sonnet, or opus
SYSTEM_PROMPTNo"You are a helpful coding assistant."System prompt for the session
RATE_LIMITNo5Max messages per user per minute
CHAT_DIRSNo—JSON mapping of chat ID → working dir, e.g. {"123456": "/projects/foo"}

Commands

CommandWhat it does
(any text)Sent to Claude Code — full tool access
/cancelCancel the currently running task

Security

ALLOWED_USERS is your first line of defense. Set it to your Telegram user ID. If it is empty, this template denies all users unless ALLOW_ALL_USERS=true.

# Single user
export ALLOWED_USERS="111222333"

# Multiple users
export ALLOWED_USERS="111222333,444555666"

What Claude can do: The bot can execute Claude Code tools from the configured working directory. Only grant access to users you trust completely.

Credentials: BOT_TOKEN and ALLOWED_USERS are env vars — never committed to git. Use a .env file locally and EnvironmentFile in systemd.


Architecture

3 files, ~300 lines:

FileLinesResponsibility
bot.py~160Telegram bot — auth, message handling, progress display, cancellation
sdk_client.py~130Claude SDK wrapper — persistent connection, streaming, auto-reconnect
requirements.txt2python-telegram-bot + claude-agent-sdk

The SDK client maintains a single persistent connection per process. On disconnect or crash, it reconnects transparently before the next query. The lock ensures concurrent Telegram messages are serialized to the same session.


Battle-Tested

This public template is intentionally smaller than a private production bot stack. It omits private deployment wiring, logs, runtime state, and operational workflows.


Star History

Star History Chart


License

AGPL-3.0 — see NOTICE for attribution.

↑↓ navigate openesc close