New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@tekmidian/telex

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tekmidian/telex

Telegram MCP bridge for Claude Code — bidirectional self-chat via MTProto

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Telex

Your phone is now a Claude Code terminal — via Telegram. Send a message to your Saved Messages, Claude gets it. Claude responds, you see it on Telegram. Text, images, voice notes — in both directions.

Dictate a voice note while driving and Claude starts coding. Send an image from your phone and Claude interprets it. Get spoken responses back in any of 28 voices — all synthesized locally, nothing leaves your machine. Take complete control of your computer using /t to open and manage any number of terminal sessions. Manage multiple Claude sessions from your couch with /s, switch between them, or /kill a stuck one and restart it fresh. Take screenshots of any session using /ss and have the screenshot sent to you via Telegram.

One command to set up. Zero cloud dependencies for voice. Works with any Telegram account.

How it works

Telex has two components:

Watcher daemon — a long-running process that owns the Telegram connection (via the GramJS MTProto library). It delivers incoming messages to iTerm2 by typing them into your Claude session via AppleScript. It also serves a Unix Domain Socket so MCP server instances can send and receive messages without holding their own connection.

MCP server — a thin IPC proxy started by Claude Code. It has no direct Telegram connection. Every tool call is forwarded to the watcher over the socket and the response returned to Claude.

Your phone
    |
    | Telegram (GramJS MTProto)
    |
  Watcher daemon  <── launchd, auto-restarts
    |
    |── AppleScript ──> iTerm2 ──> Claude Code (types message into terminal)
    |
    |── Unix Domain Socket (/tmp/telex-watcher.sock)
              |
              └──> MCP Server (started by Claude Code)
                       |
                       └──> telegram_send / receive / status / wait / login
                            telegram_tts / telegram_speak / telegram_voice_config

The separation means you can have multiple Claude Code sessions open simultaneously. Each MCP server instance registers its TERM_SESSION_ID with the watcher. The first session to register becomes the active recipient for incoming messages; use /N from Telegram or telegram_switch to change the active session.

Architecture

Telex is built on aibroker — a shared core library that provides the platform-independent infrastructure:

aibroker (shared core — installed automatically via npm)
├── Logging, session state, message queuing
├── File persistence (parameterized data directory)
├── Unix Domain Socket IPC (server + client)
├── macOS iTerm2 adapter (AppleScript, tab management)
├── Kokoro TTS (local speech synthesis + Whisper transcription)
└── SessionBackend (deliver messages by typing into iTerm2)

Whazaa (WhatsApp bridge)          Telex (this package)
├── Baileys connection             ├── GramJS MTProto connection
├── WhatsApp formatting            ├── Telegram formatting
├── MCP tools (whatsapp_*)         ├── MCP tools (telegram_*)
└── Desktop DB integration         └── ...

If you install multiple bridges (Whazaa + Telex), each has its own node_modules/ — no conflicts. They share the same iTerm2 session infrastructure at runtime through macOS AppleScript.

Quick start

Tell Claude Code:

Clone https://github.com/mnott/Telex and set it up for me

Claude clones the repo, finds the setup skill, and handles everything autonomously — prerequisites, build, MCP config, watcher daemon, and Telegram authentication. The only thing you do is enter your phone number and verification code when prompted.

Manual install

git clone https://github.com/mnott/Telex.git
cd Telex
npm install
npm run build

Then tell Claude to set it up from the local clone.

Prerequisites

  • Node.js >= 18
  • macOS with iTerm2 for the watch command and iTerm2 delivery
  • ffmpeg for TTS voice note conversion (WAV to OGG Opus)
  • Whisper for voice note transcription (optional — only needed to receive audio/voice messages)
  • Telegram API credentials (TELEGRAM_API_ID and TELEGRAM_API_HASH) from my.telegram.org

Install ffmpeg and Whisper via Homebrew:

brew install ffmpeg
pip install openai-whisper

Getting Telegram API credentials

  • Go to my.telegram.org and log in with your phone number
  • Click "API development tools"
  • Create a new application (any name/description)
  • Copy the api_id (number) and api_hash (string)
  • Set them as environment variables:
export TELEGRAM_API_ID=12345678
export TELEGRAM_API_HASH=abcdef1234567890abcdef1234567890

Add these to your ~/.zshrc or ~/.bashrc for persistence.

How to Use

Once Telex is set up, you talk to Claude in plain language. You never need to know about tool names or parameters — just say what you want.

Sending Messages

Tell Claude what to say and to whom:

  • "Send Randolf a Telegram message saying I'll be late"
  • "Tell Nicole on Telegram the meeting is moved to 3pm"
  • "Message my Saved Messages: pick up milk"

If you don't say who to send it to, Claude sends to your Telegram Saved Messages — useful for notes to yourself.

Voice Notes

Claude can send a Telegram voice note instead of a text message:

  • "Send me a voice note saying good morning"
  • "Send a voice note to Nicole saying I'm on my way"

You can choose whose voice to use:

  • "Say it as George" or "Use George's voice"
  • "Use Nicole's voice for this"

Listening Locally (Mac Speakers)

Claude can speak out loud through your Mac — no Telegram needed:

  • "Say that out loud"
  • "Read that to me"

Voice Mode — Hands-Free

Put Claude into persistent voice mode so every response comes back as audio automatically.

  • "Voice mode on" — every Claude response becomes a Telegram voice note
  • "Back to text" — back to normal text messages
  • "Talk to me locally" — every response plays through your speakers

