Skip to main content

MCP server to control a Telegram bot

Project description

Telegram Bot MCP

MCP (Multi-purpose Computing Platform) for working with Telegram Bot API. Provides functions for sending and receiving messages through Telegram bot.

Features

  • Send text messages to chats
  • Send media content (photos, documents, videos, audio)
  • Create and send polls
  • Get bot information
  • Get updates (messages, events) from users
  • Delete messages

Installation

git clone https://github.com/coderroleggg/telegram-bot-mcp
cd telegram-bot-mcp
uv venv
source .venv/bin/activate
uv pip install -e .

Connecting to Claude Desktop, Cursor

Add the telegram-bot block to your mcp.json or claude_desktop_config.json or completely replace the file content with:

{
    "mcpServers": {
        "telegram-bot": {
            "type": "stdio",
            "command": "uv",
            "args": [
                "run",
                "--directory",
                "/Users/yourusername/Downloads/telegram-bot-mcp", // path to the bot code folder
                "server"
            ],
            "name": "Telegram Bot API",
            "description": "MCP for working with Telegram Bot API. Send messages, media and work with bot.",
            "config": {
                "token": "YOUR_BOT_TOKEN_HERE"
            }
        }
    }
}

Available Functions

  • sendMessage - send text message
  • sendPhoto - send photo
  • deleteMessage - delete message
  • getMe - get bot information
  • getUpdates - get new messages and events

Usage Examples

Sending a Message

response = mcp.call("sendMessage", {"chatId": "12345678", "text": "Hello, world!"})
print(response)

Getting Updates

updates = mcp.call("getUpdates", {})
for update in updates["updates"]:
    print(update)

Example Usage in Cursor

Here's how to use the Telegram Bot MCP in Cursor:

Cursor Usage Example

Result Message

Example of a message sent through the bot:

Result Message

License

MIT

API Tools

initialize

Initializes configuration for Telegram Bot MCP.

Parameters:

  • token: Your Telegram bot token obtained from @BotFather

sendMessage

Sends a text message to the specified chat.

Parameters:

  • chatId: Chat ID where to send the message (string or number)
  • text: Message text to send

sendPhoto

Sends a photo to the specified chat.

Parameters:

  • chatId: Chat ID where to send the photo (string or number)
  • photoUrl: Photo URL or path to local file
  • caption: Photo caption (optional)

sendDocument

Sends a document to the specified chat.

Parameters:

  • chatId: Chat ID where to send the document (string or number)
  • documentUrl: Document URL or path to local file
  • caption: Document caption (optional)
  • filename: File name (optional)

sendVideo

Sends a video to the specified chat.

Parameters:

  • chatId: Chat ID where to send the video (string or number)
  • videoUrl: Video URL or path to local file
  • caption: Video caption (optional)
  • duration: Video duration in seconds (optional)
  • width: Video width (optional)
  • height: Video height (optional)

sendAudio

Sends audio to the specified chat.

Parameters:

  • chatId: Chat ID where to send the audio (string or number)
  • audioUrl: Audio URL or path to local file
  • caption: Audio caption (optional)
  • duration: Audio duration in seconds (optional)
  • performer: Performer (optional)
  • title: Track title (optional)

sendPoll

Sends a poll message to the specified chat.

Parameters:

  • chatId: Chat ID where to send the poll (string or number)
  • question: Poll question
  • options: List of answer options (strings)
  • isAnonymous: Whether the poll is anonymous (optional, default True)
  • allowsMultipleAnswers: Whether multiple answers are allowed (optional, default False)

getMe

Gets information about the bot.

Parameters: none

getUpdates

Gets updates (messages, events) from Telegram Bot API.

Parameters:

  • offset: ID of the first update to return (optional)
  • limit: Maximum number of updates to return (optional, default 100)
  • timeout: Timeout in seconds (optional, default 0)

deleteMessage

Deletes a message from the chat.

Parameters:

  • chatId: Chat ID from which to delete the message (string or number)
  • messageId: Message ID to delete (number)

How to Get chatId?

To get a chat or user ID, there are several ways:

  1. Use the getUpdates tool and find the needed ID after sending a message to your bot

  2. Use a bot like @userinfobot: send it a message, and it will return your ID

  3. For group chats: add your bot to the group, send a message and use getUpdates to find the group ID

  4. For channels:

    • First, add your bot as an administrator to the channel with permission to send messages
    • Forward any message from the channel to @userdatailsbot
    • The bot will return the channel ID (it will be negative and start with -100)
    • Use this ID as chatId when sending messages to the channel

Limitations

  • Bot cannot start a conversation with a user first, the user must send a message to the bot first
  • Bot can only send messages to chats where it is present
  • Some file formats may be restricted by Telegram
  • When sending local files, they must be accessible to the process in which MCP is running

Additional Information

For more information about Telegram Bot API:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_coderroleggg_telegram_bot_mcp-1.0.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_coderroleggg_telegram_bot_mcp-1.0.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_coderroleggg_telegram_bot_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 87d852beefbda64d3ddf47380c30a21c4ca5b7fe3155e62bb87d08815cb68fde
MD5 238ce0d16788726a8eaf94961e5163b1
BLAKE2b-256 2ed23da7c75de969556f778be4347142998849080cef5b039571851161809055

See more details on using hashes here.

File details

Details for the file iflow_mcp_coderroleggg_telegram_bot_mcp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_coderroleggg_telegram_bot_mcp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_coderroleggg_telegram_bot_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e154792186bae193c17f725436e7b6f3f70f7ab4b12f8fc967acc7dd69e4f99e
MD5 3396c3084ca7d34dad2ace3f2e019a99
BLAKE2b-256 a492bb34f9fa850b813be05fff0bd8acaada3ff7039e2192a9eaea57f0438c57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page