telegram-mcp

telegram-mcp avatar

by chigwell

Community Servers

What is telegram-mcp

License: Apache 2.0 LinkedIn

Telegram MCP Server

A Telegram MCP (Model Context Protocol) server built using Python, Telethon, and MCP Python SDK. This MCP server provides simple tools for interacting with Telegram chats directly through MCP-compatible hosts, such as Claude for Desktop.

Tools Provided

  • get_chats: Retrieve a paginated list of your Telegram chats.
  • get_messages: Retrieve paginated messages from a specific chat.
  • send_message: Send a message to a specific chat.

Requirements

Installation and Setup

Clone the Repository

git clone https://github.com/chigwell/telegram-mcp
cd telegram-mcp

Create Environment File

Copy and rename .env.example to .env and fill it with your Telegram credentials obtained from https://my.telegram.org/apps:

cp .env.example .env

Your .env file should look like:

TELEGRAM_API_ID=your_api_id_here
TELEGRAM_API_HASH=your_api_hash_here
TELEGRAM_SESSION_NAME=your_session_name

Setup Python Environment

Use uv to set up the Python environment and install dependencies:

uv venv
source .venv/bin/activate
uv add "mcp[cli]" telethon python-dotenv nest_asyncio

Run the Server (First-time Auth)

The first time you run the server, Telethon will prompt you to enter a Telegram authentication code:

uv run main.py

Authenticate by entering the code sent to your Telegram client. This step is only required once.

Integrating with Claude for Desktop

macOS/Linux

Edit your Claude Desktop configuration:

nano ~/Library/Application\ Support/Claude/claude_desktop_config.json

Add this MCP server configuration:

{
    "mcpServers": {
        "telegram-mcp": {
            "command": "uv",
            "args": [
                "--directory",
                "/ABSOLUTE_PATH/telegram-mcp",
                "run",
                "main.py"
            ]
        }
    }
}

Ensure you replace /ABSOLUTE_PATH/telegram-mcp with your project's absolute path.

Windows

Edit your Claude Desktop configuration:

nano $env:AppData\Claude\claude_desktop_config.json

Add this MCP server configuration:

{
    "mcpServers": {
        "telegram-mcp": {
            "command": "uv",
            "args": [
                "--directory",
                "C:\\ABSOLUTE_PATH\\telegram-mcp",
                "run",
                "main.py"
            ]
        }
    }
}

Ensure you replace C:\ABSOLUTE_PATH\telegram-mcp with your project's absolute path.

Usage

Once integrated, your Telegram tools (get_chats, get_messages, and send_message) will become available within the Claude for Desktop UI or any other MCP-compatible client.

License

This project is licensed under the Apache 2.0 License.

Leave a Comment

Comments section will be available soon. Stay tuned!

Frequently Asked Questions

What is MCP?

MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.

What are MCP Servers?

MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.

How do MCP Servers work?

MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.

Are MCP Servers secure?

Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.