send_animation
Send a GIF or animation to a Telegram chat using a URL or file ID, with optional caption and notification settings.
Instructions
Send a GIF/animation to a Telegram chat.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes | Target chat ID. | |
| animation_url | Yes | URL or file_id of the animation. | |
| caption | No | Optional caption. | |
| parse_mode | No | HTML, Markdown, MarkdownV2, or None. | HTML |
| disable_notification | No | Send silently. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| error | No | ||
| message_id | No | ||
| chat_id | No |
Implementation Reference
- aiogram_mcp/tools/media.py:202-252 (handler)The main handler function for the 'send_animation' tool. It validates chat access, enforces rate limiting, calls bot.send_animation with the provided parameters, handles errors, and logs the outcome.
async def send_animation( chat_id: int, animation_url: str, caption: str | None = None, parse_mode: str | None = "HTML", disable_notification: bool = False, ) -> SendMediaResult: """Send a GIF/animation to a Telegram chat. Args: chat_id: Target chat ID. animation_url: URL or file_id of the animation. caption: Optional caption. parse_mode: HTML, Markdown, MarkdownV2, or None. disable_notification: Send silently. """ if not ctx.is_chat_allowed(chat_id): result = SendMediaResult(ok=False, error=f"Chat {chat_id} is not allowed.") if ctx.audit_logger: ctx.audit_logger.log( "send_animation", {"chat_id": chat_id, "animation_url": animation_url}, result.ok, result.error, ) return result try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() msg = await ctx.bot.send_animation( chat_id=chat_id, animation=animation_url, caption=caption, parse_mode=normalize_parse_mode(parse_mode), disable_notification=disable_notification, ) result = SendMediaResult(ok=True, message_id=msg.message_id, chat_id=msg.chat.id) except ValueError as exc: result = SendMediaResult(ok=False, error=str(exc)) except (TelegramBadRequest, TelegramForbiddenError) as exc: result = SendMediaResult(ok=False, error=str(exc)) if ctx.audit_logger: ctx.audit_logger.log( "send_animation", {"chat_id": chat_id, "animation_url": animation_url}, result.ok, result.error, ) return result - aiogram_mcp/tools/media.py:14-16 (schema)SendMediaResult model used as the return type for send_animation.
class SendMediaResult(ToolResponse): message_id: int | None = None chat_id: int | None = None - aiogram_mcp/tools/media.py:25-27 (registration)The register_media_tools function that registers send_animation (and other media tools) via @mcp.tool decorator.
def register_media_tools( mcp: FastMCP, ctx: BotContext, allowed_tools: set[str] | None = None ) -> None: - aiogram_mcp/server.py:102-102 (registration)The call site where register_media_tools is invoked, which registers send_animation as an MCP tool.
register_media_tools(self._mcp, self._ctx, allowed_tools=at) - aiogram_mcp/permissions.py:34-34 (helper)Permission level mapping for send_animation, set to MESSAGING.
"send_animation": PermissionLevel.MESSAGING,