Skip to main content
Glama
martinsgirss

gmail-invoice-mcp

by martinsgirss

gmail-invoice-mcp

An MCP server that pulls invoice and receipt attachments out of Gmail and drops them straight into an accounting folder.

The problem

Bookkeeping for a small company means opening dozens of emails a month, downloading a PDF from each one, renaming it, and filing it. The standard Gmail integrations for AI assistants can read a message, but none of them can hand you the attachment — so the one step that actually takes time stays manual.

Related MCP server: Gmail AutoAuth MCP Server

What it does

Four tools, exposed over the Model Context Protocol, so an assistant can do the whole fetch-and-file pass in one instruction:

Tool

What it does

search_with_attachments

Finds messages matching a Gmail query that carry attachments

list_attachments

Lists the attachments on one message with names, types and sizes

get_attachment

Downloads a single attachment, optionally straight to a path

save_attachments_to_folder

Bulk-saves every attachment matching a query into one folder

A month of supplier invoices is then a single request: "save every PDF from these five senders since 1 June into the bookkeeping folder".

Stack

Python · MCP FastMCP · Gmail API · Google OAuth 2.0 (read-only scope, token cached locally)

Result

Collecting one month of supplier invoices for a Norwegian AS went from an hour of manual downloading to a single instruction. It has been running in production bookkeeping since early 2026.

Setup

  1. Create a Google Cloud project, enable the Gmail API, and configure an OAuth consent screen.

  2. Download the OAuth client credentials as credentials.json.

  3. Install dependencies:

    pip install -r requirements.txt
  4. Point the server at your credentials and register it with your MCP client:

    {
      "mcpServers": {
        "gmail-invoice": {
          "command": "python",
          "args": ["src/server.py"],
          "env": {
            "GMAIL_CREDENTIALS_PATH": "/path/to/credentials.json",
            "GMAIL_TOKEN_PATH": "/path/to/token.json"
          }
        }
      }
    }

On first run the server opens a browser for authorization and caches the token at GMAIL_TOKEN_PATH. The scope is gmail.readonly — the server can read and download, never send or delete.

Security

credentials.json and token.json are secrets. They are excluded in .gitignore and must never be committed.

License

MIT

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.
    117 npm
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to interact with Gmail accounts for reading unread emails, creating draft replies with proper threading, and managing messages, with optional professional writing guidelines, templates, and Google Docs/Calendar integration.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to manage Gmail accounts through natural language for tasks like sending, reading, searching, and organizing emails. It supports advanced features including draft management, label operations, and batch actions via secure OAuth 2.0 authentication.
    MIT