Skip to main content
Glama
ggiraudon

Email MCP Server

by ggiraudon

search

Find emails in a specified folder using criteria like sender, recipient, subject, date range, and message status to locate specific messages.

Instructions

Searches for messages in the specified folder matching the parameters set in searchOptions. Available search options are: from, to, subject, since, before, unseen, flagged, answered, custom. It returns a list of ids that can then be used to get individual messages based on their id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderYes
fromNo
toNo
subjectNo
sinceNo
beforeNo

Implementation Reference

  • The async execute function that implements the core logic of the 'search' tool: validates input, parses search options, connects to IMAP, performs the search via controller, and returns message IDs as JSON.
    async execute(args, context) {
      if (!args || typeof args !== 'object' || !('folder' in args)) {
        throw new Error("Missing required arguments");
      }
      const searchOptions = MailSearchOptionSchema.parse(args);
      const controller = ImapControllerFactory.getInstance();
      await controller.connect();
      const ids = await controller.search(args.folder, searchOptions);
      return JSON.stringify({ ids });
    }
  • Zod schema defining the input parameters for the 'search' tool (used as parameters in Tool object). Note: some options are commented out here but handled via internal schema.
    export const SearchInput = z.object({
      folder: z.string().min(2).max(100),
      from: z.string().optional(),
      to: z.string().optional(),
      subject: z.string().optional(),
      since: z.coerce.date().optional(),
      before: z.coerce.date().optional(),
    //  unseen: z.boolean().optional(),
    //  flagged: z.boolean().optional(),
    //  answered: z.boolean().optional(),
    });
  • Internal Zod schema used in the handler to parse full search options, including additional flags like unseen, flagged, answered, and custom.
    export const MailSearchOptionSchema = z.object({
        from: z.string().optional(),
        to: z.string().optional(),
        subject: z.string().optional(),
        since: z.coerce.date().optional(),
        before: z.coerce.date().optional(),
        unseen: z.boolean().optional(),
        flagged: z.boolean().optional(),
        answered: z.boolean().optional(),
        custom: z.any().optional(),
    });
  • src/index.ts:54-54 (registration)
    Registration of the SearchFolderTool (named 'search') with the FastMCP server.
    server.addTool(SearchFolderTool);
  • src/index.ts:14-14 (registration)
    Import of the SearchFolderTool in the main index file.
    import { SearchFolderTool } from "./tools/SearchFolderTool.js";
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool returns a list of IDs for later use, which is helpful, but lacks critical details like whether this is a read-only operation, potential rate limits, authentication needs, error conditions, or pagination behavior for large result sets.

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

Conciseness4/5

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

The description is appropriately concise with two sentences that efficiently convey the core functionality and output usage. It's front-loaded with the main purpose, though the list of search options could be slightly more structured.

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

Completeness2/5

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

For a search tool with 6 parameters, 0% schema coverage, no annotations, and no output schema, the description is insufficient. It doesn't explain parameter interactions, result format beyond 'list of ids', error handling, or limitations. The mismatch between described parameters and schema parameters further reduces completeness.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It lists available search options (from, to, subject, since, before, unseen, flagged, answered, custom), which covers more parameters than the schema shows (6 vs 9 mentioned), but doesn't explain their semantics, formats, or how they combine. The mismatch between described and schema parameters creates confusion.

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

Purpose4/5

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

The description clearly states the tool searches for messages in a specified folder using search parameters, which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like getMessageList, which might also retrieve messages but without search capabilities.

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 through the mention of 'searchOptions' and returning IDs for further message retrieval, suggesting this is for filtered searches rather than bulk listing. However, it doesn't explicitly state when to use this versus alternatives like getMessageList or getFolderList, nor does it mention prerequisites or exclusions.

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/ggiraudon/emailMCPServer'

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