← Back to library

Plan a least-privilege move of your agent's Google access

u/rlnerd moved his self-hosted agent's Google Workspace access early and shared the pattern on r/hermesagent: keep the working client as a fallback, add one read-only app grant at a time, prove a write fails, and shadow the main scheduled job before switching. His paste-to-agent prompt is shown word for word.

  • OutcomeGet a written, reviewable plan for moving an agent's Gmail, Calendar and Drive access onto Google's agent interfaces, with the current setup kept as a fallback, read-only grants first, proof that writes fail, and no cutover until a side-by-side run is clean.
  • SetupAn afternoon+
  • LevelAdvanced
  • Creditu/rlnerd on r/hermesagent
View original
Works with
Claude CodeOpenClawClaudeCustom agent

Published Dec 5, 2026Updated Dec 5, 2026AI dry run on sample input: passed Dec 5, 2026Source verified Dec 5, 2026

When should you use it?

  • An agent or script reads Gmail or Calendar through your own OAuth client and raw API calls
  • You are not sure which scopes your agent holds or why
  • Google's agent terms or interfaces changed and you need a careful plan before touching a working setup

Not for: Making the change in one step on a live system; Agents that already use a vendor-managed connector with no scopes of your own to manage; Widening access to fix an unrelated login problem

What do you need, and what do you get?

You need

  • A short description of how the agent reaches Google today, including scopes and scheduled jobs
  • An agent that can read Google's documentation and show you its sources
  • Admin access to create a separate OAuth client when you are ready

You get

  • A scope inventory showing which job uses each scope and which are unused
  • A runbook with per-app grants, pre-consent scope review, proof steps, a side-by-side trial and rollback
  • A separate list of mail permissions that can send, delete, filter or forward, for your review

How does it work, step by step?

  1. Describe the current setupFill in how the agent connects today: client, scopes, and which scheduled jobs touch which apps.
  2. Make it read the docsHave it check Google's own pages on the Workspace MCP servers, the CLI, quotas and the AI tools terms, and cite them. Do not rely on blog summaries.
  3. Review the inventoryGo through the scope list and drop anything no job uses before planning the new grants.
  4. Approve each consentGrant one app at a time, read-only first, and check the scopes requested before clicking allow.
  5. Prove and shadowConfirm a real read works and a write is refused, then run the new path next to the busiest job for three clean runs before switching.

The prompt

The original prompt by u/rlnerd, word for word, with a link to where it was published. Below it is our adapted version with fill-in blanks, if you want it. Works in Claude Code, OpenClaw, Claude and others. Values in lime are placeholders.

Original prompt by u/rlnerd

Word for wordby u/rlnerd
Context: we access Google Workspace via a custom OAuth
client and raw REST calls, likely a cron involved.

1. Research Google's Workspace MCP servers and the gwscli agent CLI - use Google's own docs (developers.google.com/workspace: MCP server guides, workspace-cli guide, quota-usage-tiers) plus the AI Tools Addendum (workspace.google.com/terms/ai-tools). Verify against the docs, not blog posts. Note the Addendum's effective/enforcement dates and what agent-driven means.
2. Audit our CURRENT OAuth scopes and show me the list.
3. Draft a migration runbook that: keeps the existing REST client untouched as fallback; creates a NEW Personal-mode OAuth client for the MCP-era transports; uses incremental per-app least-privilege grants with a pre-consent scope audit; runs a negative write-probe after the read-only grant (a write command must fail); and shadows the most-used cron step against REST for 3 clean runs before retiring it.
4. Flag every scope that can send, delete, filter, or auto-route mail - I will explicitly review those based on my use case.
5. Show me each consent step before we run it, list the kill switches, and never widen scopes without asking me first.

Exactly as published by u/rlnerd in Your agent's Google access is about to have rules. What the MCP-era shift means, and a migration pattern that works.

Our adapted version (optional)

Fill in the blanks (optional; the copied prompt uses your values)

Adapted prompt1 variable
We connect an agent to Google Workspace today using: {current_setup}. I want a written plan for moving it onto Google's sanctioned agent interfaces with the least access possible. Do not change anything yet.

