SuperAPIAI Directory

termgram

github.com · AI developer platforms

Terminal Telegram client over MTProto: CLI for messages, media and contacts, plus an MCP server that sends notifications when new messages arrive.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

termgram is a complete Telegram client for use in the terminal. It communicates directly with Telegram over the MTProto protocol and does not rely on the Bot API or external services. The project consists of a Rust workspace containing four crates and produces three binaries: a CLI, an MCP server, and a notification stream.

Main capabilities

Unified sending pipeline: send text, rich media, clickable date labels, and scheduled messages through a single send command. Supports plain, markdown, and html formats parsed into real Telegram entities, as well as photos, documents, voice messages, albums, replies, scheduling, forum topics, and more. --date can be repeated to add multiple clickable date labels.

Local search mirror: after running sync once, offline instant search across all chats is possible. Unmirrored chats are automatically synced on demand, and if the mirror still has no results, it falls back to live API search. Chat name matching is case-insensitive.

Complete chat toolkit: supports polls, reactions, drafts, pinning, folders, contacts, member management, kick/ban/unban/promote, export/import/wipe, and more. Complete commands include me, men, dialogs, messages, read, watch, send, edit, delete, forward, pin, react, reactions, drafts, draft, profile, set, block, unblock, typing, status, scheduled, cancel, contacts, folders, folder-new, folder-rm, pinned, members, kick, ban, unban, promote, grab, export, import, wipe, poll, topics, search, searchin, searchall, sync, cached.

Push instead of polling: new messages arrive via broadcast signals; wait blocks on the server side waiting for real Telegram pushes and returns immediately. The MCP server pushes each new incoming message as a server-to-client custom notification. Push is off by default, and the notify tool can control which chats are pushed.

SSE notification stream: termgram-notify is a standalone lightweight HTTP server that streams the same new message events in text/event-stream format. Each event is a data: line with the same JSON structure as MCP notifications, followed by a blank line; a : ping heartbeat comment is sent every 15 seconds to keep the connection alive. The port can be overridden via TERMGRAM_NOTIFY_PORT, filtered via query string, and connected to from a browser, curl, or any SSE client.

Unified authentication: a single session drives the CLI, MCP server, and notifier at the same time, with multi-account support. Credentials and sessions are stored only in ~/.config/termgram/ and do not enter the repository.

Usage

First register an application at my.telegram.org to obtain an API ID and hash. termgram keeps everything under ~/.config/termgram/, and on first run it writes a config.toml template for you to fill in. The session is stored in ~/.config/termgram/session.db, and the CLI, MCP server, and notifier share one login.

Installation: build the workspace and copy the three binaries to PATH; or install from crates.io via cargo install termgram-cli termgram-mcp termgram-notify; or install from source: cargo install --path crates/cli, cargo install --path crates/mcp, cargo install --path crates/notify. Each GitHub release also includes precompiled binaries.

termgram-mcp uses the Model Context Protocol over stdio. It can be registered with MCP clients such as opencode, or any standard MCP client. termgram-mcp --catalog starts a sessionless mode that only answers MCP discovery calls (without connecting to Telegram), allowing directory services to introspect the server without credentials. Every CLI command is exposed as a tool; send accepts the same unified model (text, files, format, dates, reply, topic, at), plus poll, topics, watch, upload, album, voice, schedule, scheduled, cancel, edit, draft, drafts, react, reactions, search/searchin/searchall, sync, proxy access, management tools, and export/import/wipe.

Use cases

Suitable for users who are accustomed to a terminal environment and want to overlay AI onto chat. AI tools can access Telegram chats through an MCP server, or custom scripts can respond to new messages in real time through an SSE stream.

Limitations

The MCP or SSE connection streams the account's incoming events. Messages tied to interactions occurring on another active session (for example, a termgram process running in another terminal replying to a bot) may remain in that session's stream and fail to reach your stream. In common cases, sending and pushing occur in the same process, so nothing is missed. The MTProto layer guarantees continuous streaming, not per-session synchronization.

Reacting with new emoji requires Telegram Premium; reading reactions is available to everyone. Two termgram processes on the same account share one session.db; long-running monitors should run independently, and concurrent write commands may trigger database is locked. The notifier binds only to 127.0.0.1. The push payload does not store or forward keys.

The project is actively looking for maintainers; the current maintainer uses it daily but is no longer adding features.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools