Skip to main content
Glama

search_draft_emails

Locate and retrieve draft emails in Microsoft Outlook using specific keywords, streamlining email management and reducing manual search time.

Instructions

Search draft emails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of results to return
queryYesSearch keywords

Implementation Reference

  • src/index.ts:198-216 (registration)
    Registration of the 'search_draft_emails' tool in the MCP ListToolsRequestSchema handler, defining name, description, and input schema.
    { name: "search_draft_emails", description: "Search draft emails", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search keywords" }, count: { type: "number", description: "Number of results to return", default: 10 } }, required: ["query"] } },
  • Top-level MCP tool call handler for 'search_draft_emails' that parses arguments, invokes the manager method, and formats the response.
    case 'search_draft_emails': { const query = (args as any)?.query; const count = (args as any)?.count || 10; if (!query) { throw new Error('Search query is required'); } const drafts = await outlookManager.searchDraftEmails(query, count); return { content: [ { type: 'text', text: `🔍 **Draft Search Results: "${query}"**\nTotal: ${drafts.length} items\n\n📋 **Draft Search Results List:**\n` + drafts.map((draft, index) => `${index + 1}. **${draft.subject}**\n From: ${draft.sender}\n Time: ${draft.receivedTime}\n EntryID: ${draft.id}\n StoreID: ${draft.storeId || 'N/A'}\n Search Context: ${draft.body?.includes(query) ? 'Match in content' : 'Match in subject'}: ${draft.subject}\n Preview: ${draft.body?.substring(0, 100)}...\n` ).join('\n') }, ], }; }
  • Implementation of searchDraftEmails in OutlookManager that fetches draft emails and filters them using EmailSummarizer.searchEmails.
    async searchDraftEmails(query: string, count: number = 10): Promise<EmailMessage[]> { const emails = await this.getDraftEmails(Math.min(count * 2, 50)); const { EmailSummarizer } = await import('./email-summarizer.js'); const searchResults = EmailSummarizer.searchEmails(emails, query); return searchResults.slice(0, count); }
  • Static helper method EmailSummarizer.searchEmails that implements the core search logic by filtering emails matching the query in subject, sender, or body.
    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; }); }

Other Tools

Related Tools

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