send_location
Send geographic coordinates to a Telegram chat. Specify latitude, longitude, chat ID, and optionally disable notification.
Instructions
Send a location to a Telegram chat.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes | Target chat ID. | |
| latitude | Yes | Latitude of the location. | |
| longitude | Yes | Longitude of the location. | |
| 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:468-516 (handler)The handler function that implements the send_location tool. It validates the chat, calls ctx.bot.send_location(), and returns a SendMediaResult.
if allowed_tools is None or "send_location" in allowed_tools: @mcp.tool async def send_location( chat_id: int, latitude: float, longitude: float, disable_notification: bool = False, ) -> SendMediaResult: """Send a location to a Telegram chat. Args: chat_id: Target chat ID. latitude: Latitude of the location. longitude: Longitude of the location. 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_location", {"chat_id": chat_id, "latitude": latitude, "longitude": longitude}, result.ok, result.error, ) return result try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() msg = await ctx.bot.send_location( chat_id=chat_id, latitude=latitude, longitude=longitude, 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_location", {"chat_id": chat_id, "latitude": latitude, "longitude": longitude}, result.ok, result.error, ) return result - aiogram_mcp/tools/media.py:14-16 (schema)Schema for the return type of send_location (and other media tools).
class SendMediaResult(ToolResponse): message_id: int | None = None chat_id: int | None = None - aiogram_mcp/tools/media.py:25-27 (registration)The registration function that conditionally registers send_location (and other media tools) on the FastMCP instance based on allowed_tools.
def register_media_tools( mcp: FastMCP, ctx: BotContext, allowed_tools: set[str] | None = None ) -> None: - aiogram_mcp/server.py:24-24 (registration)Import of register_media_tools in the server module.
from .tools.media import register_media_tools - aiogram_mcp/server.py:102-102 (registration)Call site where register_media_tools is invoked during server setup.
register_media_tools(self._mcp, self._ctx, allowed_tools=at)