Skip to content

Releases

0.1.7 - duplicate definition, encoding-safe ACL check, folder inheritance

Choose a tag to compare

@luojinghao6-art luojinghao6-art released this 05 Nov 05:34

0.1.7

Three holes in the 0.1.6 permission hardening.

  • A duplicated _harden_dir — the later, non-verifying copy shadowed the
    strict one, so GMAIL_MCP_STRICT_PERMISSIONS=1 never actually covered
    directories. Removed, and CI now parses the package and fails on any
    duplicate top-level definition.
  • Windows ACL verification used locale text mode. subprocess(..., text=True)
    decodes with the console code page; on some Chinese Windows setups that raises
    UnicodeDecodeError, which was not caught. The check now runs through
    PowerShell and returns an ASCII verdict, and every subprocess call is handled
    as bytes with defensive decoding.
  • /inheritance:r only removes inherited ACEs, so an explicitly granted
    group (sandbox, corporate tooling) survived — and protecting a folder
    propagated to its children, leaving them with an empty DACL and locking the
    owner out. Hardening now does /reset first, then /inheritance:r /grant:r,
    and folder grants carry (OI)(CI) so their contents stay usable.

Verified against a real profile: config folder, credentials file and audit log
all read back with a single ACE for the current user. Tests: 120 offline (10
skipped), live suite 8/8.

pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.7/gmail_imap_mcp-0.1.7-py3-none-any.whl"

0.1.6 - permission hardening is verified, not assumed

Choose a tag to compare

@luojinghao6-art luojinghao6-art released this 05 Nov 05:19

0.1.6

Permission hardening is now verified, not assumed.

_harden_file() used to swallow every error and ignore icacls' exit status,
so "the credentials file and the audit log are owner-only" was a hope.

  • POSIX: chmod 0600, then the mode is read back with stat.
  • Windows: inherited ACEs are removed, the current user is granted, and the
    ACL is read back and rejected if any ACE names another principal — matched
    against the user name, DOMAIN\user, and the SID from whoami /user, so the
    check does not depend on the system language.
  • Failures are reported once on stderr instead of vanishing.
    GMAIL_MCP_STRICT_PERMISSIONS=1 makes them fatal.
  • No secret under inherited permissions: gmail-imap config now creates the
    file empty, hardens it, and only then writes the password. Under strict mode a
    failure deletes the file rather than leaving an unprotected secret behind. The
    audit log follows the same create → harden → append order.
  • PermissionHardeningError subclasses AuditError, so every existing
    "audit failed" path covers it too.

Verified on a real Windows account: both the credentials file and the audit log
read back with a single ACE for the current user. Tests: 116 offline (10
skipped: live suite + POSIX-only checks), live suite 8/8 before tagging.

pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.6/gmail_imap_mcp-0.1.6-py3-none-any.whl"

0.1.5 - partial delivery and unknown send state reported accurately

Choose a tag to compare

@luojinghao6-art luojinghao6-art released this 05 Nov 05:08

0.1.5

Send state is now described accurately, not as a single "failed".

smtplib.send_message() delivers to the accepted recipients before it returns
the refused ones. 0.1.4 raised a plain GmailError for that case, which looked
like nothing was sent — retrying duplicated the message for everyone who had
already received it.

  • Partial delivery raises PartialSendError carrying sent_to and
    refused; the audit row is send_partial with both lists, so a retry can be
    aimed at the refused addresses only.
  • All recipients refused still raises a plain error — nothing left the machine.
  • An SMTP failure mid-transfer raises SendStateUnknownError: delivery
    state is unknown, check the Sent folder before retrying.
  • Docs and Skill troubleshooting cover the three outcomes.

Tests: 111 offline (9 skipped: live suite + a POSIX-only file-mode check), plus
the real-mailbox suite (8/8) run before tagging.

pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.5/gmail_imap_mcp-0.1.5-py3-none-any.whl"

0.1.4 - audit intent before SMTP, explicit sent-but-unaudited error

Choose a tag to compare

@luojinghao6-art luojinghao6-art released this 05 Nov 05:00

0.1.4

The strict-audit guarantee was not real in 0.1.3. The completion record was
written after SMTP, so with GMAIL_MCP_AUDIT_STRICT=1 a failed write raised a
plain error even though the message had already left — and a retry could send it
twice.

