Skip to main content
Glama
Racimy

iMail-mcp

test_connection

Verify IMAP and SMTP server connectivity to ensure email services are properly configured and accessible.

Instructions

Test the email server connection (IMAP and SMTP)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler for the test_connection tool in the MCP server request handler. Validates mailClient existence and delegates to mailClient.testConnection(), returning the result as JSON text.
    case 'test_connection': {
      if (!mailClient) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          'iCloud Mail not configured. Please set ICLOUD_EMAIL and ICLOUD_APP_PASSWORD environment variables.'
        );
      }
    
      const result = await mailClient.testConnection();
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Core implementation of testConnection method in ICloudMailClient class. Tests IMAP (connect/disconnect) and SMTP (verify with timeout), provides detailed success/error responses with troubleshooting tips.
    async testConnection(): Promise<{ status: string; message: string }> {
      try {
        console.error('Testing IMAP connection...');
        await this.connect();
        console.error('IMAP connection successful, disconnecting...');
        await this.disconnect();
    
        console.error('Testing SMTP connection...');
        // Test SMTP connection with timeout
        await Promise.race([
          this.transporter.verify(),
          new Promise((_, reject) =>
            setTimeout(
              () =>
                reject(new Error('SMTP verification timeout after 30 seconds')),
              30000
            )
          ),
        ]);
    
        console.error('SMTP connection successful');
    
        return {
          status: 'success',
          message:
            'Email connection test successful - both IMAP and SMTP are working',
        };
      } catch (error) {
        const errorMessage =
          error instanceof Error ? error.message : String(error);
        console.error('Connection test failed:', errorMessage);
    
        // Provide helpful error messages based on common issues
        let helpfulMessage = errorMessage;
        if (
          errorMessage.includes('authenticate') ||
          errorMessage.includes('Invalid credentials')
        ) {
          helpfulMessage +=
            "\n\nTroubleshooting:\n1. Ensure you're using an app-specific password, not your regular Apple ID password\n2. Verify that two-factor authentication is enabled on your Apple ID\n3. Generate a new app-specific password if the current one isn't working\n4. Check that your Apple ID hasn't been locked";
        } else if (
          errorMessage.includes('timeout') ||
          errorMessage.includes('ENOTFOUND') ||
          errorMessage.includes('ECONNREFUSED')
        ) {
          helpfulMessage +=
            '\n\nTroubleshooting:\n1. Check your internet connection\n2. Verify firewall settings allow connections to iCloud mail servers\n3. Try connecting from a different network';
        }
    
        return {
          status: 'error',
          message: helpfulMessage,
        };
      }
    }
  • src/index.ts:139-145 (registration)
    Registration of the test_connection tool in the MCP tools list, with description and empty input schema (no parameters required).
      name: 'test_connection',
      description: 'Test the email server connection (IMAP and SMTP)',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
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 states the action ('Test') but doesn't reveal critical traits: whether this is a read-only diagnostic, if it requires authentication, potential side effects (e.g., network traffic), error handling, or output format. This is inadequate for a tool with zero annotation coverage.

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 sentence with zero waste. It's front-loaded with the core purpose and includes relevant technical details (IMAP and SMTP) without fluff, making it easy for an agent to parse quickly.

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 of testing server connections, the description is incomplete. With no annotations and no output schema, it fails to explain what the test entails, what results to expect (e.g., success/failure indicators), or behavioral aspects like timeouts or retries. This leaves significant gaps for an agent to use the tool effectively.

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

Parameters4/5

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

The tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description doesn't add param info, but that's unnecessary here. A baseline of 4 is appropriate as it avoids redundancy while the schema fully handles the lack of parameters.

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: 'Test the email server connection (IMAP and SMTP).' It specifies the verb ('Test') and the resource ('email server connection'), with additional detail about the protocols involved. However, it doesn't explicitly differentiate from sibling tools like 'check_config', which might have overlapping functionality, preventing a score of 5.

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 prerequisites (e.g., after configuration changes), exclusions, or comparisons to siblings like 'check_config', leaving the agent with minimal context for decision-making.

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/Racimy/iMail-mcp'

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