Skip to main content
Glama
Google Messages MCP

Google Messages MCP

by ilakskill

google-messages-mcp

Local MCP server (stdio) that drives Google Messages for Web (https://messages.google.com/web) with Playwright, so AI agents can read and send the SMS/RCS on your Android phone. There is no official API; this automates the web app in a dedicated, persistent Chromium profile.

  • Entry: src/server.mjs (MCP tools, send-token safety)

  • Browser/session + all DOM selectors: src/browser.mjs (SELECTORS at the top)

  • Profile (pairing lives here; treat as a credential): ~/.google-messages-mcp/profile (%USERPROFILE%\.google-messages-mcp\profile on Windows)

  • QR screenshot: ~/.google-messages-mcp/qr.png

Install

git clone https://github.com/ilakskill/google-messages-mcp.git
cd google-messages-mcp
npm install
npx playwright install chromium
npm run smoke            # tools/list + gmsg_status, no browser launch

Related MCP server: Ghostlight

MCP registration

Claude Code (user scope), with the absolute path to your clone:

claude mcp add google-messages --scope user -- node /absolute/path/to/google-messages-mcp/src/server.mjs

Generic JSON (Claude Desktop / Cursor / Gemini / Antigravity mcpServers; VS Code uses servers):

{
  "mcpServers": {
    "google-messages": {
      "command": "node",
      "args": ["/absolute/path/to/google-messages-mcp/src/server.mjs"]
    }
  }
}

Only one process can open the profile at a time, so only one MCP client can actively use the server at once. A second client gets PROFILE_LOCKED until the first one exits.

Pairing (one time, needs your phone)

Ask an agent to run gmsg_pair (or wait_seconds: 0 first to get instructions right away).

  1. The server opens a visible browser on the pairing page.

  2. If Google offers a QR code: it turns on "Remember this computer", saves qr.png and returns the QR as an image. On the phone: Messages app > profile picture > Device pairing > QR code scanner, then scan.

  3. If Google offers no QR code (what the live site did on 2026-12-01: /web/authentication redirected to /web/welcome, which only has "Sign In"): Google blocks sign-in in Playwright-controlled browsers, so the server opens the same profile in a plain, non-automated browser window. In that window: click Sign In, sign in with the same Google account the phone's Messages app uses, and approve on the phone when prompted (matching emoji / prompt). Say yes to remembering this computer if asked.

  4. The server detects your conversation list, waits a few seconds, closes the window, and confirms pairing by reopening the profile under Playwright. Later calls run headless.

If the wait times out the window stays open; finish there and call gmsg_pair again (it resumes waiting). gmsg_pair with method: "cancel" closes a leftover sign-in window. Force a path with method: "qr" or method: "signin".

Tools

All tools return JSON text: {"ok":true,"data":...} or {"ok":false,"code","message","remedy"}. They never throw. Browser work is serialized through a single queue.

Tool

Args

What it does

gmsg_status

check?

Browser up, paired, page URL, last error. check:true launches headless to test pairing. Never queued behind a running pair.

gmsg_pair

wait_seconds?=120, method?=auto|qr|signin|cancel

Pairing (above).

gmsg_list_conversations

limit?=20, unread_only?=false

name, snippet, timestamp text, unread, conversation_id (from /web/conversations/<id>).

gmsg_read_conversation

conversation_id or name, limit?=30

Messages with direction (incoming/outgoing), text, timestamp, aria label, status. Scrolls up for older ones.

gmsg_search

query, scan?=150

Filters the conversation list by name, snippet or digits of a number.

gmsg_send_message

one of conversation_id / name / phone_number, text, confirm_token?

Two-step. Without token: preview (resolved recipient + text) and a 5-minute, single-use token bound to the exact recipient and text hash; nothing is sent. With token: sends, then verifies the outgoing bubble and reports its status. New numbers go through Start chat.

gmsg_archive_conversations

conversation_ids or all_in_inbox:true, confirm_token?

Two-step. Without token: resolves targets and returns a preview plus token; nothing is archived. With token: archives them and records id-to-name in ~/.google-messages-mcp/archived-map.json.

gmsg_unarchive_conversations

see tool schema, confirm_token?

Two-step. Restores conversations from the Archived view. Only conversations archived through this server (recorded in archived-map.json) can be targeted by id.

Error codes: NOT_PAIRED, PAIRING_IN_PROGRESS, PROFILE_LOCKED, SESSION_IN_USE, SELECTOR_MISSING, TIMEOUT, NOT_FOUND, AMBIGUOUS, BAD_INPUT, TOKEN_INVALID, TOKEN_MISMATCH, SEND_UNVERIFIED, BROWSER_MISSING, LAUNCH_FAILED, INTERNAL.

Environment variables

Var

Default

Meaning

GMSG_PROFILE_DIR

~/.google-messages-mcp/profile (%USERPROFILE%\.google-messages-mcp\profile on Windows)

Persistent browser profile. Changing it means re-pairing.

GMSG_HEADLESS

1

0 = run normal operations in a visible window.

GMSG_BROWSER

chromium

chromium (Playwright build), chrome (installed Google Chrome) or msedge. Profile is tied to the browser; switching means re-pairing. Try chrome if Google refuses sign-in in the Chromium build.

GMSG_BROWSER_PATH

auto

Explicit browser .exe for the manual sign-in window.

GMSG_AUTO_USE_HERE

1

Auto-click "Use here" on the "open in another tab" dialog. 0 = return SESSION_IN_USE instead.

GMSG_SIGNIN_WATCH

1

Sign-in window gets --remote-debugging-port=0 so the server can see when pairing finishes and close it. 0 = no port; close the window yourself.

GMSG_NAV_TIMEOUT_MS

45000

Navigation timeout.

Troubleshooting

  • Re-pair: if tools return NOT_PAIRED (phone unpaired the device, or "Remember this computer" was off), run gmsg_pair again. To start over completely, stop all MCP clients and point GMSG_PROFILE_DIR at a new empty folder; the old profile is never deleted by the server.

  • PROFILE_LOCKED: another server process, a smoke/probe run, or a sign-in window has the profile open. Close it (gmsg_pair method=cancel for a sign-in window) and retry.

  • "Messages for web is open in another tab/window" / "Use here": the server owns its profile and keeps a single tab, so by default it closes stray tabs in its own browser and clicks "Use here". Your own Chrome is a separate paired device and isn't affected. Set GMSG_AUTO_USE_HERE=0 to get SESSION_IN_USE instead.

  • Selector updates (Google changed the DOM): symptoms are SELECTOR_MISSING or empty results. Stop the MCP server, then:

    cd google-messages-mcp
    node scripts/probe.mjs                     # conversation list page
    node scripts/probe.mjs <conversation_id>   # a thread
    node scripts/probe.mjs --new               # Start chat page
    GMSG_HEADLESS=0 node scripts/probe.mjs     # watch it

    It prints which SELECTORS entries match and saves probe.png + probe-dom.html in ~/.google-messages-mcp (these contain message content; keep private). Fix the list in SELECTORS in src/browser.mjs (put the working selector first). In Git Bash, prefix path arguments with MSYS_NO_PATHCONV=1.

  • Headless blocked or blank: set GMSG_HEADLESS=0 and watch. The server already removes "HeadlessChrome" from the user agent.

  • Logs: stderr only (stdout is the MCP channel). Claude Code shows them with claude --debug / MCP logs.

Selector status

Verified live (unpaired) on 2026-12-01: the welcome page ([data-e2e-welcome-page-sign-in-button]) and the /web/authentication to /web/welcome redirect. Everything for a paired session (conversation list, threads, compose, send, Start chat, QR element, Remember toggle, Use here) is best-known and UNVERIFIED until a paired probe run. Entries are tagged [UNVERIFIED] in SELECTORS.

Smoke test

cd google-messages-mcp
node scripts/smoke.mjs                       # tools/list + gmsg_status
node scripts/smoke.mjs --check --validate    # + headless pairing check + send input validation
node scripts/smoke.mjs --list                # + list 5 conversations (needs pairing)
node scripts/smoke.mjs --qr                  # + gmsg_pair method=qr wait 0 (visible window)

The smoke test never sends a message.

Disclaimer

Unofficial. Not affiliated with or endorsed by Google. It automates the Google Messages web app, which can change or block automation at any time. The browser profile grants full access to your messages; never share or commit it.

License

MIT. See LICENSE.

Available Tools

8 tools
gmsg_archive_conversationsArchive conversations (two-step)A
Destructive

Two-step archive. Call 1 (no confirm_token): resolves targets (conversation_ids, or all_in_inbox=true which scrolls the whole inbox) and returns {count, targets:[{conversation_id,name}]} plus a confirm_token valid 5 minutes, single use, bound to the sorted id list; NOTHING is archived. Call 2 with the same selector (same conversation_ids, or all_in_inbox=true) and the token: archives each conversation one by one via its item menu and returns {archived:[ids], failed:[{id,reason}]}; a per-item failure never aborts the batch. Archived conversations are recoverable with gmsg_unarchive_conversations.

Inputs: all_in_inbox, confirm_token, conversation_ids.

gmsg_list_conversationsList conversationsB
Read-only

List recent conversations: name, snippet, timestamp text, unread flag, conversation_id.

Inputs: limit, unread_only.

gmsg_pairPair Google Messages (QR)A

Pair this server's browser profile with the phone (needs the user). method "auto" (default): opens a VISIBLE browser on the pairing page; if Google offers a QR code it turns on "Remember this computer", saves the QR to ~/.google-messages-mcp/qr.png and returns it as an image (scan: Messages app > profile picture > Device pairing > QR code scanner). If no QR is offered (current Google behaviour: Google-account sign-in only), it opens a plain non-automated browser window on the same profile for the user to sign in by hand and approve on the phone; the server detects completion and closes it. Waits up to wait_seconds (default 120); wait_seconds=0 returns right away (then call gmsg_pair again to keep waiting, or gmsg_status check=true). Relay the returned instructions to the user.

Inputs: method, wait_seconds.

gmsg_read_conversationRead a conversationA
Read-only

Read messages from one conversation (by conversation_id or name). Returns direction (incoming/outgoing), text, timestamp, aria label, status. Scrolls up to load older messages up to limit.

Inputs: name, limit, conversation_id.

gmsg_send_messageSend SMS/RCS (two-step)A
Destructive

Two-step send. Call 1 (no confirm_token): resolves the recipient and returns a preview plus a confirm_token valid 5 minutes, bound to the exact recipient and text; NOTHING is sent. Show the preview to the user. Call 2 with the same recipient fields, identical text and confirm_token: actually sends, then verifies the outgoing bubble and reports status. Recipient: exactly one of conversation_id, name, phone_number (new numbers go through Start chat).

Inputs: text (required), name, phone_number, confirm_token, +1 more.

gmsg_statusGoogle Messages statusA
Read-only

Browser up?, paired?, page URL, last error. check=true launches the browser (headless) if needed to determine pairing; default only reports current state without launching.

Inputs: check.

gmsg_unarchive_conversationsUnarchive conversations (two-step)A
Destructive

Two-step unarchive, operating from the Archived view (drawer > Archived dialog, which lists names only, no ids). Only ids archived through gmsg_archive_conversations are known (remembered by name in ~/.google-messages-mcp/archived-map.json); unknown ids fail with NOT_FOUND. Call 1 (no confirm_token): verifies each name is present in the archived list and returns {count, targets} plus a 5-minute single-use confirm_token bound to the sorted id list; nothing changes. Call 2 with the same conversation_ids and token: unarchives each, returns {unarchived:[ids], failed:[{id,reason}]}.

Inputs: conversation_ids (required), confirm_token.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool targets a distinct action on a distinct resource: send, list, read, search, archive, unarchive, pair, status. The archive/unarchive pair are clearly opposite operations, and search vs. list are distinguished (query-based scan vs. recent conversations). Status (read state) vs. pair (initiate pairing) are separated by explicit descriptions.

    Naming Consistency4/5

    All tools share the gmsg_ prefix and snake_case, giving a predictable namespace. Minor deviation: several tools are bare verbs/nouns (gmsg_status, gmsg_pair, gmsg_search) rather than verb_noun, but the convention remains readable and consistent in style.

    Tool Count5/5

    Eight tools is well within the sweet spot and each earns its place: core messaging (send/list/read/search), lifecycle management (archive/unarchive), and setup/diagnostics (pair/status). Nothing appears redundant or padded.

    Completeness4/5

    The core read/send/search workflow plus archive lifecycle and pairing is covered, including two-step confirmation for destructive actions. Gaps remain: no way to list archived conversations directly (unarchive requires remembered ids), and no delete-conversation, mark read/unread, or media/attachment sending.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      MCP server for a local-first messaging workspace that integrates Google Messages, WhatsApp, and Signal. It enables reading, sending, searching messages, and managing conversations through MCP tools.
      74
      -
    • A
      license
      A
      quality
      B
      maintenance
      MCP server that lets AI agents drive your real Chromium browser with your existing signed-in sessions, providing visible, local, and inspectable automation for tasks like navigation, clicking, typing, and form filling.
      25
      2
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server that lets ChatGPT search and read iMessage/SMS history, send one-at-a-time messages, and manage Contacts on your own Mac, with confirmations for any writes.
      MIT
    • F
      license
      A
      quality
      B
      maintenance
      A local stdio MCP server that gives any MCP client one connection to all of the user's Gmail, Google Workspace and IMAP accounts at once, letting assistants list accounts, read messages and attachments, run full-text search across mailboxes, trigger syncs and export messages as .eml. It runs on the user's own computer with encrypted secrets and no intermediary server, so mail is fetched directly from the providers.
      9
      1
      -