Skip to main content
Glama
atesahmet0

metu-webmail-mcp

by atesahmet0
README.md
# METU Webmail MCP Server ๐Ÿ“จ

A Model Context Protocol (MCP) server for **Middle East Technical University (METU / ODTรœ) Webmail** (`https://webmail.metu.edu.tr`).

Connect your AI assistants (Claude Desktop, Cursor, Antigravity, OpenCode, etc.) to your METU email account to list, search, read, send, reply to, flag, and organize emails securely using METU's official IMAP and SMTP servers.

---

## โœจ Features

- ๐Ÿ“ฅ **Inbox & Folder Management**: List all mailboxes (`INBOX`, `Sent`, `Drafts`, `Trash`, custom folders) and check unread message counts.
- ๐Ÿ” **Advanced Email Search**: Filter messages by keyword query, sender, recipient, subject, date ranges (`SINCE`, `BEFORE`), and read/flagged status.
- ๐Ÿ“– **Clean Content Reading**: Robust RFC2047 decoding for Turkish characters (UTF-8, ISO-8859-9, windows-1254), automatic HTML to clean Markdown conversion, and message threading metadata.
- ๐Ÿ“Ž **Attachment Support**: Inspect attachment metadata and download/extract file attachments.
- โœ‰๏ธ **Send, Reply & Forward**: Send new emails via SMTP (with automatic save to `Sent`), reply with automatic threading headers (`In-Reply-To`, `References`, `Re:` prefix), and forward messages.
- ๐Ÿท๏ธ **Flag & Organize**: Mark emails as read/unread or starred/flagged, and move or delete messages.
- ๐Ÿš€ **Dual Transport**: Supports standard MCP `stdio` mode and `sse` HTTP streaming mode.

---

## ๐Ÿ› ๏ธ Installation & Setup

### Prerequisites
- Python 3.11+
- [`uv`](https://docs.astral.sh/uv/) (recommended) or `pip`

### 1. Clone & Install Dependencies

```bash
cd /Users/ates/Documents/projects/metu-webmail-mcp
uv sync
```

### 2. Configure Credentials

Create a `.env` file in the project root:

```env
METU_USERNAME=e123456@metu.edu.tr
METU_PASSWORD=your_metu_password

# Optional configurations (defaults shown)
METU_IMAP_SERVER=imap.metu.edu.tr
METU_IMAP_PORT=993
METU_SMTP_SERVER=smtp.metu.edu.tr
METU_SMTP_PORT=587
```

> **Note**: Both `METU_USERNAME` / `METU_PASSWORD` and `SAIS_USERNAME` / `SAIS_PASSWORD` are automatically supported.

---

## ๐Ÿค– MCP Client Configuration

### Claude Desktop / Antigravity / Cursor

Add the following to your MCP client configuration (`claude_desktop_config.json` or equivalent):

```json
{
  "mcpServers": {
    "metu-webmail": {
      "command": "uv",
      "args": [
        "--directory",
        "/Users/ates/Documents/projects/metu-webmail-mcp",
        "run",
        "metu-webmail-mcp"
      ],
      "env": {
        "METU_USERNAME": "e123456@metu.edu.tr",
        "METU_PASSWORD": "your_password"
      }
    }
  }
}
```

---

## ๐Ÿงฐ Available Tools

| Tool | Description |
| :--- | :--- |
| `get_mailbox_status` | Returns overall account summary, email address, all folder metrics, and total unread count. |
| `list_folders` | Lists all mailbox folders with total and unread email counts. |
| `list_emails` | Lists recent emails from a folder (e.g. `INBOX`, `Sent`) with pagination (`limit`, `offset`) and preview snippets. |
| `search_emails` | Searches emails by text query, sender, recipient, subject, date ranges, unread only, or flagged only. |
| `read_email` | Reads full email content, decoded headers, markdown/html body, attachments list, and optionally marks as read. |
| `get_attachment` | Downloads/extracts attachment base64 content by filename or index. |
| `send_email` | Sends an email via METU SMTP with optional HTML body, CC, BCC, and file attachments. |
| `reply_email` | Replies to an existing email with automatic message threading and quoting. |
| `forward_email` | Forwards an existing email with optional comments to new recipients. |
| `mark_email` | Updates flags (read/unread, flagged/starred). |
| `move_email` | Moves an email from one folder to another. |
| `delete_email` | Moves an email to Trash or permanently deletes it. |

---

## ๐Ÿงช Testing

Run unit and integration tests:

```bash
uv run pytest -v
```

---

## ๐Ÿ“„ License

MIT License.

TDQS

B3.4/5.0

Scored across 12 tools

Disambiguation4/5

Each tool maps to a distinct email action (move, delete, read, send, reply, forward, search, mark, attachment). The only mild overlap is between list_folders and get_mailbox_status, which both return folder names and message counts, though their descriptions are slightly differentiated.

Naming Consistency5/5

All 12 tools follow a clean, consistent verb_noun snake_case pattern (list_emails, send_email, move_email, mark_email, etc.). No deviations in style or casing.

Tool Count5/5

12 tools is a well-scoped set for an email client, covering the core read/compose/organize workflow without redundancy or filler.

Completeness4/5

Strong lifecycle coverage: list, search, read, send, reply, forward, move, delete, flag, and attachments. Minor gaps exist (e.g., no create_folder/rename folder or draft-save operation), but core email workflows are fully supported.

Maintenance

ActivityMaintained
ResponsivenessNo issues