Fixed by ordering:

  • a send_intent record is written before SMTP. Under strict audit a
    failure there aborts the send, so nothing leaves the machine and "no mail
    without a trail" is now true;
  • send / reply remain the completion record after SMTP;
  • if only the completion record fails, the call raises
    SentButUnauditedError with an explicit "the mail WAS sent — check the
    Sent folder before retrying", instead of an error that looks like nothing
    happened;
  • blocked attempts and SMTP errors are audited through _audit_quietly, so an
    audit failure never masks the original reason.

Also: the live workflow now emits a warning annotation when it skips for missing
secrets, so a green run cannot be mistaken for a real mailbox test. The suite
itself was run against a real account before tagging (8/8).

Tests: 109 offline (9 skipped: live suite + a POSIX-only file-mode check).

pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.4/gmail_imap_mcp-0.1.4-py3-none-any.whl"

0.1.3 - owner-only credentials and audit files, scan hook, nightly live CI

Choose a tag to compare

@luojinghao6-art luojinghao6-art released this 05 Nov 04:46

0.1.3

Hardening for the two things that were still best-effort: credentials and audit.

  • Credentials are owner-only on disk. gmail-imap config writes 0600 on
    POSIX and replaces the ACL with a single grant for the current user on Windows.
    New GMAIL_APP_PASSWORD_FILE lets the App Password live in a keychain export
    or a mounted secret instead of the JSON config.
  • The audit trail can no longer fail silently. The log is created 0600,
    hardened on first write, and a failed write now prints a warning. With
    GMAIL_MCP_AUDIT_STRICT=1 that failure aborts the send — no mail without a
    trail.
  • Optional attachment scanning. GMAIL_MCP_SCAN_CMD="clamdscan --no-summary {}"
    runs on every saved attachment: exit 0 keeps the file, exit 1 (flagged) or a
    scanner that cannot run deletes it and fails the call. Results carry a scan
    field. Without it, downloaded files are still untrusted content — never open
    them automatically.
  • Nightly live checks. .github/workflows/live.yml runs the real-mailbox
    suite daily when GMAIL_ADDRESS / GMAIL_APP_PASSWORD repository secrets are
    set, and skips cleanly when they are not.
  • Docs now say plainly that this is a personal connector: an App Password is
    full-mailbox access, so one account per OS user or container, not multi-tenant.
  • Tests: 105 offline (9 skipped: live suite + a POSIX-only file-mode check), plus
    the live suite run against a real account before tagging.
pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.3/gmail_imap_mcp-0.1.3-py3-none-any.whl"

0.1.2 - inbound attachment confinement, web header and token fixes

Choose a tag to compare

@luojinghao6-art luojinghao6-art released this 05 Nov 04:32

0.1.2

Inbound attachments are now confined to a download folder.

  • gmail_download_attachment and gmail_read(save_attachments_to=...) only write
    inside ~/Downloads/gmail-imap and the roots listed in GMAIL_MCP_DOWNLOAD_DIRS.
    Sender-supplied filenames are reduced to a single path component (no separators,
    no ./.., Windows device names prefixed), and an existing file is never
    overwritten — the name gets a _1, _2 … suffix and the file is opened with
    O_EXCL. This closes the "email tells the agent to drop a file into Startup"
    path that prompt injection needs.
  • Web UI: /api/attachment now sends the same security headers as the rest of the
    API, and the page token is redacted from stderr request logs.
  • Skill: the install line now names the real package (gmail-imap-mcp), and the
    attachment example points at the allowed folder.
  • Tests: attachment policy suite, web attachment header and token-redaction tests,
    a docs regression test, and an opt-in live Gmail suite
    (GMAIL_IMAP_LIVE=1 python -m unittest tests.test_live) run against a real
    account — login, labels, search, read by uid and msgid, attachment fetch,
    dry-run send.

Breaking for scripts that saved into a relative folder: --save-attachments ./out
is now refused unless ./out sits under an allowed root. Set
GMAIL_MCP_DOWNLOAD_DIRS=/path/to/out to allow it, or drop the flag and use the
default ~/Downloads/gmail-imap.

pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.2/gmail_imap_mcp-0.1.2-py3-none-any.whl"

v0.1.1 — mailbox-safe refs, web hardening, send controls

Choose a tag to compare

@luojinghao6-art luojinghao6-art released this 04 Nov 14:53

What changed

Mailbox-scoped message references (correctness fix). Gmail UIDs are unique
per mailbox, not per account. gmail_search now returns mailbox and
mailbox_raw with every hit, plus an account-wide msgid (X-GM-MSGID).
gmail_read, gmail_reply and gmail_download_attachment accept
mailbox or msgid; a UID from an INBOX-only search can no longer resolve to
a different message in All Mail. An explicit mailbox that cannot be opened now
raises instead of silently falling back to INBOX.

