get_user_profile_photos
Retrieve Telegram user profile photo file IDs for bot integration, enabling avatar display or storage in aiogram applications.
Instructions
Return a lightweight list of Telegram profile photo file IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | ||
| limit | No |
Implementation Reference
- aiogram_mcp/tools/users.py:114-163 (handler)Implementation of the get_user_profile_photos MCP tool handler.
async def get_user_profile_photos( user_id: int, limit: int = 5 ) -> UserProfilePhotosResult: """Return a lightweight list of Telegram profile photo file IDs.""" if limit < 1 or limit > 100: result = UserProfilePhotosResult( ok=False, error="limit must be between 1 and 100." ) if ctx.audit_logger: ctx.audit_logger.log( "get_user_profile_photos", {"user_id": user_id, "limit": limit}, result.ok, result.error, ) return result try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() photos = await ctx.bot.get_user_profile_photos(user_id=user_id, limit=limit) result = UserProfilePhotosResult( ok=True, user_id=user_id, total_count=photos.total_count, photos=[ [ { "file_id": size.file_id, "file_unique_id": size.file_unique_id, "width": size.width, "height": size.height, "file_size": size.file_size, } for size in group ] for group in photos.photos ], ) except (TelegramBadRequest, TelegramForbiddenError) as exc: result = UserProfilePhotosResult(ok=False, error=str(exc)) if ctx.audit_logger: ctx.audit_logger.log( "get_user_profile_photos", {"user_id": user_id, "limit": limit}, result.ok, result.error, ) return result - aiogram_mcp/tools/users.py:35-39 (schema)Result schema for get_user_profile_photos tool.
class UserProfilePhotosResult(ToolResponse): user_id: int | None = None total_count: int | None = None photos: list[list[dict[str, Any]]] | None = None - aiogram_mcp/tools/users.py:111-111 (registration)Registration condition for get_user_profile_photos tool within register_user_tools.
if allowed_tools is None or "get_user_profile_photos" in allowed_tools: