Skip to main content
Glama

search_inbox_emails

Search your Outlook inbox for emails using keywords to quickly find specific messages and information.

Instructions

Search inbox emails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch keywords
countNoNumber of results to return

Implementation Reference

  • src/index.ts:132-150 (registration)
    MCP tool registration including name, description, and input schema for search_inbox_emails
    { name: "search_inbox_emails", description: "Search inbox emails", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search keywords" }, count: { type: "number", description: "Number of results to return", default: 10 } }, required: ["query"] } },
  • Primary MCP tool handler for search_inbox_emails: extracts parameters, calls OutlookManager.searchInboxEmails, formats and returns search results
    case 'search_inbox_emails': { const query = (args as any)?.query; const count = (args as any)?.count || 10; if (!query) { throw new Error('Search query is required'); } const emails = await outlookManager.searchInboxEmails(query, count); return { content: [ { type: 'text', text: `šŸ” **Search Results: "${query}"**\nTotal: ${emails.length} items\nUnread: ${emails.filter(e => !e.isRead).length} items\n\nšŸ“‹ **Search Results List:**\n` + emails.map((email, index) => `${index + 1}. ${email.isRead ? 'āœ…' : 'šŸ“©'} **${email.subject}**\n From: ${email.sender}\n Time: ${email.receivedTime}\n EntryID: ${email.id}\n StoreID: ${email.storeId || 'N/A'}\n Search Context: ${email.body?.includes(query) ? 'Match in content' : 'Match in subject'}: ${email.subject}\n Preview: ${email.body?.substring(0, 100)}...\n` ).join('\n') }, ], }; }
  • Core implementation: fetches more inbox emails than requested, uses EmailSummarizer to filter by query, returns top count results
    async searchInboxEmails(query: string, count: number = 10): Promise<EmailMessage[]> { const emails = await this.getInboxEmails(Math.min(count * 2, 50)); const { EmailSummarizer } = await import('./email-summarizer.js'); const searchResults = EmailSummarizer.searchEmails(emails, query); return searchResults.slice(0, count); }
  • Helper function that performs the actual text search across subject, sender, and body content of emails
    static searchEmails(emails: EmailMessage[], searchTerm: string): EmailMessage[] { if (!searchTerm.trim()) { return emails; } const normalizedSearchTerm = searchTerm.toLowerCase(); return emails.filter(email => { // Search in subject const subjectMatch = email.subject.toLowerCase().includes(normalizedSearchTerm); // Search in sender const senderMatch = email.sender.toLowerCase().includes(normalizedSearchTerm); // Search in body content (remove HTML tags before searching) const cleanBody = email.body.replace(/<[^>]*>/g, '').toLowerCase(); const bodyMatch = cleanBody.includes(normalizedSearchTerm); return subjectMatch || senderMatch || bodyMatch; }); }

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/cqyefeng119/windows-outlook-mcp'

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