Skip to main content
Glama

search_sent_emails

Find sent emails in Outlook using search keywords to retrieve specific messages from your sent items folder.

Instructions

Search sent emails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch keywords
countNoNumber of results to return

Implementation Reference

  • Core handler function for search_sent_emails tool. Fetches a batch of recent sent emails, applies semantic search using EmailSummarizer, and returns top matching results.
    async searchSentEmails(query: string, count: number = 10): Promise<EmailMessage[]> {
      const emails = await this.getSentEmails(Math.min(count * 2, 50));
      const { EmailSummarizer } = await import('./email-summarizer.js');
      const searchResults = EmailSummarizer.searchEmails(emails, query);
      return searchResults.slice(0, count);
    }
  • Key helper method implementing case-insensitive full-text search across email subject, sender, and body (stripping HTML).
    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;
      });
    }
  • src/index.ts:587-605 (registration)
    MCP server dispatch handler for search_sent_emails tool calls, validating inputs and formatting response.
    case 'search_sent_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.searchSentEmails(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')
          },
        ],
      };
    }
  • Tool registration including name, description, and input schema (query: string required, count: number optional default 10).
    {
      name: "search_sent_emails",
      description: "Search sent emails",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search keywords"
          },
          count: {
            type: "number",
            description: "Number of results to return",
            default: 10
          }
        },
        required: ["query"]
      }
    },
  • Helper method to retrieve recent sent emails from Outlook Sent Items folder using PowerShell automation.
    async getSentEmails(count: number = 10): Promise<EmailMessage[]> {
      return this.getEmailsFromFolder(5, count, "[SentOn]"); // 5 = Sent Items
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does ('search') without any information about permissions needed, rate limits, pagination behavior, what fields are searched, or what the return format looks like. For a search tool with zero annotation coverage, this is completely inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While technically concise with just three words, this is a case of under-specification rather than effective conciseness. The description doesn't earn its place by providing meaningful guidance or context. It's too brief to be helpful, failing to convey necessary information about the tool's behavior or usage.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations, no output schema, and the presence of multiple similar sibling tools, the description is completely inadequate. It fails to explain what makes this tool distinct from other search and listing tools, doesn't describe the return format or behavior, and provides no context about limitations or appropriate usage scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with both parameters ('query' and 'count') well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Search sent emails' is a tautology that essentially restates the tool name. It does specify the verb 'search' and resource 'sent emails', but fails to distinguish this tool from sibling tools like 'search_draft_emails' or 'search_inbox_emails'. The purpose is minimally stated but lacks differentiation from similar tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There are multiple sibling search tools (search_draft_emails, search_inbox_emails) and listing tools (get_sent_emails) that serve similar purposes, but the description offers no context about when this specific search tool is appropriate versus those other options.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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