Python 3.10+. The MCP SDK requires it. CI now has a second job that
installs .[mcp], so resolver/extra breakage fails CI instead of hiding behind
the core-only leg.

Web UI hardening. Loopback Host allowlist (DNS rebinding), Origin /
Referer checks on writes, Content-Type: application/json required, 32 MB
body cap, and CSP / X-Frame-Options: DENY / nosniff / no-referrer on every
response. The credential path shown in the setup card now comes from the server
instead of a stale hard-coded path.

Code-level send controls. Prompt instructions are no longer the only guard:
GMAIL_MCP_READ_ONLY=1 disables send/reply outright,
GMAIL_MCP_ATTACHMENT_DIRS bounds attachments, credential-looking files are
always refused, and every send attempt is appended to audit.log as JSON.

--dry-run really is dry. It used to send the message and then print
"(dry run)". It now builds the message and returns without touching SMTP.

Tests. 62 offline tests (up from 18): IMAP FETCH/SEARCH fixtures, mailbox
resolution, message construction, reply/reply-all/threading, policy and audit,
web token/Host/Origin/CSP, MCP tool schema.

Install

pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.1/gmail_imap_mcp-0.1.1-py3-none-any.whl"

v0.1.0 - Gmail for AI agents

Choose a tag to compare

@luojinghao6-art luojinghao6-art released this 04 Nov 14:02

Gmail for AI agents over IMAP/SMTP with a Google App Password. No OAuth, no Google Cloud project, no third-party relay.

One core, three front-ends: an MCP server, a CLI, and a local web UI.

Install

# from this release — no PyPI account needed
pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.0/gmail_imap_mcp-0.1.0-py3-none-any.whl"

# or straight from the repo
pip install "git+https://github.com/luojinghao6-art/gmail-imap-mcp.git#egg=gmail-imap-mcp[mcp]"

60-second setup

  1. Create an App Password — https://myaccount.google.com/apppasswords (2-Step Verification must be on)
  2. gmail-imap config
  3. claude mcp add gmail -- gmail-imap-mcp

For Claude Desktop / Cursor / any MCP client:

{ "mcpServers": { "gmail": { "command": "gmail-imap-mcp" } } }

MCP tools

Tool Purpose
gmail_status Is it configured? Does IMAP login work?
gmail_search Search with Gmail's own syntax (from:, has:attachment, newer_than:7d, label:)
gmail_read Full message: plain text, HTML, attachment list
gmail_send Send with CC/BCC, HTML, attachments, threaded replies
gmail_reply Reply / reply-all, quoting the original
gmail_labels Folders and labels, decoded from IMAP UTF-7
gmail_download_attachment Save one attachment to disk

Web UI

gmail-imap-ui        # http://127.0.0.1:8765/

Three panes, compose with attachments, Gmail-syntax search. Localhost only, token-gated, email HTML rendered in a sandboxed iframe with remote images blocked.

Verified

  • 18 unit tests, CI on Python 3.9 / 3.11 / 3.13
  • Real personal Gmail account: search, read, attachments, send, reply, web UI
  • MCP handshake and tool calls against a live inbox

Known limits

IMAP cannot edit drafts, change filters, or read Gmail settings — use a Gmail API server for those. App Passwords require 2-Step Verification and may be disabled on managed Workspace accounts.


中文

给 AI 用的 Gmail —— 走 IMAP/SMTP + 应用专用密码。不用 OAuth、不建 GCP 项目、不经过第三方中转。

一个核心,三个入口:MCP 服务、命令行、本地 Web 界面。

安装

pip install "gmail-imap-mcp[mcp] @ https://github.com/luojinghao6-art/gmail-imap-mcp/releases/download/v0.1.0/gmail_imap_mcp-0.1.0-py3-none-any.whl"

三步上手

  1. 生成应用专用密码 —— https://myaccount.google.com/apppasswords(先开两步验证)
  2. gmail-imap config
  3. claude mcp add gmail -- gmail-imap-mcp

已验证

  • 18 个单元测试,CI 跑 Python 3.9 / 3.11 / 3.13
  • 真实个人 Gmail 账号上跑通搜索、阅读、附件、发信、回复、Web UI
  • MCP 握手与工具调用已对真实收件箱验证

已知限制

IMAP 改不了草稿、过滤器和 Gmail 设置;需要这些请用 Gmail API 方案。应用专用密码要求账号开启两步验证,企业 Workspace 账号可能被管理员禁用。