tools/call arguments and results (not prompts or resources). It resolves Drive folders using the calling user’s Google identity, which MCP Manager forwards to the engine automatically when you configure it — see Set up the Folder Blocker below.What it protects against
The Folder Blocker enforces a folder boundary at the gateway, independent of each user’s own Drive permissions. The problem it solves: a user (or an agent acting on their behalf) often has legitimate Drive access to a sensitive shared drive — HR, legal, finance, executive — but you don’t want that content reachable through an AI client. Drive’s own sharing model can’t express “this person may open the folder, but their AI assistant may not.” The Folder Blocker can. Once active, protection applies automatically to everyone whose traffic flows through that gateway — you configure it once, not per user. An administrator sets it up inside MCP Manager; end users simply continue connecting their AI client to the gateway URL, and protected folders are unreachable through it.How it works
On each Drive-touching tool call, the engine extracts every Drive file and folder ID it can find in the message — from IDs in tool arguments, URLs, and the structured fields a Workspace tool returns — and then determines whether any of them sit inside a protected folder. Because the protected set is checked against each item’s ancestor chain, a file is caught even when it is nested many levels below the folder you listed. The walk is built to leave no quiet gaps:- Full hierarchy. Each referenced item’s parent chain is walked upward, so a file deep inside
Protected/2026/Q3/board-deckis blocked by listingProtected. - Shortcuts are resolved. A Drive shortcut that lives in an allowed folder but points into a protected one is followed to its target, so it can’t be used as a side door.
- Shared drives included. Items on shared drives (formerly Team Drives) are resolved correctly, so a protected shared-drive folder is enforced just like a My Drive folder.
- Both directions. The rule fires on the request leg (catching content-extraction tools such as
get_drive_file_contentandexport_doc_to_pdf, where the file ID is in the arguments and no ID comes back in the result) and on the response leg (catching metadata-returning tools such assearch_drive_filesandlist_drive_items, where the ID is only in the result). The engine pre-selects both directions, so adding it materializes a paired request + response rule (see Detection hook). - Fail-closed by design. If the engine can’t fully verify a request — a Drive lookup fails, the hierarchy is implausibly deep, or the payload references more items than it can check — it returns an error rather than guessing, and the rule’s failure mode (Block by default) decides the outcome. It never lets an unverified reference through silently.
Before you start
The Folder Blocker depends on the Google Workspace MCP already being governed by MCP Manager:- The Google Workspace MCP is added as a remote MCP server and provisioned to the gateway you want to protect. MCP Manager handles the Google OAuth and proxies Workspace requests on each user’s behalf — no one manages raw tokens.
- End users connect their AI client to the gateway URL (not the Workspace server URL). The gateway is where the Folder Blocker and every other rule are applied.
Find a folder or shared drive ID
A protected entry is a Drive folder ID or shared drive ID. To get one, open the folder in Google Drive and copy the identifier from the URL — it is the segment after/folders/ (for a folder) or /drive/folders/ (inside a shared drive):
Set up the Folder Blocker
Setup is deliberately short: once MCP Manager recognizes the managed endpoint URL, it configures the engine for you, so you only name it, set the URL, and fill in the folder list.Add the rule engine and name it
Google Drive Folder Blocker.Set the Endpoint URL
mcpm-gdrive-blocked-folders header is added ready for its value. Two more headers are added at the same time: mcpm-gdrive-allowed-folders, empty, for the optional allowed folders, and mcpm-gdrive-warn-deleted-folders, pre-set to false — leave it as-is unless you want the opt-in deleted-folder alert.Fill in the protected folders
mcpm-gdrive-blocked-folders header, paste the folder IDs from the previous section as the value. Separate them with commas, whitespace, or one per line — all three are accepted (a JSON array works too). Save the engine.When you edit the engine later, its three settings, mcpm-gdrive-blocked-folders, mcpm-gdrive-allowed-folders and mcpm-gdrive-warn-deleted-folders, are shown exactly as you saved them. Folder IDs are not secrets (they appear in every Google Drive share link), so you can read each list, check that a folder or shared drive is on it, and remove one ID without retyping the others. You can also see whether the deleted-folder alert is on. If one of these settings shows as a fingerprint (hmac:…) instead, MCP Manager could not read it just then: reload the page. Leaving a fingerprint unchanged keeps the saved value.Apply it to the gateway
Allow folders inside a protected folder
Sometimes a few folders inside a protected folder or shared drive should stay reachable. List them in themcpm-gdrive-allowed-folders header, in the same format as the protected list. Leave it empty if you don’t need it.
For each file, the blocker looks up the folder chain from the file to the top of its drive. The nearest folder that is in either list decides:
- An allowed folder does not reopen anything protected inside it. List a folder inside an allowed folder as protected, and it is blocked again.
- Shortcuts are still followed. A shortcut placed in an allowed folder that points to a file elsewhere in the protected drive is still blocked.
- To unblock a whole folder or shared drive, remove it from
mcpm-gdrive-blocked-folders. An ID in both lists stays blocked. The form refuses to save an ID typed into both lists, and refuses a shared drive ID in the allowed list, since a shared drive is never inside another folder. The form checks a list you type or change. A list you leave exactly as saved is not checked again, so the form cannot compare it with a list you did change, and the rule that an ID in both lists stays blocked applies.
/folders/. The AI client can’t browse to it through the protected drive, because listing the drive itself stays blocked.
What works, and what still blocks. A rule decides each tool call as a whole, so:
- Listing an allowed folder, opening a file inside it, and searching within it (for example a query such as
'<allowed folder ID>' in parents) work. - Don’t name the protected shared drive in the search (as
drive_id): its ID is protected, so that search is blocked. A query on the allowed folder, such as'<allowed folder ID>' in parents, finds its files without it. - A search across Drive whose results include any file from a protected part is blocked as a whole. Point the assistant at the allowed folder instead.
- Listing the protected drive itself, or a protected folder, stays blocked.
Accepted folder ID format
Each entry must be a syntactically valid Google Drive identifier:- Character set — the URL-safe characters Drive uses:
A–Z,a–z,0–9,-, and_. No spaces or other punctuation inside an ID. - Length — roughly 19 to 44 characters. Shared drive IDs are around 19 characters; file and folder IDs are longer. The blocker validates against this range rather than a single fixed length, so both shapes are accepted.
Supported maximum
Both lists travel with every check, so each has a size limit, counted in characters including separators:- Protected folders: up to 8,192 characters — about 400 shared drive IDs, or about 240 folder IDs.
- Allowed folders: up to 2,048 characters — about 60 folder IDs.
Validation and failure behavior
The Folder Blocker is designed to never weaken protection silently. A misconfigured list fails loudly; a list that can’t be fully evaluated fails closed. The behavior splits cleanly between save time and request time. At save time, both lists are validated before they are stored:- A token that isn’t a valid Drive ID — wrong characters, too short, too long, or two IDs merged by a dropped comma — is rejected with an error that names the offending token, so you can find and fix it immediately.
- A list that exceeds the supported maximum is rejected the same way.
- An ID typed into both lists, or a shared drive ID in the allowed list, is refused with an explanation (see Allow folders inside a protected folder).
- Whitespace and a single trailing comma are normalized away, but tokens are never auto-merged or auto-split — a malformed entry is reported, not “repaired” into something you didn’t intend.
- If a stored protected list somehow can’t be parsed safely, the engine never silently ignores a token it can’t understand. It returns an error, and the rule’s failure mode decides: Block (recommended) blocks that gateway’s Drive traffic rather than under-protecting.
- If the allowed list can’t be parsed safely, or is over its limit, it is ignored instead: everything in the protected list stays blocked, including the folders the allowed list names, and an alert names the problem. A mistake in the allowed list never turns protection off.
- The folder lists come only from the rule engine’s own headers. A header with the same name on a user’s connection is ignored, so a user can’t change what is protected.
- If the engine can’t fully verify a particular call — a Drive API error, a hierarchy deeper than it will walk, or a payload referencing more items than it can check — it returns an error. The rule’s failure mode then decides: Block (the default for custom engines, and the recommended setting here) fails closed; Allow fails open. See Failure mode.
Warn on deleted folders
A protected entry whose folder has since been deleted keeps behaving as a safe no-op — it matches nothing and never errors a request. Confirming that a listed folder no longer exists, though, means issuing a Driveget for the folder on every request the rule inspects, which adds latency to all of the gateway’s Drive traffic. Because most lists are stable, that check is off by default and must be explicitly opted into.
To enable it, set the mcpm-gdrive-warn-deleted-folders header to true. Like the mcpm-gdrive-blocked-folders header, MCP Manager adds this header for you — pre-set to false — when it recognizes the managed endpoint, so you only change the value:
false(default) — no extra lookup. Deleted entries stay silent no-ops, and Drive traffic keeps the lowest latency.true— each protected folder is resolved on every inspected request, and when one is found to have been deleted the blocker raises an alert (anMcpAlertMessage) so you can prune the stale entry. Turn on the rule’s Alerts toggle as well to actually be notified.
Validating it works
The standard rule-engine Test action can’t meaningfully exercise this engine: a test runs outside a live gateway session, so there is no forwarded Google identity for it to query Drive with (and a real test would forward live Google credentials on every check). Validate it live from an AI client instead:- Ask the assistant to open or summarize a file you know is inside a protected folder — it should be blocked.
- Ask it to open a file outside every protected folder — it should work normally.
- If you use allowed folders, ask it to list one and open a file inside it — both should work.
Security characteristics and limitations
- Identity-aware, gateway-enforced. The boundary is enforced at the gateway using the user’s own forwarded Google identity, so it holds regardless of how the file is reached — and applies uniformly to every user on the gateway without changing anyone’s Drive permissions.
- Defense against indirect access paths. Nesting, shortcuts, and shared-drive placement are all resolved during the ancestor walk, closing the obvious ways a protected file could be reached without naming its folder directly. The engine’s threat model is maintained as a catalog of closed circumvention paths.
- Fail-closed posture. Combined with the default Block failure mode, an unverifiable or misconfigured state errs toward blocking rather than leaking — consistent with the rest of MCP Manager’s runtime protections.
How it appears in logs and alerts
The Folder Blocker behaves like any custom rule engine in your logs: each run records the engine, its verdict (pass / block / error), and a comment explaining the decision — for example, which protected folder a blocked file resolved into, or which Drive lookup failed. A block is also recorded as a policy_enforced_abort entry. Turn on the rule’s Alerts toggle to be notified whenever it acts, including fail-closed warnings and — when Warn on deleted folders is enabled — alerts that a protected folder has been deleted. See Audit & Observability for what each leg stores.

