Telegram send file
tg_send_fileSend a file to a Telegram chat using a URL. Optionally add a caption, parse mode, or reply to a message.
Instructions
Send general files via telegram bot
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | File URL | |
| chat_id | No | Telegram chat id, Default to get from environment variables | |
| caption | No | File caption, 0-1024 characters after entities parsing | |
| parse_mode | No | Mode for parsing entities in the caption. [text/MarkdownV2] | |
| reply_to_message_id | No | Identifier of the message that will be replied to |
Implementation Reference
- mcp_notify/tgbot.py:155-171 (handler)Handler function for the tg_send_file tool. Sends a general file (document) via Telegram bot using the provided URL.
async def tg_send_file( url: str = Field(description="File URL"), chat_id: str = Field("", description="Telegram chat id, Default to get from environment variables"), caption: str = Field("", description="File caption, 0-1024 characters after entities parsing"), parse_mode: str = Field("", description=f"Mode for parsing entities in the caption. [text/MarkdownV2]"), reply_to_message_id: int = Field(0, description="Identifier of the message that will be replied to"), ): if parse_mode == TELEGRAM_MARKDOWN_V2: caption = telegramify_markdown.markdownify(caption) res = await bot.send_document( chat_id=chat_id or TELEGRAM_DEFAULT_CHAT, document=url, caption=caption or None, parse_mode=parse_mode if parse_mode in [TELEGRAM_MARKDOWN_V2] else None, reply_to_message_id=reply_to_message_id or None, ) return res.to_json() - mcp_notify/tgbot.py:155-160 (schema)Input schema for tg_send_file, defined via Pydantic Field parameters: url (required), chat_id, caption, parse_mode, reply_to_message_id.
async def tg_send_file( url: str = Field(description="File URL"), chat_id: str = Field("", description="Telegram chat id, Default to get from environment variables"), caption: str = Field("", description="File caption, 0-1024 characters after entities parsing"), parse_mode: str = Field("", description=f"Mode for parsing entities in the caption. [text/MarkdownV2]"), reply_to_message_id: int = Field(0, description="Identifier of the message that will be replied to"), - mcp_notify/tgbot.py:151-154 (registration)Registration of the tg_send_file tool via @mcp.tool() decorator with title 'Telegram send file' and description 'Send general files via telegram bot'.
@mcp.tool( title="Telegram send file", description="Send general files via telegram bot", ) - mcp_notify/__init__.py:20-21 (registration)Registration of the tgbot module's tools (including tg_send_file) via tgbot.add_tools(mcp) call.
tgbot.add_tools(mcp) other.add_tools(mcp)