Skip to main content
Glama
Telegram MCP Server

Telegram MCP Server

by OrrBin

Telegram MCP Server

A Model Context Protocol (MCP) server that provides full access to your personal Telegram account. This allows you to interact with your Telegram messages, chats, and contacts through MCP clients like Claude Desktop.

Features

  • Full Account Access: Access all your personal messages, chats, and channels

  • Message Management: Read, send, and search messages across all conversations

  • Chat Operations: List, search, and get information about chats, groups, and channels

  • User Information: Get details about users and contacts

  • Real-time Operations: Mark messages as read and perform live actions

Related MCP server: tg-userbot

Prerequisites

  1. Telegram API Credentials: You need to obtain API credentials from Telegram

  2. Node.js: Version 18 or higher

  3. Your Phone Number: The phone number associated with your Telegram account

Setup Instructions

1. Get Telegram API Credentials

  1. Go to https://my.telegram.org/apps

  2. Log in with your phone number

  3. Create a new application:

    • App title: Choose any name (e.g., "My MCP Server")

    • Short name: Choose a short name (e.g., "mcp-server")

    • Platform: Choose "Desktop"

  4. Note down your api_id and api_hash

2. Install Dependencies

npm install

3. Configure Environment

  1. Copy the example environment file:

cp .env.example .env
  1. Edit .env and fill in your credentials:

TELEGRAM_API_ID=your_api_id_here
TELEGRAM_API_HASH=your_api_hash_here
TELEGRAM_PHONE=+1234567890
NODE_ENV=production
SESSION_DIR=./session

4. Build the Project

npm run build

5. Authentication

Before using the MCP server, you need to authenticate with Telegram. Run the standalone authentication script:

npm run auth

You'll be prompted to:

  1. Enter the verification code sent to your Telegram app

  2. If you have 2FA enabled, enter your password

The session will be saved in the session/ directory and reused automatically by the MCP server.

MCP Client Configuration

Q CLI

For Amazon Q CLI, create or edit your MCP configuration file:

macOS/Linux: ~/.config/mcp/mcp.json Windows: %APPDATA%\mcp\mcp.json

{
  "mcpServers": {
    "telegram": {
      "command": "node",
      "args": ["/Users/orrb/personal/workspace/telegram-mcp/dist/index.js"],
      "env": {
        "TELEGRAM_API_ID": "your_api_id",
        "TELEGRAM_API_HASH": "your_api_hash",
        "TELEGRAM_PHONE": "+1234567890"
      }
    }
  }
}

Claude Desktop

Add this to your Claude Desktop configuration file:

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

{
  "mcpServers": {
    "telegram": {
      "command": "node",
      "args": ["/path/to/telegram-mcp-server/dist/index.js"],
      "env": {
        "TELEGRAM_API_ID": "your_api_id",
        "TELEGRAM_API_HASH": "your_api_hash",
        "TELEGRAM_PHONE": "+1234567890"
      }
    }
  }
}

Cline (VS Code Extension)

For Cline, add the MCP server to your VS Code settings or Cline configuration:

{
  "cline.mcpServers": {
    "telegram": {
      "command": "node",
      "args": ["/path/to/telegram-mcp-server/dist/index.js"],
      "env": {
        "TELEGRAM_API_ID": "your_api_id",
        "TELEGRAM_API_HASH": "your_api_hash",
        "TELEGRAM_PHONE": "+1234567890"
      }
    }
  }
}

Other MCP Clients

For other MCP clients, use:

  • Command: node

  • Args: ["/path/to/telegram-mcp-server/dist/index.js"]

  • Environment Variables: Set the Telegram credentials as shown above

Available Tools

Chat Management

list_chats

List all chats, groups, and channels you have access to.

Parameters:

  • limit (optional): Number of chats to return (default: 50, max: 200)

get_chat_info

Get detailed information about a specific chat.

Parameters:

  • chatId: The chat ID to get information for

search_chats

Search for chats by title or username.

Parameters:

  • query: Search query to find chats by title

  • limit (optional): Number of results to return (default: 20, max: 100)

Message Operations

get_messages

Get recent messages from a specific chat.

Parameters:

  • chatId: The chat ID to get messages from

  • limit (optional): Number of messages to return (default: 20, max: 100)

  • fromMessageId (optional): Get messages starting from this message ID

send_message

Send a text message to a chat.

Parameters:

  • chatId: The chat ID to send the message to

  • text: The message text to send

  • replyToMessageId (optional): Message ID to reply to

search_messages

Search for messages across all chats or within a specific chat.

Parameters:

  • query: Search query to find messages

  • chatId (optional): Limit search to specific chat

  • limit (optional): Number of results to return (default: 20, max: 100)

mark_as_read

Mark specific messages as read in a chat.

Parameters:

  • chatId: The chat ID to mark messages as read

  • messageIds: Array of message IDs to mark as read

User Information

