Skip to main content
Glama
savestidolajr

gmail-attachments-mcp

gmail-attachments-mcp

Give your AI agent the ability to open Gmail attachments.

Most Gmail integrations let an agent search and read email bodies but stop at the attachment. This MCP server fills that gap. Your agent can list what is attached to a message, read PDFs, Word, Excel and PowerPoint files straight into its context, or save any attachment to disk. Read-only (gmail.readonly), runs locally on your machine.

Works with any MCP client: Claude Code, Claude Desktop, Cursor, and others.

What your agent can do with it

  • "Summarise the PDF the recruiter sent me."

  • "Read the invoice attached to that Anthropic email and check the totals match the email body."

  • "Pull the job description from the latest email and compare it to my CV."

  • "Download the spreadsheet from Sam's email and total column C."

  • "List every attachment in that thread."

Pair it with a Gmail connector: the connector finds the message and gives the message_id, this server opens the attachments.

Related MCP server: Gmail AutoAuth MCP Server

Tools

  • list_attachments(message_id): name, type, size

  • download_attachment(message_id, filename, dest_dir="", index=0): saves to ~/Downloads/gmail-attachments by default, never overwrites

  • read_attachment_text(message_id, filename, index=0, max_chars=20000): extracts text without saving the file. Supported types:

    • PDF (text-based; scanned PDFs return a hint to download instead)

    • Word .docx (paragraphs and tables)

    • Excel .xlsx (every sheet, rows joined with |)

    • PowerPoint .pptx (text per slide)

    • Plain text: .txt, .csv, .json, .xml, .html, .md

    • Anything else (images, zip, legacy .doc / .xls / .ppt): use download_attachment, then open the file yourself.

message_id is the same id the Gmail connector returns from search_threads / get_message.

One-time setup

  1. Google Cloud Console: create a project, enable the Gmail API.

  2. OAuth consent screen: External, add your Gmail as a test user.

  3. Credentials: create an OAuth client ID, type Desktop app. Download the JSON.

  4. Save it as ~/.config/gmail-attachments-mcp/credentials.json (outside the repo).

  5. Authorise once (opens a browser):

    uv run gmail-attachments-auth

    Token is saved to ~/.config/gmail-attachments-mcp/token.json (mode 600).

Install in your agent

Clone the repo first (needs uv):

git clone https://github.com/savestidolajr/gmail-attachments-mcp

Claude Code

claude mcp add gmail-attachments --scope user -- uv run --directory /absolute/path/to/gmail-attachments-mcp gmail-attachments-mcp

Claude Desktop, Cursor and other MCP clients: add this to the client's MCP config (claude_desktop_config.json for Claude Desktop):

{
  "mcpServers": {
    "gmail-attachments": {
      "command": "uv",
      "args": ["run", "--directory", "/absolute/path/to/gmail-attachments-mcp", "gmail-attachments-mcp"]
    }
  }
}

Restart the client, then ask it to list the attachments on any email.

Host it on Vercel (use from any device)

The local server only works on the machine it runs on. Hosted mode runs the same tools over streamable HTTP, protected by a bearer token, as a Vercel Python service. It has no download_attachment (no persistent disk) and takes credentials from env vars instead of token.json. app.py exposes the ASGI app, vercel.json declares it as a service and routes everything to it. The MCP session runs per request (stateless, JSON responses), so it does not depend on lifespan events.

  1. Do the one-time Google setup and uv run gmail-attachments-auth locally.

  2. npm i -g vercel, then vercel login.

  3. ./scripts/vercel-setup.sh links the project and sets the four env vars from your local OAuth files, piped straight to Vercel. It prints the generated MCP_AUTH_TOKEN once. Save it.

  4. vercel deploy --prod

  5. Connect your client to https://<your-project>.vercel.app/mcp. For Claude Code:

    claude mcp add --transport http gmail-attachments https://<your-project>.vercel.app/mcp --header "Authorization: Bearer <MCP_AUTH_TOKEN>"

To rotate the token later and re-register it in Claude Code in one step, with the token never printed: ./scripts/rotate-and-register.sh.

Caveats: the default function time limit applies to large attachments, cold starts import the Google and Office libraries, and Vercel's deployment protection may block the URL until you disable it for this project. Security: anyone with the bearer token can read attachments in the Gmail account. Keep the token secret, keep the scope read-only, rotate MCP_AUTH_TOKEN if it leaks, and host it for yourself only, never as a shared service holding other people's Gmail tokens. Without a token of 32+ characters the server rejects every request. /health is the only unauthenticated route.

Env vars

  • GMAIL_ATT_CONFIG_DIR: where credentials/token live

  • GMAIL_ATT_CLIENT_FILE: path to the OAuth client JSON

  • GMAIL_ATT_DOWNLOAD_DIR: default download folder

  • Hosted mode only: GMAIL_ATT_CLIENT_ID, GMAIL_ATT_CLIENT_SECRET, GMAIL_ATT_REFRESH_TOKEN, MCP_AUTH_TOKEN (set by scripts/vercel-setup.sh)

Notes

  • While the OAuth app is in "Testing", Google expires the refresh token after 7 days. Re-run the auth command, or publish the app to "In production" (no verification needed for personal use of a single account).

  • Never commit credentials.json or token.json. .gitignore covers both.

Privacy

Runs locally. Uses only the read-only Gmail scope. Your OAuth client and token stay on your machine in ~/.config/gmail-attachments-mcp/. Each user must create their own Google Cloud OAuth client.

Licence

MIT

Available Tools

3 tools
download_attachmentA

Save one attachment to disk and return the file path.

