forward_message
Forward messages between Telegram chats by specifying source, destination, and message ID. Use this tool to share content across different conversations or channels.
Instructions
Forward an existing message from one chat to another.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to_chat_id | Yes | ||
| from_chat_id | Yes | ||
| message_id | Yes | ||
| disable_notification | No |
Implementation Reference
- aiogram_mcp/tools/messaging.py:139-187 (handler)The forward_message tool handler function, which forwards a message using the bot context and handles potential errors.
async def forward_message( to_chat_id: int, from_chat_id: int, message_id: int, disable_notification: bool = False, ) -> ForwardMessageResult: """Forward an existing message from one chat to another.""" if not ctx.is_chat_allowed(to_chat_id): result = ForwardMessageResult( ok=False, error=f"Chat {to_chat_id} is not allowed." ) if ctx.audit_logger: ctx.audit_logger.log( "forward_message", { "to_chat_id": to_chat_id, "from_chat_id": from_chat_id, "message_id": message_id, }, result.ok, result.error, ) return result try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() msg = await ctx.bot.forward_message( chat_id=to_chat_id, from_chat_id=from_chat_id, message_id=message_id, disable_notification=disable_notification, ) result = ForwardMessageResult(ok=True, message_id=msg.message_id) except (TelegramBadRequest, TelegramForbiddenError) as exc: result = ForwardMessageResult(ok=False, error=str(exc)) if ctx.audit_logger: ctx.audit_logger.log( "forward_message", { "to_chat_id": to_chat_id, "from_chat_id": from_chat_id, "message_id": message_id, }, result.ok, result.error, ) return result - aiogram_mcp/tools/messaging.py:25-26 (schema)Data structure for the forward_message tool result.
class ForwardMessageResult(ToolResponse): message_id: int | None = None - aiogram_mcp/tools/messaging.py:136-136 (registration)Registration check for the forward_message tool.
if allowed_tools is None or "forward_message" in allowed_tools: