io.github.n24q02m/better-telegram-mcp
Telegram MCP server — dual-mode Bot API + MTProto, 6 composite tools.
★ 2MITdevtools
Install
Config snippet generator goes here (5 client tabs)
README
# Better Telegram MCP
mcp-name: io.github.n24q02m/better-telegram-mcp
**MCP server for Telegram with dual-mode support: Bot API (httpx) for quick bot integrations and MTProto (Telethon) for full user-account access.**
<!-- Badge Row 1: Status -->
[](https://github.com/n24q02m/better-telegram-mcp/actions/workflows/ci.yml)
[](https://codecov.io/gh/n24q02m/better-telegram-mcp)
[](https://pypi.org/project/better-telegram-mcp/)
[](https://hub.docker.com/r/n24q02m/better-telegram-mcp)
[](https://opensource.org/licenses/MIT)
<!-- Badge Row 2: Tech -->
[](#)
[](https://core.telegram.org)
[](#)
[](https://github.com/python-semantic-release/python-semantic-release)
[](https://github.com/renovatebot/renovate)
<a href="https://glama.ai/mcp/servers/n24q02m/better-telegram-mcp">
<img width="380" height="200" src="https://glama.ai/mcp/servers/n24q02m/better-telegram-mcp/badge" alt="better-telegram-mcp MCP server" />
</a>
## Features
- **Dual mode** -- Bot API (httpx) for bots, MTProto (Telethon) for user accounts
- **6 mega-tools** with action dispatch: `messages`, `chats`, `media`, `contacts`, `config`, `help`
- **Auto-detect mode** -- Set bot token for bot mode, or API credentials for user mode
- **Web-based OTP auth** -- Browser-based authentication with remote relay support for headless environments
- **Tool annotations** -- Each tool declares `readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`
- **MCP Resources** -- Documentation available as `telegram://docs/*` resources
- **Security hardened** -- SSRF protection, path traversal prevention, error sanitization
## Quick Start
### Claude Code Plugin (Recommended)
Via marketplace (includes skills: /setup-bot, /channel-post):
```bash
/plugin marketplace add n24q02m/claude-plugins
/plugin install better-telegram-mcp@claude-plugins
```
Or install this plugin only:
```bash
/plugin marketplace add n24q02m/better-telegram-mcp
/plugin install better-telegram-mcp
```
Set credentials in `~/.claude/settings.local.json` or shell profile. See [Environment Variables](#environment-variables).
### MCP Server
> **Python 3.13 required** -- Python 3.14+ is **not** supported.
#### Bot Mode Setup
1. Open Telegram, search for [@BotFather](https://t.me/BotFather)
2. Send `/newbot`, follow prompts to name your bot
3. Copy the token (format: `123456789:ABCdefGHI-JKLmnoPQRstUVwxyz`)
#### User Mode Setup
1. Go to [my.telegram.org](https://my.telegram.org), login with your phone number
2. Click "API development tools", create an app
3. Note your `api_id` (integer) and `api_hash` (32-char hex string)
4. On first run, a **local web page** opens for OTP authentication
#### Option 1: uvx
```jsonc
{
"mcpServers": {
"telegram": {
"command": "uvx",
"args": ["--python", "3.13", "better-telegram-mcp"]
}
}
}
```
<details>
<summary>Other MCP clients (Cursor, Codex, Gemini CLI)</summary>
```jsonc
// Cursor (~/.cursor/mcp.json), Windsurf, Cline, Amp, OpenCode
{
"mcpServers": {
"telegram": {
"command": "uvx",
"args": ["--python", "3.13", "better-telegram-mcp"]
}
}
}
```
```toml
# Codex (~/.codex/config.toml)
[mcp_servers.telegram]
command = "uvx"
args = ["--python", "3.13", "better-telegram-mcp"]
```
</details>
#### Option 2: Docker
```jsonc
{
"mcpServers": {
"telegram": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "TELEGRAM_BOT_TOKEN",
"-v", "telegram-data:/data",
"n24q02m/better-telegram-mcp"
]
}
}
}
```
Configure credentials in `~/.claude/settings.local.json` or your shell profile. See [Environment Variables](#environment-variables) below.
> For user mode in Docker, mount the session directory with `-v ~/.better-telegram-mcp:/data` so the session persists across container restarts.
## Tools
| Tool | Actions | Description |
|:-----|:--------|:------------|
| `messages` | `send`, `edit`, `delete`, `forward`, `pin`, `react`, `search`, `history` | Send, edit, delete, forward messages. P