A Model Context Protocol (MCP) server that provides seamless integration with the Telegram Bot API. This server enables AI assistants like Claude to interact with Telegram, including support for sending messages, managing media, and handling interactive callback buttons.
- Rich Messaging: Send text messages with Markdown, HTML, or plain text formatting
- Media Support: Send photos, videos, and documents
- Message Management: Forward, delete, and retrieve chat information
- Interactive Callbacks: Full support for inline keyboards and callback queries
- Update Polling: Receive incoming messages and callback queries
- Type-Safe: Built with TypeScript and Zod for robust input validation
- MCP Compatible: Works with Claude Desktop, Cursor, and other MCP clients
- Node.js 18 or higher
- A Telegram Bot Token (get one from @BotFather)
npm install -g telegram-mcpgit clone https://github.com/YOUR_USERNAME/telegram-mcp.git
cd telegram-mcp
npm install
npm run build- Open Telegram and search for @BotFather
- Send
/newbotand follow the instructions - Copy the bot token provided by BotFather
- Set it as an environment variable:
TELEGRAM_BOT_TOKEN
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": "npx",
"args": ["-y", "telegram-mcp"],
"env": {
"TELEGRAM_BOT_TOKEN": "your-bot-token-here"
}
}
}
}Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"telegram": {
"command": "npx",
"args": ["-y", "telegram-mcp"],
"env": {
"TELEGRAM_BOT_TOKEN": "your-bot-token-here"
}
}
}
}Send a text message to a Telegram chat.
Parameters:
chat_id(string|number, required): Chat ID to send message totext(string, required): Text message to sendparse_mode(string, optional): "Markdown", "MarkdownV2", or "HTML"disable_notification(boolean, optional): Send message silently
Example:
Send a message "Hello from Claude!" to chat ID 123456789
Send a photo to a Telegram chat.
Parameters:
chat_id(string|number, required): Chat IDphoto(string, required): Photo file path or URLcaption(string, optional): Photo captionparse_mode(string, optional): Caption formatting mode
Send a document/file to a Telegram chat.
Parameters:
chat_id(string|number, required): Chat IDdocument(string, required): Document file path or URLcaption(string, optional): Document caption
Send a video to a Telegram chat.
Parameters:
chat_id(string|number, required): Chat IDvideo(string, required): Video file path or URLcaption(string, optional): Video caption
Forward a message from one chat to another.
Parameters:
chat_id(string|number, required): Destination chat IDfrom_chat_id(string|number, required): Source chat IDmessage_id(number, required): Message ID to forward
Delete a message from a chat.
Parameters:
chat_id(string|number, required): Chat IDmessage_id(number, required): Message ID to delete
Get information about a chat.
Parameters:
chat_id(string|number, required): Chat ID
Receive incoming updates (messages, callback queries, etc.).
Parameters:
offset(number, optional): Identifier of the first update to returnlimit(number, optional): Number of updates to retrieve (1-100)timeout(number, optional): Timeout in seconds for long polling
Send a message with inline keyboard buttons.
Parameters:
chat_id(string|number, required): Chat IDtext(string, required): Message textinline_keyboard(array, required): Array of button rowsparse_mode(string, optional): Message formatting mode
Example:
Send a message with buttons:
- Text: "Choose an option:"
- Buttons: [
[{"text": "Option 1", "callback_data": "opt1"}],
[{"text": "Option 2", "callback_data": "opt2"}]
]
Answer a callback query from an inline keyboard button.
Parameters:
callback_query_id(string, required): Unique identifier for the querytext(string, optional): Notification text (0-200 characters)show_alert(boolean, optional): Show as alert instead of notification
Edit the text of an existing message.
Parameters:
chat_id(string|number, required): Chat IDmessage_id(number, required): Message ID to edittext(string, required): New textparse_mode(string, optional): Formatting mode
Edit the inline keyboard of an existing message.
Parameters:
chat_id(string|number, required): Chat IDmessage_id(number, required): Message ID to editinline_keyboard(array, required): New inline keyboard
Send "Hello, World!" to my Telegram chat 123456789
1. Send a message with inline keyboard:
- Text: "What's your favorite color?"
- Buttons: [
[{"text": "Red", "callback_data": "color_red"}],
[{"text": "Blue", "callback_data": "color_blue"}]
]
2. Get updates to receive callback queries
3. When user clicks a button, answer the callback query:
- callback_query_id: (from update)
- text: "You selected Red!"
4. Edit the original message to show the selection:
- Update text to "You chose: Red"
Send a photo from https://example.com/image.jpg to chat 123456789 with caption "Check this out!"
To find your chat ID:
- Send a message to your bot
- Use the
get_updatestool to retrieve updates - Look for the
chat.idfield in the response
Alternatively, use @userinfobot on Telegram.
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build
npm run build
# Run production build
npm startMake sure you've set the TELEGRAM_BOT_TOKEN in your MCP configuration.
Verify the chat ID is correct. The bot must have access to the chat (user must have started the bot or bot must be added to the group).
- Make sure to call
answer_callback_queryafter receiving a callback query - Check that
callback_datais set on your inline keyboard buttons - Use
get_updatesto retrieve callback queries
- Never share your bot token publicly
- Use environment variables to store sensitive credentials
- Be cautious with chat IDs - validate access controls in your application
- Consider implementing rate limiting for production use
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions:
- Open an issue on GitHub
- Check the Telegram Bot API documentation
- Review the MCP documentation