search_draft_emails
Find draft emails in Outlook by searching with keywords to locate specific messages before sending.
Instructions
Search draft emails
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search keywords | |
| count | No | Number of results to return |
Implementation Reference
- src/outlook-manager.ts:381-385 (handler)Core implementation of the search_draft_emails tool. Fetches draft emails, uses EmailSummarizer for searching based on query, limits to requested count.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);
- src/index.ts:199-216 (registration)Tool registration including name, description, and input schema definition.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"] } },
- src/index.ts:201-215 (schema)Input schema defining parameters: query (required string), count (optional number, default 10).inputSchema: { type: "object", properties: { query: { type: "string", description: "Search keywords" }, count: { type: "number", description: "Number of results to return", default: 10 } }, required: ["query"] }
- src/index.ts:639-657 (handler)MCP tool call dispatcher case that validates input, calls the outlookManager handler, 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') }, ], }; }