list_mails_paginated
Retrieve paginated email lists from Naver Mail accounts with configurable page size and output format for efficient mail management.
Instructions
페이징을 지원하는 메일 목록 조회
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_size | No | 한 페이지당 메일 개수 | |
| last_uid | No | 이전 페이지의 마지막 UID (다음 페이지 요청시 사용) | |
| format | No | 출력 형태 (json: JSON 형태, text: 읽기 쉬운 텍스트(내용은 없음)) | text |
Implementation Reference
- service/mail_service.py:19-58 (handler)The core logic for paginated mail retrieval using UID-based filtering and mailbox fetching.
def get_mails_paginated(self, page_size: int = 10, last_uid: str = None) -> dict: """ UID 기반 페이징으로 메일을 가져옵니다. Args: page_size: 한 페이지당 메일 개수 last_uid: 이전 페이지의 마지막 UID (다음 페이지를 가져올 때 사용) Returns: { 'mails': list[MailMessage], 'last_uid': str, # 다음 페이지 요청시 사용할 UID 'has_more': bool # 다음 페이지가 있는지 } """ with self._get_mailbox_client() as mailbox: # 검색 조건 설정 if last_uid: # 특정 UID보다 작은 메일들만 가져오기 (reverse=True이므로) criteria = AND(uid=f"1:{last_uid}") # UID로 정렬하여 last_uid보다 작은 것들 중에서 최신순으로 mails = list(mailbox.fetch( criteria=criteria, limit=page_size + 1, # +1로 다음 페이지 존재 여부 확인 reverse=True )) # last_uid는 제외 mails = [mail for mail in mails if mail.uid != last_uid] else: # 첫 페이지 mails = list(mailbox.fetch( limit=page_size + 1, reverse=True )) # 다음 페이지 존재 여부 확인 has_more = len(mails) > page_size if has_more: mails = mails[:page_size] - server.py:319-343 (registration)The MCP tool handler in server.py that invokes the mail_service's paginated retrieval and formats the response.
elif name == "list_mails_paginated": page_size = args.get("page_size", 10) last_uid = args.get("last_uid") output_format = args.get("format", "text") result = mail_service.get_mails_paginated( page_size=page_size, last_uid=last_uid ) mails = result['mails'] page_info = { 'last_uid': result['last_uid'], 'has_more': result['has_more'] } if output_format == "json": content = mails_to_json(mails, page_info) else: content = mails_to_text(mails, page_info) return [TextContent(type="text", text=content)] elif name == "get_mail_detail": uid = args.get("uid")