Telegram Channel Explorer MCP server

Enables access to Telegram channels and messages for searching content by keywords, listing available channels, retrieving specific messages, and filtering with regex patterns using the MTProto protocol.
Back to servers
Provider
kfastov
Release date
Mar 20, 2025
Language
TypeScript
Stats
15 stars

The Telegram MCP Server connects AI assistants like Claude to your Telegram account using the user client API instead of the bot API. This allows AI assistants to access and interact with your Telegram chats and messages through a standardized interface.

Prerequisites

  • Node.js: Version 18 or later recommended
  • Telegram Account:
    • An active Telegram account
    • Two-Step Verification (2FA) must be enabled (Settings → Privacy and Security → Two-Step Verification)
  • Telegram API Credentials:

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/telegram-mcp-server.git
    cd telegram-mcp-server
    
  2. Install dependencies:

    npm install
    

Configuration

MCP Server Configuration

Configure using environment variables in a .env file:

TELEGRAM_API_ID=YOUR_API_ID
TELEGRAM_API_HASH=YOUR_API_HASH
TELEGRAM_PHONE_NUMBER=YOUR_PHONE_NUMBER_WITH_COUNTRY_CODE # e.g., +15551234567

MCP Client Configuration

Configure client software (Claude Desktop, Cursor, etc.) to connect to the MCP server:

{
  "mcpServers": {
    "telegram": {
      "url": "http://localhost:8080/sse",
      "disabled": false,
      "timeout": 30
    }
  }
}

For Claude Desktop, the config file is located at:

  • On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • On Windows: %APPDATA%/Claude/claude_desktop_config.json

Important: Restart your MCP client after making changes.

Running the Server

Initial Login

For first-time setup or when your session expires:

npm start
  • You'll be prompted to enter the login code sent to your Telegram account and your 2FA password
  • Upon successful login, a session file (./data/session.json) will be created
  • The server will build or load a cache of your chats (./data/dialog_cache.json)

Normal Operation

Start the server manually:

npm start

Once running, your MCP client will connect to it via the configured URL.

Available Tools

listChannels

Lists available Telegram channels/chats accessible by the account.

Parameters:

  • limit (number, optional): Maximum number of channels to return (default: 50)

Output: List of channels/chats with their ID, title, type, and access hash (if applicable).

searchChannels

Searches the cached channels/chats by keywords in their names.

Parameters:

  • keywords (string): Keywords to search for in channel names
  • limit (number, optional): Maximum results to return (default: 100)

Output: List of matching channels/chats.

getChannelMessages

Retrieves recent messages from a specific channel/chat.

Parameters:

  • channelId (number): The numeric ID of the channel/chat
  • limit (number, optional): Maximum messages to return (default: 100)
  • filterPattern (string, optional): JavaScript-compatible regex to filter messages by content

Output: List of messages containing ID, date, text, and sender ID.

Troubleshooting

  • Login Prompts: If the server keeps asking for login codes/passwords, run npm start manually once to refresh the session
  • Cache Issues: Delete ./data/dialog_cache.json and restart the server to force a full refresh
  • Cannot Find Module: Ensure you ran npm install in the project directory
  • Other Issues: Check that file permissions allow read/write access to the data directory

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later