Skip to main content
Glama
TimeCyber

Email MCP Server

by TimeCyber

setup_email_account

Configure email accounts by automatically detecting provider settings or specifying them manually for integration with email services.

Instructions

设置邮箱账号(自动识别邮箱类型并配置服务器)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYes邮箱地址(如 user@qq.com)
passwordYes邮箱密码或授权码
providerNo邮箱提供商(可选,不填写则自动识别)

Implementation Reference

  • The main handler function that executes the setup_email_account tool. It sets EMAIL_USER and EMAIL_PASSWORD environment variables, detects the email provider if not specified, auto-configures server settings using EMAIL_CONFIGS, and returns a success message with configuration details or an error.
    async setupEmailAccount(args) {
      const { email, password, provider } = args;
    
      // 设置用户名和密码
      process.env.EMAIL_USER = email;
      process.env.EMAIL_PASSWORD = password;
    
      let detectedProvider = provider;
      let config;
    
      try {
        // 如果没有指定提供商,则自动检测
        if (!detectedProvider) {
          detectedProvider = this.detectEmailProvider(email);
          if (!detectedProvider) {
            return {
              content: [{
                type: 'text',
                text: `❌ 无法识别邮箱类型: ${email}\n\n支持的邮箱类型请使用 list_supported_providers 查看,或手动指定 provider 参数。`
              }]
            };
          }
        }
    
        // 自动配置服务器设置
        config = this.autoConfigureByProvider(detectedProvider);
    
        let result = `✅ 邮箱账号设置成功!\n\n`;
        result += `📧 邮箱地址: ${email}\n`;
        result += `🏢 邮箱提供商: ${config.name}\n`;
        result += `📤 SMTP服务器: ${config.smtp.host}:${config.smtp.port} (SSL: ${config.smtp.secure})\n`;
        result += `📥 接收协议: ${config.usePOP3 ? 'POP3' : 'IMAP'}\n`;
        
        if (config.usePOP3) {
          result += `📥 POP3服务器: ${config.pop3.host}:${config.pop3.port} (SSL: ${config.pop3.secure})\n`;
        } else {
          result += `📥 IMAP服务器: ${config.imap.host}:${config.imap.port} (SSL: ${config.imap.secure})\n`;
        }
    
        result += `\n💡 提示: 配置已自动完成,您现在可以使用邮件功能了!`;
    
        return {
          content: [{
            type: 'text',
            text: result
          }]
        };
    
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `❌ 邮箱设置失败: ${error.message}`
          }]
        };
      }
    }
  • index.js:247-269 (registration)
    Registers the 'setup_email_account' tool in the MCP server's listTools response, including name, description, and input schema definition.
    {
      name: 'setup_email_account',
      description: '设置邮箱账号(自动识别邮箱类型并配置服务器)',
      inputSchema: {
        type: 'object',
        properties: {
          email: {
            type: 'string',
            description: '邮箱地址(如 user@qq.com)'
          },
          password: {
            type: 'string',
            description: '邮箱密码或授权码'
          },
          provider: {
            type: 'string',
            enum: ['qq', '163', 'gmail', 'outlook', 'exmail', 'aliyun', 'sina', 'sohu'], // 暂时注释掉: 'netease-enterprise'
            description: '邮箱提供商(可选,不填写则自动识别)'
          }
        },
        required: ['email', 'password']
      }
    },
  • index.js:352-353 (registration)
    In the CallToolRequestSchema handler, dispatches calls to 'setup_email_account' to the setupEmailAccount method.
    case 'setup_email_account':
      return await this.setupEmailAccount(args);
  • Helper method to detect email provider from email domain or manual type, used by setupEmailAccount.
    detectEmailProvider(email, manualType = null) {
      // 优先使用手动指定的邮箱类型
      if (manualType && EMAIL_CONFIGS[manualType]) {
        console.log(`使用手动指定的邮箱类型: ${manualType} (${EMAIL_CONFIGS[manualType].name})`);
        return manualType;
      }
    
      // 如果没有手动指定,则根据域名自动检测
      const domain = email.split('@')[1]?.toLowerCase();
      if (!domain) return null;
      
      for (const [provider, config] of Object.entries(EMAIL_CONFIGS)) {
        if (config.domains.includes(domain)) {
          console.log(`自动检测到邮箱类型: ${provider} (${config.name})`);
          return provider;
        }
      }
      
      console.log(`未能识别邮箱类型,域名: ${domain}`);
      return null;
    }
  • Helper method that sets environment variables for email servers based on the detected provider, used by setupEmailAccount.
    autoConfigureByProvider(provider) {
      const config = EMAIL_CONFIGS[provider];
      if (!config) {
        throw new Error(`不支持的邮箱类型: ${provider}`);
      }
    
      // 设置SMTP配置
      process.env.EMAIL_SMTP_HOST = config.smtp.host;
      process.env.EMAIL_SMTP_PORT = config.smtp.port.toString();
      process.env.EMAIL_SMTP_SECURE = config.smtp.secure.toString();
    
      // 设置IMAP配置
      process.env.EMAIL_IMAP_HOST = config.imap.host;
      process.env.EMAIL_IMAP_PORT = config.imap.port.toString();
      process.env.EMAIL_IMAP_SECURE = config.imap.secure.toString();
    
      // 设置POP3配置
      process.env.EMAIL_POP3_HOST = config.pop3.host;
      process.env.EMAIL_POP3_PORT = config.pop3.port.toString();
      process.env.EMAIL_POP3_SECURE = config.pop3.secure.toString();
    
      // 设置协议偏好
      process.env.EMAIL_USE_POP3 = config.usePOP3.toString();
    
      return config;
    }
Behavior2/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. It mentions automatic provider detection and server configuration, but lacks critical details: whether this creates a new account or configures an existing one, what permissions are required, if it's a read-only or destructive operation, potential rate limits, or what happens on success/failure. For a tool with no annotations and potential account setup implications, this is a significant gap.

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 extremely concise and front-loaded: a single sentence in parentheses adds useful context about automatic detection. There's no wasted verbiage or redundancy, making it efficient for an agent to parse while conveying the core functionality.

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?

Given the complexity (account setup with 3 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like mutability, error handling, or return values, which are crucial for a tool that likely involves authentication and configuration. The description alone is insufficient for safe and effective use by an AI agent.

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 all parameters well-documented in the input schema (email, password, provider). The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain parameter interactions (e.g., how provider auto-detection works if omitted) or usage nuances. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't detract either.

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's purpose: '设置邮箱账号(自动识别邮箱类型并配置服务器)' translates to 'Set up email account (automatically identify email type and configure server).' It specifies the verb 'set up' and resource 'email account' with the additional functionality of automatic provider detection and server configuration. However, it doesn't explicitly differentiate from sibling tools like 'configure_email_server' or 'test_email_connection,' which prevents a perfect score.

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. It doesn't mention sibling tools like 'configure_email_server' (which might be for manual configuration) or 'test_email_connection' (which might be for verification). There's no indication of prerequisites, such as needing an existing account or specific permissions, leaving the agent with no context for tool selection.

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