forward_message
Forward an existing message from one chat to another by specifying source chat, message ID, and target chat.
Instructions
Forward an existing message from one chat to another.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to_chat_id | Yes | ||
| from_chat_id | Yes | ||
| message_id | Yes | ||
| disable_notification | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| error | No | ||
| message_id | No |
Implementation Reference
- aiogram_mcp/tools/messaging.py:136-187 (handler)The forward_message tool handler function. It checks chat permissions, applies rate limiting, calls ctx.bot.forward_message(), and logs the result via audit_logger.
if allowed_tools is None or "forward_message" in allowed_tools: @mcp.tool 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)ForwardMessageResult Pydantic model: returns ok/error and optional message_id.
class ForwardMessageResult(ToolResponse): message_id: int | None = None - aiogram_mcp/tools/messaging.py:29-31 (registration)register_messaging_tools function that registers forward_message as an MCP tool via @mcp.tool decorator. Called from server.py line 88.
def register_messaging_tools( mcp: FastMCP, ctx: BotContext, allowed_tools: set[str] | None = None ) -> None: - aiogram_mcp/server.py:86-88 (registration)The _register_tools method in the server that calls register_messaging_tools to register all messaging tools including forward_message.
def _register_tools(self) -> None: at = self._allowed_tools register_messaging_tools(self._mcp, self._ctx, allowed_tools=at) - aiogram_mcp/permissions.py:27-27 (helper)Permission mapping: 'forward_message' is assigned PermissionLevel.MESSAGING.
"forward_message": PermissionLevel.MESSAGING,