Telegram MCP Server logo

Telegram MCP Server

by kfastov

This project provides a Telegram client library and an MCP server, enabling AI assistants to interact with Telegram via the user client API. It allows reading message history from channels and chats, with potential for sending messages on behalf of users in future updates.

View on GitHub

Last updated: N/A

What is Telegram MCP Server?

The Telegram MCP Server is a project that includes a Telegram client library and an MCP (Model Context Protocol) server. It allows AI agents, such as Claude, to interact with Telegram through the user client API, enabling them to read message history and potentially send messages.

How to use Telegram MCP Server?

  1. Configure Telegram API credentials in a .env file. 2. Install dependencies using npm install. 3. Start the MCP server using npm start. 4. Connect an MCP-compatible client to the server's SSE endpoint (http://localhost:8080/sse). 5. Use the available tools (listChannels, searchChannels, getChannelMessages) through the connected client.

Key features of Telegram MCP Server

  • Telegram client library for authentication and API interaction

  • MCP server exposing Telegram interactions as tools for AI assistants

  • Retrieving chats/dialogs with caching

  • Fetching messages from specific chats with optional regex filtering

Use cases of Telegram MCP Server

  • Enabling AI assistants to access and analyze Telegram channel content

  • Building AI-powered Telegram bots with advanced message filtering capabilities

  • Integrating Telegram data into other applications through the MCP interface

  • Automating Telegram interactions for research or monitoring purposes

FAQ from Telegram MCP Server

How do I resolve authentication issues?

Delete the session file in the data/ directory and restart the server to re-authenticate.

What should I do if the server crashes?

Check your environment variables and ensure your Telegram API credentials are correct.

Why am I getting 'Access Denied' errors for certain channels?

Ensure your Telegram account has access to the channels you're trying to query.

How can I filter messages for specific content?

Use the filterPattern parameter with getChannelMessages and provide a regular expression to match the desired content.

What is the purpose of the dialog cache?

The dialog cache stores information about Telegram chats and channels to improve performance and reduce API calls.