list_emails
Retrieve emails from a specified Outlook folder using a Microsoft MCP server. Configure account ID, folder, limit, and body inclusion for precise email listing.
Instructions
List emails from specified folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes | ||
| folder | No | inbox | |
| include_body | No | ||
| limit | No |
Implementation Reference
- src/microsoft_mcp/tools.py:132-162 (handler)The handler function for the 'list_emails' tool. It lists emails from a specified Microsoft mail folder using the Microsoft Graph API, with options for folder, limit, and whether to include body content.@mcp.tool def list_emails( account_id: str, folder: str = "inbox", limit: int = 10, include_body: bool = True, ) -> list[dict[str, Any]]: """List emails from specified folder""" folder_path = FOLDERS.get(folder.casefold(), folder) if include_body: select_fields = "id,subject,from,toRecipients,ccRecipients,receivedDateTime,hasAttachments,body,conversationId,isRead" else: select_fields = "id,subject,from,toRecipients,receivedDateTime,hasAttachments,conversationId,isRead" params = { "$top": min(limit, 100), "$select": select_fields, "$orderby": "receivedDateTime desc", } emails = list( graph.request_paginated( f"/me/mailFolders/{folder_path}/messages", account_id, params=params, limit=limit, ) ) return emails
- src/microsoft_mcp/tools.py:10-20 (helper)Helper dictionary mapping user-friendly folder names to Microsoft Graph API folder paths, used by the list_emails handler.FOLDERS = { k.casefold(): v for k, v in { "inbox": "inbox", "sent": "sentitems", "drafts": "drafts", "deleted": "deleteditems", "junk": "junkemail", "archive": "archive", }.items() }
- src/microsoft_mcp/tools.py:8-8 (registration)Creation of the FastMCP instance where tools like list_emails are registered via decorators.mcp = FastMCP("microsoft-mcp")
- src/microsoft_mcp/server.py:3-3 (registration)Import of the MCP instance from tools.py, which triggers registration of all decorated tools including list_emails, and runs the server.from .tools import mcp