send_contact
Send phone contacts to Telegram chats by specifying chat ID, phone number, and contact name. Enables silent sending with optional notification settings.
Instructions
Send a phone contact to a Telegram chat.
Args: chat_id: Target chat ID. phone_number: Contact's phone number. first_name: Contact's first name. last_name: Contact's last name. disable_notification: Send silently.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes | ||
| phone_number | Yes | ||
| first_name | Yes | ||
| last_name | No | ||
| disable_notification | No |
Implementation Reference
- aiogram_mcp/tools/media.py:418-462 (handler)The handler implementation for the `send_contact` MCP tool, which sends a contact to a Telegram chat using `aiogram`'s `bot.send_contact` method.
async def send_contact( chat_id: int, phone_number: str, first_name: str, last_name: str | None = None, disable_notification: bool = False, ) -> SendMediaResult: """Send a phone contact to a Telegram chat. Args: chat_id: Target chat ID. phone_number: Contact's phone number. first_name: Contact's first name. last_name: Contact's last name. 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_contact", {"chat_id": chat_id, "phone_number": phone_number}, result.ok, result.error, ) return result try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() msg = await ctx.bot.send_contact( chat_id=chat_id, phone_number=phone_number, first_name=first_name, last_name=last_name, disable_notification=disable_notification, ) result = SendMediaResult(ok=True, message_id=msg.message_id, chat_id=msg.chat.id) except (TelegramBadRequest, TelegramForbiddenError) as exc: result = SendMediaResult(ok=False, error=str(exc)) if ctx.audit_logger: ctx.audit_logger.log( "send_contact", {"chat_id": chat_id, "phone_number": phone_number},