filename: exact name from list_attachments. index: pick among duplicate names.
dest_dir: folder to save into (default ~/Downloads/gmail-attachments).
Existing files are never overwritten; a numeric suffix is added.
ParametersJSON Schema
NameRequiredDescriptionDefault
indexNo
dest_dirNo
filenameYes
message_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden, and it does add real value: existing files are never overwritten and a numeric suffix is added on collision. It does not cover error behavior (missing attachment, bad index), permissions/auth needs, or any rate limits, so significant disclosure gaps remain.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The primary action is front-loaded in the first sentence, then parameters follow in tight, labeled lines. Every sentence carries information (workflow source, disambiguation, default path, overwrite policy) with no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so the return value need not be elaborated beyond the stated file path. For a 4-parameter, no-annotation tool the description covers the practically important behavior, with the only clear hole being message_id semantics and error handling.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description is the only source of parameter meaning. It documents filename (exact name from list_attachments), index (duplicate disambiguation), and dest_dir (default and purpose), which is genuinely useful, but the required message_id parameter is never explained in the description or schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Save one attachment to disk and return the file path') and makes the single-attachment scope explicit. The disk-saving framing implicitly separates it from read_attachment_text, and it names list_attachments as the filename source, so an agent can place it correctly among siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

'filename: exact name from list_attachments' and 'index: pick among duplicate names' establish the intended call sequence and the disambiguation case for duplicates. It gives clear context for how to invoke but never states when NOT to use this tool or when read_attachment_text is preferable.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_attachmentsA

List attachments on a Gmail message (name, type, size in bytes).

message_id is the Gmail message id, e.g. from the Gmail connector's search_threads.
ParametersJSON Schema
NameRequiredDescriptionDefault
message_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that this is a listing operation returning name/type/size, and where to get the message_id, which implies a safe read. It does not state permissions, whether attachments are downloaded, or any limits — gaps for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences, front-loaded with the purpose and followed only by the one piece of parameter context an agent needs. Nothing is wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the description need not explain return values, and a single-parameter read tool is simple. It covers purpose and parameter provenance adequately; only permission/behavior nuance is absent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must define the sole parameter, and it does: message_id is the Gmail message id, with a concrete provenance hint (search_threads). That compensates well for the otherwise bare schema, though no format example of the id itself is given.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb+resource ('List attachments on a Gmail message') and even enumerates the returned fields (name, type, size in bytes). It is clearly distinguishable from the download/read siblings, though it never names them explicitly. Clear purpose, but no direct sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit when-to-use vs alternatives statement, but the note that message_id comes 'from the Gmail connector's search_threads' implies the required upstream workflow. That is useful implied guidance rather than stated guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_attachment_textA

Return the text of an attachment without saving it.

Supports PDF, docx, xlsx, pptx, and text files (txt, csv, json, xml, html, md).
Other types (images, zip, doc, xls, ppt): use download_attachment (local server only).
ParametersJSON Schema
NameRequiredDescriptionDefault
indexNo
filenameYes
max_charsNo
message_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden and discloses the key behavioral trait: it reads text without persisting ('without saving it'), and it flags the cross-tool constraint that download_attachment only works on a local server. It does not say what happens when an unsupported type is passed (error vs. empty), which is the main remaining gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences, front-loaded with the action and scope, then the format rules and the fallback tool. Zero filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be explained, and sibling routing is handled well. However, with no annotations and zero parameter documentation, an agent still lacks guidance on index/max_chars semantics and error behavior for unsupported types.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and all four parameters (message_id, filename, index, max_chars) are undocumented in both schema and description. The format list loosely relates to filename, but index and the 20000 default for max_chars are never explained, so the description does not compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Return the text of an attachment') plus a distinguishing trait ('without saving it') that separates it from download_attachment. An agent can tell exactly what this does versus its siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly lists supported formats (PDF, docx, xlsx, pptx, txt, csv, json, xml, html, md) and names the alternative for unsupported types: 'use download_attachment (local server only)'. This is a clear when-to-use / when-not-to-use / alternative directive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv0.1.0
    • First observeddownload_attachment
    • First observedlist_attachments
    • First observedread_attachment_text

TDQS

A4.2/5.0

Scored across 3 tools

Disambiguation5/5

The three tools have clearly distinct purposes: listing attachments, downloading to disk, and reading text without saving. Descriptions explicitly clarify when to use each, with no overlap.

Naming Consistency5/5

All tools follow a consistent snake_case verb_noun pattern (list_attachments, download_attachment, read_attachment_text). The slight extra noun in the third tool is still clear and predictable.

Tool Count5/5

Three tools are well-scoped for a focused attachment server, covering the core operations of listing, downloading, and reading. No unnecessary tools, and the count feels just right.

Completeness4/5

The surface covers listing, downloading, and text reading of attachments, which are the primary retrieval workflows. Minor gaps like batch operations or attachment deletion/upload are not addressed, but likely outside the server's intended scope.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables AI assistants to interact with Gmail accounts through IMAP/SMTP, supporting reading, sending, replying to emails, managing threads, downloading attachments, and searching with Gmail syntax using simple app password authentication.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to manage Gmail through natural language interactions, supporting email operations (send, read, search, draft), comprehensive attachment handling (send, receive, download), label management, filters, and batch operations with automatic OAuth2 authentication.
    174 npm
    MIT
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables AI agents to interact with Gmail for classifying messages, extracting action items, and performing batch inbox triage. It supports automated labeling, smart replies, and task creation for external platforms like Linear, Jira, and Todoist.
    -
  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables AI assistants to search, read, and download attachments from Gmail using natural language, with read-only access.
    2
    MIT