mcp-telegram

v1.0.7
@imenam/mcp-telegram Checked 3 days ago Published 10 days ago

MCP server that connects an AI agent to one Telegram channel through a bot: read incoming posts, publish, edit, delete, pin, react and exchange files.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

get_channel_info

Describe the configured channel: title, @username, link, description, subscriber count, pinned post, and the bot's administrator rights, with the rights it lacks. Call it first when a write fails for lack of rights, or to check the setup.

list_posts

List the channel's posts, newest first, after fetching the updates Telegram holds for the bot. Only posts published or edited since the bot became an administrator are known: a bot cannot read older history. Posts deleted by a human stay listed, because Telegram does not tell bots about deletions. Page backwards with before_message_id, or read what came after a known post with after_message_id (then the oldest come first in the page, still returned newest first).

ParameterTypeDescription
after_message_idintegerOnly posts with a greater message_id
before_message_idintegerOnly posts with a smaller message_id
limitintegerNumber of posts to return, 1-100. Defaults to 20

get_post

Return one post of the channel by its message_id, with its text or caption, media, reactions and link.

ParameterTypeDescription
message_id *integerIdentifier of the post in the channel (message_id)

wait_for_posts

Block until at least one new or edited post arrives in the channel, or until the timeout. Returns the posts received (an empty list on timeout) and a cursor. Pass that cursor to the next call to get exactly what arrived since, edits included, even if another call read it first. Posts sent through this server are not waited for: their result is already returned by the sending tool.

ParameterTypeDescription
cursorstringCursor returned by a previous call: only posts received after it are returned. Omit to wait for posts received from now on
timeout_secondsintegerMaximum wait, 1-300 seconds. Defaults to 60

enable_notifications

Get notified of new and edited posts of the channel without waiting for them. Returns immediately: it hands you the exact Monitor call to make right after — arming that watcher is what actually delivers notifications, and until you do it no post will reach you. Call it once at the start of a session; then keep working, new posts interrupt you on their own. The host stops the watcher after 30 minutes at most: re-arm it with the same Monitor call each time it expires. Works locally and behind mcp-http-gateway.

ParameterTypeDescription
_gateway_watchobjectFilled in by the mcp-http-gateway relay, never by the agent: the relay will run the watcher and needs a watch specification instead of a local command

send_post

Publish a text post in the channel. The text is limited to 4096 characters after formatting is parsed. Returns the published post. Requires the can_post_messages right.

ParameterTypeDescription
text *stringText of the post
disable_link_previewbooleanDo not show a preview of the first link. Defaults to false
parse_modestringFormatting of the text. Omit for plain text. HTML supports <b>, <i>, <u>, <s>, <code>, <pre>, <a href>, <blockquote>, <tg-spoiler>; escape <, > and & as entities. MarkdownV2 requires escaping _*[]()~`…
reply_to_message_idintegerIdentifier of a post of the channel this post replies to
silentbooleanPublish without a notification sound for subscribers. Defaults to false

send_media

Publish a photo, video, animation, audio, voice note or document in the channel, with an optional caption (1024 characters at most). Give exactly one source: file_path for a file on the agent machine (10 MB for a photo, 50 MB otherwise), url for a file Telegram downloads itself, or file_id to reuse a file already on Telegram (the media.file_id of a post). Returns the published post. Requires the can_post_messages right.

ParameterTypeDescription
kind *stringHow Telegram shows the file. 'document' sends any file as is, without compression
captionstringCaption shown under the media
file_contentstringFilled in by the mcp-http-gateway relay, never by the agent: the base64 content of the file read on the agent machine
file_idstringTelegram file_id of a file already sent to Telegram
file_namestringFilled in by the mcp-http-gateway relay, never by the agent: the name of the file read on the agent machine
file_pathstringAbsolute path of the file to publish, on the agent machine. It must sit inside one of the directories allowed by TELEGRAM_UPLOAD_ROOTS
parse_modestringFormatting of the text. Omit for plain text. HTML supports <b>, <i>, <u>, <s>, <code>, <pre>, <a href>, <blockquote>, <tg-spoiler>; escape <, > and & as entities. MarkdownV2 requires escaping _*[]()~`…
reply_to_message_idintegerIdentifier of a post of the channel this post replies to
silentbooleanPublish without a notification sound for subscribers. Defaults to false
urlstringHTTP(S) URL of the file, downloaded by Telegram

edit_post

Change the text of a text post (text), or the caption of a media post (caption). Give exactly one of the two. Returns the edited post. Requires the can_edit_messages right.

ParameterTypeDescription
message_id *integerIdentifier of the post in the channel (message_id)
captionstringNew caption of a media post; an empty string removes it
disable_link_previewbooleanText posts only: do not show a link preview. Defaults to false
parse_modestringFormatting of the text. Omit for plain text. HTML supports <b>, <i>, <u>, <s>, <code>, <pre>, <a href>, <blockquote>, <tg-spoiler>; escape <, > and & as entities. MarkdownV2 requires escaping _*[]()~`…
textstringNew text of a text post

delete_posts

Delete posts of the channel. Irreversible. If one post cannot be deleted, none is. Requires the can_delete_messages right.

ParameterTypeDescription
message_ids *arrayIdentifiers of the posts to delete, 1-100

pin_post

Pin a post at the top of the channel. Requires the can_edit_messages right.

ParameterTypeDescription
message_id *integerIdentifier of the post in the channel (message_id)
silentbooleanPublish without a notification sound for subscribers. Defaults to false

unpin_post

Unpin a pinned post of the channel. Requires the can_edit_messages right.

ParameterTypeDescription
message_id *integerIdentifier of the post in the channel (message_id)

react_to_post

Set the bot's reaction on a post, or remove it when emoji is omitted. Only the emoji allowed in the channel's settings are accepted (for example 👍 ❤ 🔥 🎉 👏).

ParameterTypeDescription
message_id *integerIdentifier of the post in the channel (message_id)
emojistringThe reaction emoji. Omit to remove the bot's reaction

download_media

Download the file of a media post (photo, video, document…) into a directory of the agent machine. The file never passes through the conversation. Bots can download files up to 20 MB.

ParameterTypeDescription
message_id *integerIdentifier of the post in the channel (message_id)
destination_overwritebooleanReplace the destination file if it already exists. Defaults to false
destination_pathstringABSOLUTE path of the destination DIRECTORY on the agent machine, inside one of the directories allowed by TELEGRAM_DOWNLOAD_ROOTS. It is created if missing. Required
destination_relaybooleanFilled in by the mcp-http-gateway relay, never by the agent. Signals that the destination lives on another machine and that the file content must travel in the response
filenamestringName of the file to create, extension included. Must not contain path separators. Defaults to the name Telegram gives the file