get_user_info

Get information about a specific user.

Parameters:

  • userId: The user ID to get information for

Usage Examples

Once configured with an MCP client like Claude Desktop, you can use natural language commands:

  • "Show me my recent chats"

  • "Get the last 10 messages from my chat with John"

  • "Send a message to the Development group saying 'Meeting at 3 PM'"

  • "Search for messages containing 'project deadline'"

  • "Get information about chat ID 12345"

Development

Running in Development Mode

npm run dev

Building

npm run build

Testing

# Test basic setup and Telegram connection
npm run test-setup

# Test MCP server functionality
npm run test-mcp

Watching for Changes

npm run watch

Security Notes

  • Your session data is stored locally in the session/ directory

  • Never share your API credentials or session files

  • The server only runs locally and doesn't send data to external services

  • All communication happens directly between your machine and Telegram's servers

Troubleshooting

Authentication Issues

  1. Make sure your API credentials are correct

  2. Verify your phone number format includes country code (e.g., +1234567890)

  3. Check that you can receive Telegram messages for the verification code

Connection Problems

  1. Ensure you have a stable internet connection

  2. Try deleting the session/ directory and re-authenticating

  3. Check that your API credentials haven't been revoked

MCP Client Issues

  1. Verify the path to the built server (dist/index.js) is correct

  2. Make sure Node.js is in your PATH

  3. Check the MCP client logs for error messages

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Available Tools

18 tools
delete_messageC

Delete a message

Inputs: chatId (required), messageId (required).

download_fileC

Download a file from a message

Inputs: chatId (required), messageId (required), outputPath.

edit_messageC

Edit an existing message

Inputs: chatId (required), newText (required), messageId (required).

forward_messageC

Forward a message to another chat

Inputs: toChatId (required), messageId (required), fromChatId (required).

get_chat_infoB

Get detailed information about a specific chat

Inputs: chatId (required).

get_file_infoC

Get detailed information about a file in a message

Inputs: chatId (required), messageId (required).

get_media_contentC

Download media content from a message

Inputs: chatId (required), messageId (required), downloadPath.

get_media_infoC

Get information about media in a message

Inputs: chatId (required), messageId (required).

get_message_contextC

Get detailed context for a message including reply chain and thread

Inputs: chatId (required), messageId (required), includeThread, includeReplies.

get_messagesA

Get recent messages from a specific chat. Use "me" as chatId for your own Saved Messages.

Inputs: chatId (required), limit, fromMessageId.

get_user_infoB

Get information about a specific user

Inputs: userId (required).

list_chatsA

List all chats, groups, and channels you have access to

Inputs: limit.

mark_as_readB

Mark specific messages as read in a chat

Inputs: chatId (required), messageIds (required).

search_chatsB

Search for chats by title or username

Inputs: query (required), limit.

search_messagesA

Search for messages across all chats or within a specific chat

Inputs: query (required), limit, chatId.

send_documentC

Send a document file to a chat

Inputs: chatId (required), filePath (required), caption, replyToMessageId.

send_mediaC

Send media file to a chat

Inputs: chatId (required), filePath (required), caption, replyToMessageId.

send_messageA

Send a text message to a chat

Inputs: text (required), chatId (required), replyToMessageId.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 18 tools

    Disambiguation2/5

    Multiple tools have unclear boundaries, particularly around files/media: get_file_info vs get_media_info, get_media_content vs download_file, and send_media vs send_document are easily confused. The descriptions do not clearly differentiate these tools, which could lead an agent to select the wrong one.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun snake_case pattern (e.g., search_chats, send_message, get_chat_info). This makes the naming predictable and easy to learn, with no mixed styles or arbitrary deviations.

    Tool Count4/5

    The server has 18 tools, slightly above the typical well-scoped range of 3-15. However, given the breadth of Telegram's API and the need to cover messaging, media, search, and chat management, the count is reasonable and not excessive.

    Completeness4/5

    The tool set covers the core Telegram operations: sending messages/media, retrieving messages, searching, editing/deleting/forwarding, and chat/user info. Minor gaps exist, such as no direct 'get message by ID' or chat management operations like leaving a chat, but agents can generally accomplish tasks with the provided tools.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to control a real Telegram user account via MTProto, allowing message sending, chat reading/searching, and message management through MCP tools.
      37 npm
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables an MCP client to operate a personal Telegram account directly: read chats, send messages, interact with bots, schedule broadcasts, and research YouTube, Reddit, and Instagram.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to interact with a personal Telegram account via MCP, offering tools for reading and searching chats, summarizing unread messages, sending and editing messages, handling files and voice transcripts, and managing groups and channels, with read-only mode by default.
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables a trusted MCP assistant to access a personal Telegram account for finding existing chats and contacts, reading bounded history, preparing immutable message previews, and deliberately sending or replying only to explicitly authorized messages.
      MIT

    Appeared in Searches