Skip to main content
Glama
Racimy

iMail-mcp

check_config

Verify environment variables are correctly set for iMail-mcp server to retrieve mail from iCloud.

Instructions

Check if environment variables are properly configured

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler for the 'check_config' tool. Checks if ICLOUD_EMAIL and ICLOUD_APP_PASSWORD environment variables are set, masks their values for security, determines connection status, and returns the configuration status as JSON.
    case 'check_config': {
      const maskCredential = (value: string | undefined) => {
        if (!value) return 'Not set';
        if (value.length <= 4) return '***';
        return value.substring(0, 4) + '***';
      };
    
      const config = {
        email: {
          value: maskCredential(process.env.ICLOUD_EMAIL),
          configured: !!process.env.ICLOUD_EMAIL,
        },
        appPassword: {
          value: maskCredential(process.env.ICLOUD_APP_PASSWORD),
          configured: !!process.env.ICLOUD_APP_PASSWORD,
        },
        connectionStatus: mailClient ? 'Connected' : 'Not connected',
      };
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(config, null, 2),
          },
        ],
      };
    }
  • Input schema and metadata for the 'check_config' tool, defining it as taking no arguments.
    {
      name: 'check_config',
      description: 'Check if environment variables are properly configured',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • src/index.ts:54-383 (registration)
    Registers the 'check_config' tool by including it in the tools list returned by ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'get_messages',
            description: 'Get email messages from specified mailbox',
            inputSchema: {
              type: 'object',
              properties: {
                mailbox: {
                  type: 'string',
                  description: 'Mailbox name (default: INBOX)',
                  default: 'INBOX',
                },
                limit: {
                  type: 'number',
                  description: 'Maximum number of messages to retrieve',
                  default: 10,
                },
                unreadOnly: {
                  type: 'boolean',
                  description: 'Retrieve only unread messages',
                  default: false,
                },
              },
            },
          },
          {
            name: 'send_email',
            description: 'Send an email through iCloud Mail',
            inputSchema: {
              type: 'object',
              properties: {
                to: {
                  oneOf: [
                    { type: 'string' },
                    { type: 'array', items: { type: 'string' } },
                  ],
                  description: 'Recipient email address(es)',
                },
                subject: {
                  type: 'string',
                  description: 'Email subject',
                },
                text: {
                  type: 'string',
                  description: 'Plain text email body',
                },
                html: {
                  type: 'string',
                  description: 'HTML email body',
                },
              },
              required: ['to', 'subject'],
            },
          },
          {
            name: 'mark_as_read',
            description: 'Mark email messages as read',
            inputSchema: {
              type: 'object',
              properties: {
                messageIds: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Array of message IDs to mark as read',
                },
                mailbox: {
                  type: 'string',
                  description: 'Mailbox name (default: INBOX)',
                  default: 'INBOX',
                },
              },
              required: ['messageIds'],
            },
          },
          {
            name: 'get_mailboxes',
            description: 'List all available mailboxes',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'test_connection',
            description: 'Test the email server connection (IMAP and SMTP)',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'create_mailbox',
            description: 'Create a new mailbox (folder)',
            inputSchema: {
              type: 'object',
              properties: {
                name: {
                  type: 'string',
                  description: 'Name of the mailbox to create',
                },
              },
              required: ['name'],
            },
          },
          {
            name: 'delete_mailbox',
            description: 'Delete an existing mailbox (folder)',
            inputSchema: {
              type: 'object',
              properties: {
                name: {
                  type: 'string',
                  description: 'Name of the mailbox to delete',
                },
              },
              required: ['name'],
            },
          },
          {
            name: 'move_messages',
            description: 'Move messages between mailboxes',
            inputSchema: {
              type: 'object',
              properties: {
                messageIds: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Array of message IDs to move',
                },
                sourceMailbox: {
                  type: 'string',
                  description: 'Source mailbox name',
                },
                destinationMailbox: {
                  type: 'string',
                  description: 'Destination mailbox name',
                },
              },
              required: ['messageIds', 'sourceMailbox', 'destinationMailbox'],
            },
          },
          {
            name: 'search_messages',
            description: 'Search for messages using various criteria',
            inputSchema: {
              type: 'object',
              properties: {
                query: {
                  type: 'string',
                  description:
                    'Search query text (searches in subject, from, body)',
                },
                mailbox: {
                  type: 'string',
                  description: 'Mailbox name (default: INBOX)',
                  default: 'INBOX',
                },
                limit: {
                  type: 'number',
                  description: 'Maximum number of messages to retrieve',
                  default: 10,
                },
                dateFrom: {
                  type: 'string',
                  description: 'Start date for search (YYYY-MM-DD format)',
                },
                dateTo: {
                  type: 'string',
                  description: 'End date for search (YYYY-MM-DD format)',
                },
                fromEmail: {
                  type: 'string',
                  description: 'Filter by sender email address',
                },
                unreadOnly: {
                  type: 'boolean',
                  description: 'Search only unread messages',
                  default: false,
                },
              },
            },
          },
          {
            name: 'delete_messages',
            description: 'Delete messages from a mailbox',
            inputSchema: {
              type: 'object',
              properties: {
                messageIds: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Array of message IDs to delete',
                },
                mailbox: {
                  type: 'string',
                  description: 'Mailbox name (default: INBOX)',
                  default: 'INBOX',
                },
              },
              required: ['messageIds'],
            },
          },
          {
            name: 'set_flags',
            description: 'Set flags on messages (read, unread, flagged, etc.)',
            inputSchema: {
              type: 'object',
              properties: {
                messageIds: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Array of message IDs to set flags on',
                },
                flags: {
                  type: 'array',
                  items: { type: 'string' },
                  description:
                    'Array of flags to set (e.g., ["\\Seen", "\\Flagged"])',
                },
                mailbox: {
                  type: 'string',
                  description: 'Mailbox name (default: INBOX)',
                  default: 'INBOX',
                },
                action: {
                  type: 'string',
                  enum: ['add', 'remove'],
                  description: 'Whether to add or remove the flags (default: add)',
                  default: 'add',
                },
              },
              required: ['messageIds', 'flags'],
            },
          },
          {
            name: 'download_attachment',
            description: 'Download an attachment from a specific message',
            inputSchema: {
              type: 'object',
              properties: {
                messageId: {
                  type: 'string',
                  description: 'Message ID containing the attachment',
                },
                attachmentIndex: {
                  type: 'number',
                  description: 'Index of the attachment to download (0-based)',
                  default: 0,
                },
                mailbox: {
                  type: 'string',
                  description: 'Mailbox name (default: INBOX)',
                  default: 'INBOX',
                },
              },
              required: ['messageId'],
            },
          },
          {
            name: 'auto_organize',
            description:
              'Automatically organize emails based on rules (sender, subject keywords, etc.)',
            inputSchema: {
              type: 'object',
              properties: {
                rules: {
                  type: 'array',
                  items: {
                    type: 'object',
                    properties: {
                      name: {
                        type: 'string',
                        description: 'Rule name',
                      },
                      condition: {
                        type: 'object',
                        properties: {
                          fromContains: {
                            type: 'string',
                            description: 'Move emails if sender contains this text',
                          },
                          subjectContains: {
                            type: 'string',
                            description:
                              'Move emails if subject contains this text',
                          },
                        },
                      },
                      action: {
                        type: 'object',
                        properties: {
                          moveToMailbox: {
                            type: 'string',
                            description: 'Mailbox to move matching emails to',
                          },
                        },
                        required: ['moveToMailbox'],
                      },
                    },
                    required: ['name', 'condition', 'action'],
                  },
                  description: 'Array of organization rules',
                },
                sourceMailbox: {
                  type: 'string',
                  description: 'Source mailbox to organize (default: INBOX)',
                  default: 'INBOX',
                },
                dryRun: {
                  type: 'boolean',
                  description:
                    'If true, only shows what would be organized without moving emails',
                  default: false,
                },
              },
              required: ['rules'],
            },
          },
          {
            name: 'check_config',
            description: 'Check if environment variables are properly configured',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
        ],
      };

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