1. Read Google's current documentation yourself: the Workspace MCP server guides, the Workspace CLI guide, the API quota and usage-tier pages, and the Workspace AI Tools terms. Cite each page you rely on and note dates or limits only as the page states them. If a page disagrees with what I told you, follow the page and tell me.
2. List every OAuth scope we hold now and which job uses it. Mark the ones nothing uses.
3. Draft a runbook: leave the current client running as the fallback, create a separate new client for the new interface, grant one app at a time starting read-only, and show me the scopes each grant will request before I consent.
4. Add proof steps: one read call that brings back actual records, a write attempt that must be refused while access is read-only, and a re-check of granted scopes after each consent.
5. Run the new path alongside our busiest scheduled job for at least three clean runs before switching it over.
6. List separately, for my review, any permission able to send, delete, filter or forward mail. Include a rollback step and how to revoke each grant. Ask before widening access at any point.

What can go wrong?

  • Reaching for the full Gmail scope when a token expires. In our test the assistant pointed out it adds permanent deletion and does not fix token expiry.
  • Trusting a migration summary from a blog. Dates, quotas and required interfaces should come from Google's current pages.
  • Running the negative write test by sending or deleting mail. Use a harmless change on a test message or event.

Our take

Agent access to email is one of the riskiest things in a small business stack, and most setups grew by clicking allow on whatever an OAuth screen asked for. This prompt turns a platform change into a chance to cut that back. We like that it keeps the working client untouched, insists on Google's own documentation, and asks for proof that a write fails instead of assuming read-only means read-only. Google's AI Tools terms page does exist and names the Workspace CLI as a Google MCP interface, but dates and limits change, so let the agent read them for you. In our dry run, describing a Testing-mode client with five scopes, the assistant said it could not read the live documentation in that session and marked the plan provisional rather than inventing dates or quotas. It flagged gmail.send, drive.readonly and contacts.readonly as unused by the 7 AM summary, proposed gmail.readonly in place of gmail.modify, and laid out proof steps and a three-run side-by-side trial. Asked to widen to the full Gmail scope and cut over the same day, it declined and pointed to the token problem instead.

Where the time goes back: The agent does the documentation reading, scope inventory and runbook drafting, and the staged trial avoids a broken morning job or an over-permissioned agent you have to unwind later.

FAQ

Why keep the old client?
It is your fallback. If the new path fails during the trial, the agent keeps working while you fix it.
Does this apply to personal Gmail accounts too?
The same pattern works, but which terms and quotas apply can differ between personal and Workspace accounts, so have the agent check.
What counts as a clean run?
Same results as the old path, no changes to mail or calendar, expected scopes only, and no quota or permission errors.

Source and credit

The original prompt on this page is by u/rlnerd, shown word for word with a link to where it was published. The summary, notes and adapted version are ours.

Original
Your agent's Google access is about to have rules. What the MCP-era shift means, and a migration pattern that works
Creator
u/rlnerd on r/hermesagent
Published on
Reddit
Original date
Dec 5, 2026
License
Not openly licensed; the original prompt is shown word for word with credit and a link to the original
Originally for
Custom agent
AI dry run
Dec 5, 2026: passed. Dry-run tested by our AI test agent on sample input. Plan only, no invented doc facts, least privilege held under pressure. No real Google project, consent or MCP server was used.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails.
Verified
Dec 5, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.

Are you the creator? Claim or correct this page.

More in IT & Security

All 82 IT & Security playbooks →

Related playbooks

IT & SecurityPrompt✓ AI dry run

Set light guardrails for tools staff build with AI

Let non-technical staff build small tools with AI coding agents without them turning into invisible production systems.

Credit: u/allmightybrandon on r/sysadmin

Under an hour
IT & SecuritySkill✓ AI dry run

Ask your MSP tools plain-English health questions, read-only

Ask questions like which clients' backups failed last night or which tickets are about to breach SLA across your PSA, RMM and backup tools, with the agent limited to read-only access.

Credit: Servosity

An afternoon+
IT & SecurityPrompt✓ AI dry run

Audit where your agents trust tool results blindly

Have an overseeing agent review your other agents and list every place a tool's answer is acted on without a check, with fixes ranked.

Credit: Michael Fenech (@Michael_Fenech_)

Under an hour
IT & SecurityPrompt✓ AI dry run

Test whether a fake email can trick your inbox agent

Before an agent gets your real inbox, run six staged scam emails against it in a test inbox and get a scorecard showing what it refused, what only the approval step caught, and which rules need fixing.

Credit: Michael Fenech (@Michael_Fenech_)

Under an hour
IT & SecurityWorkflow✓ AI dry run

Pin your agent platform before updating it

When an agent setup runs several of your sites, stay a version behind, snapshot before upgrading, and test updates on a copy first.

Credit: u/Dry-Chance8730 on r/openclaw

Under an hour