Skip to main content

claude-code-telegrammer

SciTeX

Custom Telegram MCP server + TUI auto-responder for running Claude Code as an autonomous Telegram agent

PyPI version Documentation Tests License: AGPL-3.0

Documentation · pip install claude-code-telegrammer


What it is: a self-contained Telegram bridge for Claude Code — a Bun MCP server that turns any Claude Code session into an autonomous agent you talk to over Telegram, plus a TUI watchdog that keeps it running unattended. Each agent runs its own bot, its own message store, and fails loud on misconfiguration.

Problem and Solution

# Problem Solution
1

Hardcoded paths

The official plugin hardcodes ~/.claude/ as its state directory (#851), making it impossible to run multiple bots or customize where access.json lives.

Configurable state directory

All state (DB, lock, access config) lives under CLAUDE_CODE_TELEGRAMMER_AGENT_STATE_DIR. Run as many bots as you want, each with its own isolated state.
2

409 Conflict crashes

No single-instance guard — multiple sessions polling the same bot get 409 errors and crash each other (#1075).

PID-based lock

Automatic single-instance enforcement via PID lock file. Second instance detects the conflict and waits instead of crashing.
3

Zombie CPU consumption

After session ends, the plugin process lingers at 100% CPU — requires manual kill (#1146).

Clean shutdown

Exits gracefully on stdin close, SIGTERM, or SIGINT. No zombies, no manual cleanup.
4

Only 3 basic tools

The official plugin provides just send, get_updates, and set_reaction — no history, no search, no file handling, no message editing.

10 MCP tools

reply, react, edit_message, get_history, get_unread, mark_read, download_attachment, send_document, search_messages, get_context — everything an autonomous agent needs.
5

No message persistence

Messages vanish after delivery. No way to search past conversations, track read status, or build context from history.

PostgreSQL message store

All messages persisted to the fleet's PostgreSQL server, one schema per agent, with text search, reply threading (reply_to_message_id), read/replied tracking, and attachment metadata.
6

No access control for groups

Basic allowlist only — no per-group policies, no hot-reload when config changes.

DM + group policies

Allowlist-based access control with separate DM and group chat policies via access.json, hot-reloaded on file change (mtime-based).
7

No attachment support

Cannot download inbound files or upload documents to chats.

Full attachment handling

Inbound photos, documents, voice, audio, and video are auto-downloaded. Upload local files via send_document tool.
8

Sessions stall unattended

Claude Code halts at permission prompts or idle states with no way to recover — the agent just stops working.

TUI Watchdog

Polls GNU Screen buffer, detects TUI state via pattern matching, sends keystrokes to auto-accept prompts and re-engage on idle. Throttled with burst limits.

Table 1. Eight issues with the official Telegram plugin (as of April 2026) and how claude-code-telegrammer addresses each.

Quickstart

Prerequisites: Bun ≥ 1.0 (MCP server); GNU Screen (watchdog, optional).

git clone https://github.com/ywatanabe1989/claude-code-telegrammer.git
cd claude-code-telegrammer/ts && bun install

1. Get a bot token — message @BotFather, send /newbot, and copy the token (123456789:AAH...). Open your bot and send it any message. Verify: curl -s "https://api.telegram.org/bot<TOKEN>/getMe".

2. Register the MCP server with Claude Code — copy .mcp.json.example to .mcp.json (gitignored) and set CLAUDE_CODE_TELEGRAMMER_BOT_TOKEN + CLAUDE_CODE_TELEGRAMMER_ALLOWED_USERS (your Telegram user id, from @userinfobot). Full env reference: docs/configuration.md.

3. Run:

claude --dangerously-skip-permissions \
       --dangerously-load-development-channels server:claude-code-telegrammer

You should see Listening for channel messages from: server:claude-code-telegrammer. Message your bot from Telegram — Claude Code receives it as a channel notification.

Architecture

flowchart LR
    op["Operator<br/>(Telegram app)"]
    bot["Telegram Bot API<br/>per-agent bot token"]
    op <-->|messages| bot

    subgraph agent["One agent — isolated home"]
        direction TB
        srv["telegram-server.ts<br/>(Bun MCP server)"]
        gate{"allowlist gate<br/>CCT_ALLOWED_USERS<br/>+ access.json"}
        db[("state dir · per-agent<br/>messages.db · lock<br/>CCT_AGENT_STATE_DIR")]
        cc["Claude Code<br/>(the agent)"]
        srv -->|inbound| gate
        gate -->|"allowed → channel notification"| cc
        cc -->|"reply · react · send_document (MCP stdio)"| srv
        srv <--> db
    end

    bot -->|"getUpdates (long-poll)"| srv
    srv -->|sendMessage| bot

The MCP server long-polls Telegram, gates inbound messages through the allowlist, and delivers them to Claude Code as channel notifications; the agent replies through MCP tools. Each agent is self-contained — its own bot token, its own per-agent state dir, its own poller — and fails loud at startup on any misconfiguration (missing/invalid token, unexpanded ${…}, or a renamed env var). Deep dive: docs/architecture.md.

Interfaces

  • MCP server — 11 tools over stdio (reply, react, edit_message, get_history, get_unread, mark_read, download_attachment, send_document, search_messages, get_context, health) with a built-in responsiveness policy. See docs/interfaces.md.
  • config probe — bun run ts/telegram-server.ts config [--check] prints the resolved config as JSON for orchestrator preflight.
  • health (doctor) — bun run ts/telegram-server.ts health (also exposed as the health MCP tool) runs 10 checks — env hygiene, token presence/validity, webhook absence, poller liveness, allowlist, state dir, DB schema/offset — and prints {package, ok, checks[], summary}; every failing check carries an actionable hint. See docs/interfaces.md.
  • Skill — bundled at src/claude_code_telegrammer/_skills/claude-code-telegrammer/SKILL.md.

Part of SciTeX

claude-code-telegrammer is part of SciTeX — the Telegram communication layer and TUI watchdog used by scitex-agent-container (lifecycle, health, restart) and scitex-orochi (agent definitions, dashboard) for autonomous agent operation. See the agent stack.

References

Four Freedoms for Research

  1. The freedom to run your research anywhere -- your machine, your terms.
  2. The freedom to study how every step works -- from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. The freedom to modify any module and share improvements with the community.

AGPL-3.0 -- because we believe research infrastructure deserves the same freedoms as the software it runs on.


SciTeX

Metadata

Release files for claude-code-telegrammer 0.6.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-code-telegrammer 0.6.5
File Size Uploaded
claude_code_telegrammer-0.6.5.tar.gz 206.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-code-telegrammer 0.6.5
File Interpreter ABI Platform
claude_code_telegrammer-0.6.5-py3-none-any.whl Python 3 none any Details

Total release size: 453.3 kB

Release files / claude_code_telegrammer-0.6.5.tar.gz

Download URL claude_code_telegrammer-0.6.5.tar.gz
Size 206.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c3a2dc806b25e6723eb81fefa5ae8b7746363302d0acda0299b4ea182d3e384b
BLAKE2b-256 checksum
How to use checksums
9a3b3b3e5d58f5ee381fa7b3216738030fa99d6da4f7fbe15328344d0c2c3962
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / claude_code_telegrammer-0.6.5-py3-none-any.whl

Download URL claude_code_telegrammer-0.6.5-py3-none-any.whl
Size 247.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b78561b7dc38a23adf8726bf66d2cd365b265669ac2bff5c6aecd01f9dbc2b24
BLAKE2b-256 checksum
How to use checksums
4d7e985f46ccfaaab6d83ff9cce54dd522e3932177b3db219c988cccf2ef4f96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.1

2 release files

0.7.0

2 release files

0.6.6

2 release files

This release

0.6.5 This release

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.12

2 release files

0.5.11

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page