Skip to main content
Glama
TimeCyber

Email MCP Server

by TimeCyber

get_email_content

Retrieve detailed content from specific emails by providing their unique identifier to access full message information.

Instructions

获取指定邮件的详细内容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYes邮件唯一标识符

Implementation Reference

  • The core handler function that connects to IMAP, fetches the email by UID, parses it using simpleParser, and formats the content including headers, text/HTML body, and attachments list.
    async getEmailContent(args) {
      const { uid } = args;
    
      return new Promise((resolve, reject) => {
        const imap = this.createIMAPConnection();
    
        imap.once('ready', () => {
          imap.openBox('INBOX', true, (err, box) => {
            if (err) {
              imap.end();
              return reject(err);
            }
    
            // 获取指定UID的邮件
            const fetch = imap.fetch([uid], {
              bodies: '',
              struct: true
            });
    
            fetch.on('message', (msg, seqno) => {
              msg.on('body', (stream, info) => {
                simpleParser(stream, (err, parsed) => {
                  imap.end();
                  
                  if (err) {
                    return reject(err);
                  }
    
                  let content = `📧 邮件详情 (UID: ${uid})\n`;
                  content += `────────────────────────────────\n`;
                  content += `📅 日期: ${parsed.date || '未知'}\n`;
                  content += `👤 发件人: ${parsed.from?.text || '未知'}\n`;
                  content += `👥 收件人: ${parsed.to?.text || '未知'}\n`;
                  
                  if (parsed.cc) {
                    content += `📋 抄送: ${parsed.cc.text}\n`;
                  }
                  
                  content += `📝 主题: ${parsed.subject || '(无主题)'}\n`;
                  content += `────────────────────────────────\n`;
                  
                  // 邮件内容
                  if (parsed.text) {
                    content += `📄 文本内容:\n${parsed.text}\n`;
                  }
                  
                  if (parsed.html && parsed.html !== parsed.text) {
                    content += `🌐 HTML内容:\n${parsed.html}\n`;
                  }
    
                  // 附件信息
                  if (parsed.attachments && parsed.attachments.length > 0) {
                    content += `📎 附件列表:\n`;
                    parsed.attachments.forEach((att, index) => {
                      content += `  ${index + 1}. ${att.filename || '未命名'} (${att.size || 0} bytes)\n`;
                    });
                  }
    
                  resolve({
                    content: [{
                      type: 'text',
                      text: content
                    }]
                  });
                });
              });
            });
    
            fetch.once('error', (err) => {
              imap.end();
              reject(err);
            });
          });
        });
    
        imap.once('error', (err) => {
          reject(err);
        });
    
        imap.connect();
      });
    }
  • The tool registration object defining the name, description, and input schema (requiring 'uid' string parameter).
    name: 'get_email_content',
    description: '获取指定邮件的详细内容',
    inputSchema: {
      type: 'object',
      properties: {
        uid: {
          type: 'string',
          description: '邮件唯一标识符'
        }
      },
      required: ['uid']
    }
  • index.js:341-373 (registration)
    The request handler registration with switch case that dispatches 'get_email_content' calls to the handler function.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        switch (name) {
          case 'send_email':
            return await this.sendEmail(args);
          case 'get_recent_emails':
            return await this.getRecentEmails(args);
          case 'get_email_content':
            return await this.getEmailContent(args);
          case 'setup_email_account':
            return await this.setupEmailAccount(args);
          case 'list_supported_providers':
            return await this.listSupportedProviders(args);
          case 'configure_email_server':
            return await this.configureEmailServer(args);
          case 'test_email_connection':
            return await this.testConnection(args);
          default:
            throw new Error(`未知的工具: ${name}`);
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `错误: ${error.message}`
            }
          ]
        };
      }
    });
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While '获取' (get) implies a read operation, the description doesn't specify whether this requires authentication, what format the content returns (HTML, plain text, attachments), whether there are rate limits, or what happens with invalid UIDs. For a tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 a single, efficient Chinese sentence that directly states the tool's function. There's zero wasted text - every character contributes to understanding what the tool does. It's appropriately sized for a simple retrieval tool with one parameter.

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 tool with no annotations and no output schema, the description is insufficiently complete. While the purpose is clear, there's no information about return format (headers, body, attachments), error conditions, authentication requirements, or how this differs from sibling email tools. The agent would need to guess about important behavioral aspects.

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 100% with the single parameter 'uid' documented as '邮件唯一标识符' (email unique identifier). The description adds no additional parameter information beyond what the schema provides. With high schema coverage and only one parameter, the baseline score of 3 is appropriate - the schema does the heavy lifting.

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

Purpose3/5

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

The description '获取指定邮件的详细内容' (Get detailed content of specified email) clearly states the tool's purpose with a specific verb ('获取' - get) and resource ('邮件详细内容' - email detailed content). However, it doesn't distinguish this tool from potential sibling tools like 'get_recent_emails' - both appear to retrieve email content, just with different scopes (specified vs recent).

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

Usage Guidelines2/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. With sibling tools like 'get_recent_emails' and 'send_email' available, there's no indication whether this tool is for retrieving full content of a specific known email versus browsing recent emails or composing new ones. The agent must infer usage from the tool name alone.

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/TimeCyber/email-mcp'

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