Skip to main content
Glama

search_emails

Query and retrieve emails from specific accounts using Microsoft Graph API. Input search terms, account ID, and optional filters to streamline results.

Instructions

Search emails using the modern search API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
folderNo
limitNo
queryYes

Implementation Reference

  • The main handler function for the 'search_emails' tool. It performs email searches using either folder-specific traditional search or unified modern search via Microsoft Graph API, depending on whether a folder is specified.
    @mcp.tool def search_emails( query: str, account_id: str, limit: int = 50, folder: str | None = None, ) -> list[dict[str, Any]]: """Search emails using the modern search API.""" if folder: # For folder-specific search, use the traditional endpoint folder_path = FOLDERS.get(folder.casefold(), folder) endpoint = f"/me/mailFolders/{folder_path}/messages" params = { "$search": f'"{query}"', "$top": min(limit, 100), "$select": "id,subject,from,toRecipients,receivedDateTime,hasAttachments,body,conversationId,isRead", } return list( graph.request_paginated(endpoint, account_id, params=params, limit=limit) ) return list(graph.search_query(query, ["message"], account_id, limit))

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/elyxlz/microsoft-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server