# Gmail POP3 MCP Server

An MCP server that provides tools for reading and deleting emails from a single Gmail account via POP3.

## Setup

1. Enable POP3 in your Gmail account settings.
2. Create an App Password in your Google Account security settings.
3. Create a `.env` file in the same directory as `docker-compose.yml` with the following variables:

```env
GMAIL_ADDRESS=your.email@gmail.com
GMAIL_APP_PASSWORD=your_app_password_here
# Optional: Change the POP3 server/port if you are not using standard Gmail settings
# EMAIL_HOST=pop.gmail.com
# EMAIL_PORT=995
```

## Running the Server

### Using Docker Compose

```bash
docker-compose up -d
```

### Building and Running Manually with Docker

If you prefer to build the image yourself without Docker Compose:

```bash
# Build the image
docker build -t pop3_gmail_mcp .

# Run the container
docker run -d --name mcp-gmail-client \
  --env-file .env \
  -p 9087:8087 \
  pop3_gmail_mcp
```

### Running Locally

```bash
pip install -r requirements.txt
python main.py run-mcp-server --port 8087
```

## Configuration in Claude Desktop or Cursor

Add this to your `claude_desktop_config.json` or equivalent:

```json
{
  "mcpServers": {
    "gmail_client": {
      "command": "docker",
      "args": ["exec", "-i", "mcp-gmail-client-1", "python", "main.py", "run-mcp-server"]
    }
  }
}
```

(Note: Ensure the container name `mcp-gmail-client-1` matches your actual running container).

## Available Tools

- `get_emails(after_datetime, limit)`: Retrieves recent emails.
- `get_email(email_id)`: Retrieves the full content of a specific email.
- `delete_email(email_id)`: Deletes a specific email.
- `email_read_and_delete(after_datetime)`: Reads and deletes the most recent email.
- `read_and_delete_recent_email(period_in_seconds)`: Reads and deletes the most recent email received within the specified number of seconds.