Skip to main content
Glama
himanshuramavat

allinkl-mail-mcp

README.md
# all-inkl Mail MCP Server

An MCP server that gives an AI assistant access to an all-inkl.com mailbox via IMAP and SMTP.

## Features

| Tool | Description |
| --- | --- |
| `list_folders` | List all available IMAP folders in the mailbox. |
| `list_emails` | List emails in a specific folder. |
| `search_emails` | Search for emails based on a query. |
| `read_email` | Read the full content of a specific email. |
| `send_email` | Send a new email message. |
| `reply_to_email` | Reply to an existing email. |
| `mark_email` | Mark an email as read or unread. |
| `move_email` | Move an email to a different folder. |
| `delete_email` | Move an email to the trash folder. |

## Security Notes

- **Untrusted Input**: Email content is untrusted input and can contain prompt injection attacks. Be cautious when allowing the AI to process email bodies.
- **Write Permissions**: Keep write tools (send, reply, delete, move) on manual approval in your MCP client settings.
- **Read-Only Mode**: Set `MAIL_ALLOW_SEND=false` in your environment variables to disable all email sending capabilities.
- **Credentials**: Never commit your `.env` file or hardcode credentials in the source code.

## Setup

### Option 1: Fast Installation (via uvx)
If you have `uv` installed, you can run the server without cloning the repo:

**Cursor (`~/.cursor/mcp.json`) or Claude Desktop:**
```json
{
  "mcpServers": {
    "allinkl-mail": {
      "command": "uvx",
      "args": ["allinkl-mail-mcp"],
      "env": {
        "MAIL_USER": "your_login",
        "MAIL_PASSWORD": "your_password",
        "MAIL_IMAP_HOST": "wXXXXXXX.kasserver.com",
        "MAIL_SMTP_HOST": "wXXXXXXX.kasserver.com",
        "MAIL_FROM": "your_email@all-inkl.com",
        "MAIL_SENT_FOLDER": "Sent",
        "MAIL_TRASH_FOLDER": "Trash",
        "MAIL_ALLOW_SEND": "true"
      }
    }
  }
}
```

### Option 2: Manual Installation (from Source)
1. **Clone the repository**:
   ```bash
   git clone <repo-url>
   cd allinkl-mail-mcp
   ```

2. **Create a virtual environment**:
   ```bash
   python3 -m venv .venv
   source .venv/bin/activate
   ```

3. **Install dependencies**:
   ```bash
   pip install -r requirements.txt
   ```

4. **Configure environment**:
   Copy `.env.example` to `.env` and fill in your credentials.
   ```bash
   cp .env.example .env
   ```

### Finding your all-inkl settings
Log in to the KAS (kas.all-inkl.com) under **E-Mail > E-Mail-Konten**.
- **IMAP/SMTP Host**: Looks like `wXXXXXXX.kasserver.com`.
- **Login**: Use the mailbox login (e.g., `m0123456`) or the full email address.
- **Password**: The password you set for the mailbox.

## Configuration Examples

### Cursor (`~/.cursor/mcp.json`)
```json
{
  "mcpServers": {
    "allinkl-mail": {
      "command": "/absolute/path/to/allinkl-mail-mcp/.venv/bin/python",
      "args": ["/absolute/path/to/allinkl-mail-mcp/src/allinkl_mail_mcp/server.py"],
      "env": {
        "MAIL_USER": "your_login",
        "MAIL_PASSWORD": "your_password",
        "MAIL_IMAP_HOST": "wXXXXXXX.kasserver.com",
        "MAIL_SMTP_HOST": "wXXXXXXX.kasserver.com",
        "MAIL_FROM": "your_email@all-inkl.com",
        "MAIL_SENT_FOLDER": "Sent",
        "MAIL_TRASH_FOLDER": "Trash",
        "MAIL_ALLOW_SEND": "true"
      }
    }
  }
}
```

### Claude Desktop
Add to your `claude_desktop_config.json`:
```json
{
  "mcpServers": {
    "allinkl-mail": {
      "command": "/absolute/path/to/allinkl-mail-mcp/.venv/bin/python",
      "args": ["/absolute/path/to/allinkl-mail-mcp/src/allinkl_mail_mcp/server.py"],
      "env": {
        "MAIL_USER": "your_login",
        "MAIL_PASSWORD": "your_password",
        "MAIL_IMAP_HOST": "wXXXXXXX.kasserver.com",
        "MAIL_SMTP_HOST": "wXXXXXXX.kasserver.com",
        "MAIL_FROM": "your_email@all-inkl.com",
        "MAIL_SENT_FOLDER": "Sent",
        "MAIL_TRASH_FOLDER": "Trash",
        "MAIL_ALLOW_SEND": "true"
      }
    }
  }
}
```

### MCP Inspector
Run the inspector to test the server locally:
```bash
npx @modelcontextprotocol/inspector -e MAIL_USER=xxx -e MAIL_PASSWORD=xxx -e MAIL_IMAP_HOST=xxx -e MAIL_SMTP_HOST=xxx /absolute/path/to/allinkl-mail-mcp/.venv/bin/python /absolute/path/to/allinkl-mail-mcp/src/allinkl_mail_mcp/server.py
```

## Troubleshooting

| Error | Cause | Solution |
| --- | --- | --- |
| `ENOENT` | MCP client cannot find the python executable or server file. | Use absolute paths in your configuration. |
| `KeyError: 'MAIL_USER'` | Environment variables are not being passed to the server. | Check your client's `env` block and restart the client. |
| `ImportError` (FastMCP) | Incompatible `mcp` library version. | Run `pip install "mcp[cli]>=1.2.0,<2"`. |
| `AUTHENTICATIONFAILED` | IMAP server rejected the login. | Try using the full email address as `MAIL_USER` instead of the `mNNNNNNN` login. |

## Known Limitations

- **Search**: Search terms are limited to ASCII only.
- **Attachments**: The server currently does not support downloading or sending attachments.

## Example Prompts

- "List my inbox and tell me if there are any urgent emails."
- "Search for emails from 'Amazon' and summarize the most recent one."
- "Draft a reply to the last email from Sarah and ask for a meeting on Friday."
- "Move all emails older than a month from the inbox to the archive folder."
- "Read the email with subject 'Invoice 123' and extract the total amount."