Skip to main content
Glama
sugar-crash-studios

Proton MCP Server

Search Emails

proton_search_emails
Read-onlyIdempotent

Search Proton Mail emails by sender, recipient, subject, date range, body content, or unread status using multiple criteria with AND logic.

Instructions

Search emails by sender, recipient, subject, date range, body content, or unread status. Multiple criteria are combined with AND logic.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoINBOX
fromNo
toNo
subjectNo
sinceNo
beforeNo
bodyNo
unseen_onlyNo
limitNo
offsetNo

Implementation Reference

  • The handler for 'proton_search_emails' processes the search criteria, calls the IMAP service to fetch messages, and formats the results into a markdown table.
      async (params: z.infer<typeof SearchEmailsSchema>) => {
        try {
          const criteria: SearchCriteria = {
            from: params.from,
            to: params.to,
            subject: params.subject,
            body: params.body,
            unseen: params.unseen_only,
          };
    
          // Parse ISO date strings to Date objects
          if (params.since) {
            criteria.since = new Date(params.since);
          }
          if (params.before) {
            criteria.before = new Date(params.before);
          }
    
          const messages = await searchMessages(params.folder, criteria, params.limit, params.offset);
    
          if (messages.length === 0) {
            return {
              content: [
                {
                  type: 'text',
                  text: 'No messages found matching the search criteria.',
                },
              ],
            };
          }
    
          // Format as markdown table
          let result = `**Folder:** ${params.folder}\n`;
          result += '**Search Criteria:**\n';
          if (params.from) result += `- From: ${params.from}\n`;
          if (params.to) result += `- To: ${params.to}\n`;
          if (params.subject) result += `- Subject: ${params.subject}\n`;
          if (params.body) result += `- Body contains: ${params.body}\n`;
          if (params.since) result += `- Since: ${params.since}\n`;
          if (params.before) result += `- Before: ${params.before}\n`;
          if (params.unseen_only) result += `- Unread only: yes\n`;
          result += `\n**Results:** ${messages.length} message(s)\n\n`;
    
          result += '| UID | From | Subject | Date | Read |\n';
          result += '|-----|------|---------|------|------|\n';
    
          for (const msg of messages) {
            const fromName = msg.from.name || msg.from.email;
            const subject = msg.subject.substring(0, 40);
            const date = msg.date.toISOString().split('T')[0];
            const readStatus = msg.seen ? '✓' : '✗';
    
            result += `| ${msg.uid} | ${fromName} | ${subject} | ${date} | ${readStatus} |\n`;
          }
    
          return {
            content: [
              {
                type: 'text',
                text: result,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error searching emails: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Registration of the 'proton_search_emails' tool with its schema and metadata.
    'proton_search_emails',
    {
      title: 'Search Emails',
      description: 'Search emails by sender, recipient, subject, date range, body content, or unread status. Multiple criteria are combined with AND logic.',
      inputSchema: SearchEmailsSchema,
      annotations: {
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false,
      },
    },
  • Input validation schema for 'proton_search_emails'.
    export const SearchEmailsSchema = z.object({
      folder: z.string().default('INBOX'),
      from: z.string().optional(),
      to: z.string().optional(),
      subject: z.string().optional(),
      since: z.string().datetime().optional(),
      before: z.string().datetime().optional(),
      body: z.string().optional(),
      unseen_only: z.boolean().default(false),
      limit: z.number().int().min(1).max(100).default(20),
      offset: z.number().int().min(0).default(0),
    });
Behavior4/5

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

Annotations already indicate read-only, non-destructive, and idempotent behavior, but the description adds valuable context by specifying that multiple criteria use AND logic, which isn't covered by annotations. No contradictions with annotations are present.

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

Conciseness5/5

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

The description is front-loaded with the core purpose and key behavioral detail (AND logic) in two concise sentences. Every sentence adds value without redundancy, making it efficient and easy to parse.

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

Completeness3/5

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

Given 10 parameters with 0% schema coverage and no output schema, the description provides basic search criteria but lacks details on parameter interactions, default behaviors, or result format. It's adequate for a read-only tool with good annotations but has gaps in parameter explanation.

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?

Schema description coverage is 0%, so the description carries the burden. It lists search criteria (sender, recipient, etc.) which map to parameters like 'from', 'to', but doesn't explain all 10 parameters (e.g., 'folder', 'limit', 'offset'). The description adds some meaning but doesn't fully compensate for the low coverage.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('Search emails') and resources ('emails'), listing multiple search criteria. It distinguishes from siblings like proton_list_emails by specifying filtering capabilities, not just listing.

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

Usage Guidelines3/5

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

The description implies usage for searching emails with specific criteria but doesn't explicitly state when to use this vs. alternatives like proton_list_emails (which might list without filtering) or proton_read_email (for viewing a single email). No exclusions or prerequisites are mentioned.

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/sugar-crash-studios/proton-mcp-server'

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