# Better Telegram MCP

Hooks your agent up to Telegram: messages, chats, media and contacts. Works either as a bot or as a regular account.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 11
- Author: n24q02m
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/n24q02m/telegram
- Updated: 2026-10-12
- HTML: https://affpapa.org/en/nevibecode/mcp/better-telegram-mcp

## What it does

Two modes share one server. A bot token routes calls through the Bot API over httpx. Swap in account API credentials and it switches to MTProto via Telethon, which opens up a normal user account instead of a bot identity.

Seven tools dispatch by action: `message`, `chat`, `media`, `contact`, `config`, `help` and `config__open_relay`. Some carry read-only annotations, others are flagged destructive, so the agent has something to reason about before it acts. Docs also arrive as MCP resources under `telegram://docs/*`.

Signing in as a user goes through the browser. The HTTP relay form takes the phone number, the OTP and the 2FA password; on a single machine the `auth` CLI does the same job, and `login` sticks around as a deprecated alias. Skip both a bot token and the API ID/hash pair and the server has no identity to act under. Run locally, the executable starts on stdio by default; HTTP needs `--http`, `MCP_TRANSPORT=http` or `TRANSPORT_MODE=http`.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `TELEGRAM_BOT_TOKEN`, `TELEGRAM_API_ID`, `TELEGRAM_API_HASH` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env TELEGRAM_BOT_TOKEN=<TELEGRAM_BOT_TOKEN> --env TELEGRAM_API_ID=<TELEGRAM_API_ID> --env TELEGRAM_API_HASH=<TELEGRAM_API_HASH> --transport stdio better-telegram-mcp -- uvx better-telegram-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from better-telegram-mcp <command>

### Codex

**Platform CLI**
```bash
codex mcp add better-telegram-mcp --env TELEGRAM_BOT_TOKEN=<TELEGRAM_BOT_TOKEN> --env TELEGRAM_API_ID=<TELEGRAM_API_ID> --env TELEGRAM_API_HASH=<TELEGRAM_API_HASH> -- uvx better-telegram-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from better-telegram-mcp <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "better-telegram-mcp": {
            "command": "uvx",
            "args": [
                "better-telegram-mcp"
            ],
            "env": {
                "TELEGRAM_BOT_TOKEN": "<TELEGRAM_BOT_TOKEN>",
                "TELEGRAM_API_ID": "<TELEGRAM_API_ID>",
                "TELEGRAM_API_HASH": "<TELEGRAM_API_HASH>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from better-telegram-mcp <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "better-telegram-mcp": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "better-telegram-mcp"
            ],
            "env": {
                "TELEGRAM_BOT_TOKEN": "<TELEGRAM_BOT_TOKEN>",
                "TELEGRAM_API_ID": "<TELEGRAM_API_ID>",
                "TELEGRAM_API_HASH": "<TELEGRAM_API_HASH>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from better-telegram-mcp <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e TELEGRAM_BOT_TOKEN=<TELEGRAM_BOT_TOKEN> -e TELEGRAM_API_ID=<TELEGRAM_API_ID> -e TELEGRAM_API_HASH=<TELEGRAM_API_HASH> better-telegram-mcp uvx better-telegram-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from better-telegram-mcp <command>

## When to use it
- Send a chat message without leaving the agent session
- Pull media out of a thread and hand it to the project
- Look up a contact and open the conversation
- Turn incoming messages into tasks
- Drive a bot and a personal account from one interface

## Example prompts
- Post to the `dev-team` chat that the build failed
- Find Ivan in contacts and show our latest messages
- Grab the newest photo from the `release` chat

## Similar
- [Notify MCP Server](https://affpapa.org/en/nevibecode/mcp/notify-mcp-server.md) — MCP server · ★ 28
- [TONNode — TON blockchain access](https://affpapa.org/en/nevibecode/mcp/tonnode-ton-blockchain-access.md) — MCP server · ★ 27
- [telegram-mcp](https://affpapa.org/en/nevibecode/mcp/telegram-mcp.md) — MCP server · ★ 7

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
