@iqai/mcp-telegram v0.0.1
Telegram MCP Server
An MCP (Model Context Protocol) server for interacting with Telegram bots and channels using the Telegraf library.
Features
- SEND_MESSAGE: Send messages to channels or chats
- GET_CHANNEL_INFO: Get information about channels/chats
- FORWARD_MESSAGE: Forward messages between chats
- PIN_MESSAGE: Pin messages in channels
- GET_CHANNEL_MEMBERS: Get list of channel administrators
Setup
- Install dependencies:
npm install- Set up your Telegram bot token:
export TELEGRAM_BOT_TOKEN="your_bot_token_here"- Build the project:
npm run build- Start the MCP server:
npm startUsage
The server communicates over stdio and can be used with any MCP-compatible client.
Available Tools
SEND_MESSAGE
Send a message to a Telegram chat or channel.
chatId: Chat ID or username (e.g., @channelname or -1001234567890)text: Message textparseMode: Optional formatting (HTML, Markdown, MarkdownV2)disableWebPagePreview: Optional booleandisableNotification: Optional boolean for silent messages
GET_CHANNEL_INFO
Get information about a channel or chat.
channelId: Channel ID or username
FORWARD_MESSAGE
Forward a message from one chat to another.
fromChatId: Source chat IDtoChatId: Destination chat IDmessageId: Message ID to forwarddisableNotification: Optional boolean for silent forwarding
PIN_MESSAGE
Pin a message in a chat or channel.
chatId: Chat ID or usernamemessageId: Message ID to pindisableNotification: Optional boolean for silent pinning
GET_CHANNEL_MEMBERS
Get channel administrators (limited by Telegram API).
channelId: Channel ID or usernamelimit: Maximum number of members to retrieve (1-50, default: 10)
Environment Variables
TELEGRAM_BOT_TOKEN: Your Telegram bot token (required)
Bot Setup
- Create a bot with @BotFather
- Get your bot token
- Add your bot to channels with appropriate permissions
- Use channel usernames (e.g., @mychannel) or chat IDs for interactions
To install the required dependencies, run:
npm install telegraf zod dedent fastmcpnpm install -D @types/node typescript tsxThis Telegram MCP server provides comprehensive tools for interacting with Telegram channels and chats, including sending messages, getting channel information, forwarding messages, pinning messages, and retrieving member lists. The bot uses the Telegraf library which is a modern and feature-rich Telegram bot framework for Node.js.
5 months ago