# gmail-attachments-mcp [Health: Active]

**Category:** 💬 Communication  
**Repository:** https://github.com/zayansalman/gmail-attachments-mcp  
**GitHub Stars:** 4  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/gmail-attachments-mcp

## Description
Minimal MCP server for downloading Gmail attachments to disk. Read-only OAuth by default.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "gmail-attachments-mcp": {
    "command": "uvx",
    "args": ["gmail-attachments-mcp"],
    "env": {
      "GMAIL_MCP_CREDENTIALS": "",
      "GMAIL_MCP_TOKEN": "",
      "GMAIL_MCP_DEFAULT_DEST_DIR": "",
      "GMAIL_MCP_SCOPES": "",
      "XDG_CONFIG_HOME": ""
    }
  }
}
```

**Requires environment variables:** `GMAIL_MCP_CREDENTIALS`, `GMAIL_MCP_TOKEN`, `GMAIL_MCP_DEFAULT_DEST_DIR`, `GMAIL_MCP_SCOPES`, `XDG_CONFIG_HOME` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What gmail-attachments-mcp MCP server does

gmail-attachments-mcp MCP server connects an MCP client to a user-owned Gmail account and writes matching attachments to disk. Its API is intentionally limited to three operations: searching messages, downloading all attachments from a known thread, and downloading attachments from the newest search result.

The server requests the `gmail.readonly` scope by default. It can read Gmail data needed for search and downloads, but its default authorization cannot send messages, delete mail, or modify mailbox content. This makes it suitable for workflows such as collecting invoices, resumes, reports, or other files already received in Gmail.

A standalone command-line interface exposes the same functionality. The CLI can be used directly from a shell or scheduled with cron, so an MCP client is not required for automated downloads.

## How it works

After installation, the operator creates a Google Cloud project, enables the Gmail API, configures an OAuth consent screen, and creates a Desktop OAuth client. The setup command opens a browser for consent and saves a refresh token locally. Later invocations use that cached token, allowing headless commands and scheduled jobs after the initial authorization.

The `gmail_search` tool accepts Gmail's standard query syntax and returns thread summaries, including subjects, senders, dates, snippets, message counts, attachment counts, and attachment filenames. `gmail_download_thread_attachments` takes a thread ID and saves every attachment in that thread. `gmail_download_latest_matching` combines a search with a download for the single most recent match. Download operations can receive a destination directory and file-extension filters.

The server runs on the local machine. The OAuth client and token belong to the operator, and the documented design does not use a central service or telemetry.

## Setup and configuration

Install the package with `pip install gmail-attachments-mcp` or `uv tool install gmail-attachments-mcp`. Import the downloaded Google OAuth client JSON with `gmail-attachments-mcp setup --import-credentials <file>`, then verify authorization with `gmail-attachments-mcp status` or a test search.

Configuration is environment-driven. `GMAIL_MCP_CREDENTIALS` selects the OAuth client secret file, `GMAIL_MCP_TOKEN` selects the cached token, and `GMAIL_MCP_DEFAULT_DEST_DIR` changes the default download directory from `~/Downloads`. `GMAIL_MCP_SCOPES` can replace the default scope with a comma-separated value, while `XDG_CONFIG_HOME` changes the base configuration directory. Changing scopes requires reauthorization.

The default token location is `~/.config/gmail-attachments-mcp/token.json`, or the corresponding directory under `XDG_CONFIG_HOME`. The token is stored with mode `0600`; anyone with shell access to the account may be able to read Gmail through it. Keep both the token and OAuth configuration files out of source control.

## Tools and capabilities

The gmail-attachments-mcp MCP server provides:

- `gmail_search(query, max_results=10)`: finds matching Gmail threads and reports attachment metadata.
- `gmail_download_thread_attachments(thread_id, dest_dir?, extensions?)`: downloads every attachment in a selected thread and reports each file's path, byte size, MIME type, and original filename.
- `gmail_download_latest_matching(query, dest_dir?, extensions?)`: searches Gmail and downloads attachments from the newest matching thread.

The same actions are available as CLI commands: `search`, `thread`, and `latest`. This supports interactive use, shell scripts, and cron jobs. MCP configuration points clients at the `gmail-attachments-mcp serve` command over stdio.

## Limitations and notes

The toolset covers attachment retrieval rather than general mailbox management. It does not provide operations for sending mail, deleting messages, editing labels, or managing drafts. The default authorization is read-only, although changing `GMAIL_MCP_SCOPES` changes the security implications and requires the operator to manage those consequences.

Initial OAuth setup needs a browser. If a headless client reports that no valid token exists, authorize once from a terminal with browser access. Personal Gmail accounts must add the account as an OAuth test user; Google Workspace users can use an Internal consent-screen audience. Revoked or expired authorization can be renewed with `gmail-attachments-mcp setup --reauth`.

The project requires the user's own Google Cloud OAuth client rather than a shared API key or bundled secret. It is therefore a fit for developers who can complete Google Cloud configuration and want local control of Gmail credentials and downloaded files.

_Full upstream README: https://allmcps.com/mcp/gmail-attachments-mcp/readme_