Screenshots

Send /ss from your phone and the watcher captures the active Claude session's iTerm2 window and sends it back to Telegram as an image.

Session Management (from Your Phone)

Control your Claude sessions from Telegram:

  • /s — see a list of your active Claude sessions
  • /2 — switch to session 2
  • /2 Cooking Project — switch to session 2 and name it
  • /n — create a new Claude session

MCP tools

Once configured, Claude Code has 20 tools available:

ToolDescription
telegram_statusCheck Telegram connection status
telegram_sendSend a text message (to Saved Messages or any contact)
telegram_ttsSend a voice note via TTS (Kokoro, local synthesis)
telegram_send_fileSend a file (with optional caption and prettify)
telegram_receiveDrain buffered incoming messages
telegram_waitLong-poll for incoming messages (up to timeout)
telegram_loginTrigger fresh Telegram authentication
telegram_contactsList Telegram contacts
telegram_chatsList Telegram chats
telegram_historyGet message history for a chat
telegram_voice_configGet or set voice/TTS configuration
telegram_speakPlay TTS locally through Mac speakers
telegram_renameRename the current Claude session
telegram_restartRestart the current Claude session
telegram_discoverDiscover and prune Claude sessions
telegram_sessionsList all Claude sessions
telegram_switchSwitch to a different Claude session
telegram_end_sessionEnd (close) a Claude session
telegram_commandExecute a slash command directly (bypass Telegram round-trip)
telegram_dictateRecord audio via Mac microphone and transcribe

Telegram commands

Messages sent from your phone starting with / are intercepted by the watcher:

CommandDescription
/h or /helpShow help
/s or /sessionsList open sessions (Claude and terminal)
/N or /N nameSwitch to session N (optionally rename)
/n or /newCreate a new Claude session
/cClear context and resume (/clear + go)
/ss or /screenshotCapture active session's iTerm2 window
/ccSend Ctrl+C (interrupt)
/escSend Escape
/enterSend Enter/Return
/tabSend Tab (trigger completion)
/up /down /left /rightArrow keys
/pPause session
/pick N [text]Select menu option N, optionally type text
/restartRestart the watcher

Keyboard control

Send raw keystrokes to the active iTerm2 session from your phone:

CommandKeystrokeUse case
/ccCtrl+CInterrupt a running process
/escEscapeDismiss a dialog, exit a mode
/enterReturnConfirm a prompt
/tabTabTrigger shell completion
/upUp arrowPrevious history / menu up
/downDown arrowNext history / menu down
/pick NDown x (N-1) + EnterSelect the Nth option in a menu

Configuration

VariableDefaultDescription
TELEGRAM_API_ID(required)Telegram API ID from my.telegram.org
TELEGRAM_API_HASH(required)Telegram API hash from my.telegram.org
TELEX_TTS_VOICEbm_fableDefault TTS voice

Watcher daemon

The watcher is the core of Telex. It runs as a macOS launchd agent so it starts automatically and restarts if it crashes.

Starting manually

node dist/index.js watch

launchd setup (auto-start)

scripts/watcher-ctl.sh start    # Install and start as launchd agent
scripts/watcher-ctl.sh stop     # Stop and unload
scripts/watcher-ctl.sh status   # Show running state

The agent uses KeepAlive: true and ProcessType: Interactive. The Interactive process type and LimitLoadToSessionType: Aqua are required so the watcher can access the macOS GUI session and call AppleScript to control iTerm2.

Manual MCP configuration

Add to ~/.claude.json:

{
  "mcpServers": {
    "telex": {
      "command": "npx",
      "args": ["-y", "telex"]
    }
  }
}

Using a local build:

{
  "mcpServers": {
    "telex": {
      "command": "node",
      "args": ["/path/to/Telex/dist/index.js"]
    }
  }
}

Troubleshooting

"Watcher not running" errors

The watcher daemon is not running. Start it with node dist/index.js watch or use scripts/watcher-ctl.sh start.

Telegram authentication failed

Ensure TELEGRAM_API_ID and TELEGRAM_API_HASH are set. Run node dist/index.js setup to re-authenticate.

Messages not appearing in Claude

Check that the watcher is running: ps aux | grep "telex.*watch". Verify the session ID matches your Claude tab.

"iTerm2 wants to control..." security prompt

Click OK. If you clicked "Don't Allow", go to System Settings > Privacy & Security > Automation and enable iTerm2.

TTS fails with "ffmpeg not found"

Install ffmpeg: brew install ffmpeg.

First TTS call takes a long time

The Kokoro model (~160 MB) is downloaded on first use and cached locally. Subsequent calls are fast.

Security

  • Session credentials are stored locally in ~/.telex/. Treat them like passwords.
  • Telex reads and sends messages via your Saved Messages (self-chat) by default.
  • No data is sent to any third-party service beyond Telegram's servers via MTProto.
  • TTS synthesis is fully local (Kokoro-js runs on-device). Audio never leaves your machine.

Requirements

  • Node.js >= 18
  • aibroker — shared core (installed automatically)
  • Telegram account with API credentials
  • macOS with iTerm2 for the watch command and iTerm2 delivery
  • ffmpeg for TTS voice note sending

License

MIT — see LICENSE

Author

Matthias Nott — github.com/mnott

Keywords

telegram

FAQs

Package last updated on 03 Mar 2026

Related posts