send_photo
Send photos to Telegram chats using URLs, with optional captions and notification settings for bot integration.
Instructions
Send a photo to a Telegram chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes | ||
| photo_url | Yes | ||
| caption | No | ||
| parse_mode | No | HTML | |
| disable_notification | No |
Implementation Reference
- aiogram_mcp/tools/messaging.py:92-134 (handler)The handler function `send_photo` that uses aiogram's bot API to send a photo to a chat.
async def send_photo( chat_id: int, photo_url: str, caption: str | None = None, parse_mode: str | None = "HTML", disable_notification: bool = False, ) -> SendPhotoResult: """Send a photo to a Telegram chat.""" if not ctx.is_chat_allowed(chat_id): result = SendPhotoResult(ok=False, error=f"Chat {chat_id} is not allowed.") if ctx.audit_logger: ctx.audit_logger.log( "send_photo", {"chat_id": chat_id, "photo_url": photo_url}, result.ok, result.error, ) return result try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() msg = await ctx.bot.send_photo( chat_id=chat_id, photo=photo_url, caption=caption, parse_mode=normalize_parse_mode(parse_mode), disable_notification=disable_notification, ) result = SendPhotoResult(ok=True, message_id=msg.message_id, chat_id=msg.chat.id) except ValueError as exc: result = SendPhotoResult(ok=False, error=str(exc)) except (TelegramBadRequest, TelegramForbiddenError) as exc: result = SendPhotoResult(ok=False, error=str(exc)) if ctx.audit_logger: ctx.audit_logger.log( "send_photo", {"chat_id": chat_id, "photo_url": photo_url}, result.ok, result.error, ) return result - aiogram_mcp/tools/messaging.py:20-23 (schema)The response schema for the send_photo tool.
class SendPhotoResult(ToolResponse): message_id: int | None = None chat_id: int | None = None - aiogram_mcp/tools/messaging.py:89-89 (registration)Conditional registration logic for the send_photo tool within the register_messaging_tools function.
if allowed_tools is None or "send_photo" in allowed_tools: