Get the FREE Ultimate OpenClaw Setup Guide →

tgcli

Telegram user console client and archiver

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio kfastov-tgcli npx -y @kfastov/tgcli \
  --env TGCLI_STORE="path/to/store (optional)" \
  --env TELEGRAM_API_ID="your_api_id" \
  --env TELEGRAM_API_HASH="your_api_hash"

How to use

tgcli is a Telegram command-line interface that can operate as a personal MTProto client with optional background MCP server support. The tool provides authentication against Telegram, local synchronization of messages, and a suite of commands to browse, search, send, and manage Telegram data. When enabling the MCP server, tgcli exposes an HTTP API (default: http://127.0.0.1:8080/mcp) that client applications can use to trigger sync tasks, read message metadata, or interact with the stored session data. Start by authenticating with Telegram, then configure MCP if you want remote access to the session data. The available commands include authentication, syncing, listing and sending messages, managing channels, media, and many utilities for diagnostics and configuration. To use MCP, enable it in your tgcli config and then start the server with tgcli server; your client can then point to the configured host/port for MCP access.

How to install

Prerequisites:

  • Node.js (LTS) and npm installed on your machine
  • Optional: Homebrew on macOS for convenient tgcli installation

Installation steps:

  1. Install the CLI globally via npm: npm install -g @kfastov/tgcli

  2. (macOS) Optional Homebrew installation of the CLI tap: brew install kfastov/tap/tgcli

  3. Authenticate with Telegram (will prompt for API credentials): tgcli auth

  4. Start using tgcli commands (examples): tgcli sync --follow tgcli messages list --chat @username --limit 20 tgcli send text --to @username --message "hello"

  5. Enable and run MCP server (optional): tgcli config set mcp.enabled true tgcli server

  6. Point your MCP client to the configured address (default http://127.0.0.1:8080/mcp) and begin interacting with the session data.

Additional notes

Tips and notes:

  • The MCP server is optional and is accessed after tgcli config mcp.enabled is set to true. The default bind is http://127.0.0.1:8080/mcp; adjust host/port in config as needed.
  • TGCLI_STORE environment variable can override the OS-specific app-data store location for config, sessions, and messages.
  • Ensure your Telegram API credentials (api_id and api_hash) are kept secret and never shared.
  • If you encounter port conflicts, choose a different host/port in the tgcli config before starting the MCP server.
  • Logs from the MCP server can help with debugging; check tgcli logs and system logs if running as a background service.

Related MCP Servers

Sponsor this space

Reach thousands of developers