Files
PaperClipAI/server/src/services/google-workspace-rest-dispatch.test.ts
T
DottaandPaperclip 1299d1d776 fix(google-workspace): keep approved tools active when only Paperclip's display title changed (#22980)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use Google Workspace through a connection whose catalog rows
store each action's definition, and a catalog refresh holds a changed
definition for review
> - #22630 replaced each launch Google Workspace action's discovered
title with Paperclip's own readable display label (for example, `Gmail:
Read a message`), and #22874 exempted transitions from Paperclip's
shipped REST schemas back to Google's MCP servers
> - Catalog publication still hashes `descriptor.title` into
`versionHash`, so refreshing a Google Workspace MCP connection whose
rows were saved before #22630 (with a `null` title or Google's raw
title, including after the 30-day technical-information strip) or after
a local display-title copy edit quarantines every approved Gmail and
Workspace action even though Google changed nothing
> - This pull request recognizes Paperclip-authored display titles for
the six REST-defined Google Workspace services and skips quarantine when
`schemaHash` is unchanged and `versionHash` matches the exact discovered
description, input schema, annotations, and risk level under the
previously saved or raw upstream title
> - The benefit is that catalog refreshes keep approved Gmail and Google
Workspace tools working without false review holds, while upstream
description, schema, annotation, risk-level, and non-Paperclip title
mutations still quarantine for review

## Linked Issues or Issue Description

Refs #22630
Refs #22874

**What happened?**

Refreshing a managed Google Workspace connection (`POST
/api/tool-connections/:id/catalog/refresh` or the automatic 15-minute
`listCatalog` refresh) puts previously approved Gmail and Workspace read
actions into `quarantined` (`pending_review`) when the saved catalog
rows carry a `null` title, Google's raw title (pre-#22630 MCP
connections, including rows stripped by the 30-day Google Technical
Information sweep), or an earlier Paperclip display title. Because
`discovery.ts` substitutes Paperclip's local display title
(`googleWorkspaceCatalogToolTitle`) before `publication.ts` computes
`descriptorHash`, `existing.versionHash !== hash` fires even when
Google's upstream definition did not change at all.

**Expected behavior**

Catalog refresh keeps already-approved Google Workspace actions `active`
(preserving `reviewedAt`, `reviewedByUserId`, Off, and Ask first
settings) when only Paperclip's own display title changed, while still
quarantining any upstream change to `description`, `inputSchema`,
`annotations`, `riskLevel`, or any title change on tools whose title is
provider-controlled. Already-quarantined rows stay held for human
review.

**Steps to reproduce**

1. Connect Google Workspace on Google's MCP servers with Gmail
permissions enabled and approve all read actions.
2. Have saved catalog rows from before #22630 (where `title` is `null`
or Google's raw title such as `"Get Message"` and `versionHash` was
computed with that title), or from an earlier Paperclip display title.
3. Run `refreshCatalog` against Google's MCP server returning the exact
same `description`, `inputSchema`, `annotations`, and `riskLevel`.
4. Observe that all 9 Gmail actions move to `status: "quarantined"`
(`quarantineReason: "pending_review"`) and disappear from agent
sessions.

**Paperclip version or commit**

`2d065677959b585065ff3fec8718156a4cf6f41d`

## What Changed

- `server/src/services/google-workspace-rest-dispatch.ts`: added
`googleWorkspacePaperclipToolTitle(toolName)` returning Paperclip's
static display title only for the six REST-defined Google Workspace
services (`gmail`, `drive`, `docs`, `sheets`, `slides`, `calendar`), and
reused it in `googleWorkspaceCatalogToolTitle`.
- `server/src/services/connectors/paperclip-defined-tools.ts`: exposed
`paperclipAuthoredToolTitle(connection, toolName)` on the narrow
connector contract so `publication.ts` stays connector-agnostic.
- `server/src/services/tool-access/catalog/descriptors.ts` &
`discovery.ts`: carried the raw upstream title as an in-memory-only
`upstreamTitle` field on `McpToolDescriptor` when Google Workspace
discovery replaces `title` with Paperclip's local display title (needed
when the 30-day Google Technical Information sweep has cleared
`existing.title` to `null`).
- `server/src/services/tool-access/catalog/publication.ts`: skipped
quarantine when `existing.schemaHash === schemaHash`,
`paperclipAuthoredToolTitle` equals `descriptor.title` (non-null), and
`descriptorHash` with `existing.title ?? null` or
`descriptor.upstreamTitle ?? null` matches `existing.versionHash`.
Already-quarantined rows remain quarantined, and any change to
`description`, `inputSchema`, `annotations`, `riskLevel`, or
non-Paperclip titles still quarantines.
- `server/src/__tests__/google-workspace-mcp-transport.test.ts`,
`server/src/services/google-workspace-rest-dispatch.test.ts`, and
`server/src/__tests__/connector-tool-policy.test.ts`: added
embedded-Postgres and unit regression tests covering all four
Paperclip-title-only refresh cases, plus security negative tests
confirming description/annotation/schema mutations on Gmail and upstream
title mutations on non-Paperclip connectors still quarantine.

## Verification

- Red before fix (on base `2d065677959b585065ff3fec8718156a4cf6f41d`):
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/google-workspace-mcp-transport.test.ts -t "keeps approved
Gmail read tools active on refresh when only Paperclip|still quarantines
approved Gmail read tools when Google mutates"` -> `4 failed | 1 passed`
(`AssertionError: expected 9 to be +0` quarantined on all 4 title-only
cases).
- Green after fix:
- `pnpm --filter @paperclipai/server exec vitest run
src/services/google-workspace-rest-dispatch.test.ts
src/__tests__/google-workspace-mcp-transport.test.ts
src/__tests__/connector-tool-policy.test.ts` -> **3 files, 77 passed
(77)** (including 34/34 embedded-Postgres Google Workspace MCP transport
tests, 21/21 REST dispatch tests, and 22/22 connector policy tests).
- `pnpm --filter @paperclipai/server exec vitest run
src/google-workspace-rest-tools/boundary.test.ts` -> **1 file, 2 passed
(2)**.
- `pnpm --filter @paperclipai/server typecheck` -> **PASS** (all 7
server typecheck layers).
- `node scripts/check-test-budget.mjs --files
server/src/services/google-workspace-rest-dispatch.test.ts
server/src/__tests__/google-workspace-mcp-transport.test.ts
server/src/__tests__/connector-tool-policy.test.ts` -> **PASS** (`110
nightly suites validated, 3 test file(s) checked`).
- `pnpm verify --base 2d06567795
--explain` selected 1947/2301 test files (>50); focused affected suites
and server typecheck ran locally while sharded PR CI supplies broad
coverage.

## Risks

- Low risk. No schema migration, no API contract change, and no
relaxation of security boundaries.
- Only tools whose displayed title is unconditionally replaced by
Paperclip's static `googleWorkspacePaperclipToolTitle` (the 36 launch
Google Workspace tools) can match `paperclipTitleOnlyChange`, and only
when SHA-256 proves `name`, `description`, `inputSchema`, `annotations`,
and `riskLevel` are all identical to the saved row.
- Already-quarantined rows (including pre-#22874 switch holds) remain
held for human review, matching #22874's safety invariant.

## Model Used

- Google Gemini (Antigravity agentic coding assistant) with tool use,
shell execution, and embedded-Postgres integration testing.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-25 15:32:39 -06:00

243 lines
16 KiB
TypeScript

import { GOOGLE_WORKSPACE_TOOL_TRANSPORT, googleWorkspaceServiceToolNames } from "@paperclipai/shared";
import { readFileSync } from "node:fs";
import { describe, expect, it, onTestFinished, vi } from "vitest";
import { stableHash } from "./tool-catalog-hash.js";
import {
callGoogleWorkspaceRest,
googleWorkspacePaperclipToolTitle,
googleWorkspaceRestShippedSchemaHashes,
googleWorkspaceRestToolDefinition,
googleWorkspaceCatalogToolTitle,
googleWorkspaceMcpErrorDetails,
googleWorkspaceMcpPreflightRefusal,
googleWorkspaceRestTransportGaps,
listGoogleWorkspaceRest,
probeGoogleWorkspaceRest,
} from "./google-workspace-rest-dispatch.js";
describe("Google Workspace REST transport eligibility", () => {
it("switches no service to paperclip_rest unless the REST tools cover its whole allowlist", () => {
expect(googleWorkspaceRestTransportGaps()).toEqual([]);
expect(googleWorkspaceRestTransportGaps({ ...GOOGLE_WORKSPACE_TOOL_TRANSPORT, gmail: "paperclip_rest", drive: "paperclip_rest",
docs: "paperclip_rest", sheets: "paperclip_rest", slides: "paperclip_rest", calendar: "paperclip_rest" })).toEqual([]);
});
it("finds Gmail and Calendar fully implemented and Chat not", () => {
expect(googleWorkspaceRestTransportGaps({ ...GOOGLE_WORKSPACE_TOOL_TRANSPORT, gmail: "paperclip_rest", calendar: "paperclip_rest" })).toEqual([]);
expect(googleWorkspaceRestTransportGaps({ ...GOOGLE_WORKSPACE_TOOL_TRANSPORT, chat: "paperclip_rest" }).map((gap) => gap.service)).toEqual(["chat"]);
});
it("names every missing tool of a service with no REST tools", () => {
expect(googleWorkspaceRestTransportGaps({ ...GOOGLE_WORKSPACE_TOOL_TRANSPORT, chat: "paperclip_rest" }))
.toEqual([{ service: "chat", missing: googleWorkspaceServiceToolNames("chat") }]);
});
});
describe("googleWorkspaceRestToolDefinition", () => {
it("returns this folder's definition for a tool of a service on paperclip_rest, and nothing otherwise", () => {
const savedDocs = GOOGLE_WORKSPACE_TOOL_TRANSPORT.docs;
GOOGLE_WORKSPACE_TOOL_TRANSPORT.docs = "paperclip_rest";
onTestFinished(() => { GOOGLE_WORKSPACE_TOOL_TRANSPORT.docs = savedDocs; });
const rest = listGoogleWorkspaceRest("docs").find((tool) => tool.name === "update_doc")!;
expect(googleWorkspaceRestToolDefinition("docs__update_doc")).toEqual({ name: rest.name, title: "Docs: Edit a document", description: rest.description,
inputSchema: rest.inputSchema, outputSchema: rest.outputSchema, annotations: rest.annotations });
expect(googleWorkspaceRestToolDefinition("docs__update_doc")?.inputSchema.required).toContain("writeControl");
expect(googleWorkspaceRestToolDefinition("chat__list_messages")).toBeNull();
expect(googleWorkspaceRestToolDefinition("gmail__send_message")).toBeNull();
expect(googleWorkspaceRestToolDefinition("update_doc")).toBeNull();
const saved = GOOGLE_WORKSPACE_TOOL_TRANSPORT.docs;
GOOGLE_WORKSPACE_TOOL_TRANSPORT.docs = "google_mcp";
try {
expect(googleWorkspaceRestToolDefinition("docs__update_doc")).toBeNull();
} finally {
GOOGLE_WORKSPACE_TOOL_TRANSPORT.docs = saved;
}
});
});
describe("googleWorkspaceRestShippedSchemaHashes", () => {
const services = ["gmail", "calendar", "drive", "docs", "slides", "sheets"] as const;
const schemas22634: Record<string, Record<string, unknown>> = JSON.parse(
readFileSync(new URL("../google-workspace-rest-tools/fixtures/input-schemas-22634.json", import.meta.url), "utf8"));
it("lists the input schema of every REST tool as it ships now, so a saved row from this build is recognised after a switch", () => {
for (const service of services) {
for (const tool of listGoogleWorkspaceRest(service)) {
expect(googleWorkspaceRestShippedSchemaHashes(`${service}__${tool.name}`), `${service}__${tool.name}`).toContain(stableHash(tool.inputSchema));
}
}
});
it("lists the input schemas the first REST launch (#22634) saved", () => {
expect(Object.keys(schemas22634)).toHaveLength(36);
for (const [name, schema] of Object.entries(schemas22634)) {
expect(googleWorkspaceRestShippedSchemaHashes(name), name).toContain(stableHash(schema));
}
});
it("lists nothing for a tool with no REST definition", () => {
expect(googleWorkspaceRestShippedSchemaHashes("chat__list_messages")).toEqual([]);
expect(googleWorkspaceRestShippedSchemaHashes("gmail__send_message")).toEqual([]);
expect(googleWorkspaceRestShippedSchemaHashes("update_doc")).toEqual([]);
});
});
describe("googleWorkspaceCatalogToolTitle", () => {
const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
it("names every allowlisted tool for a person, whichever transport lists it", () => {
for (const service of Object.keys(GOOGLE_WORKSPACE_TOOL_TRANSPORT) as Array<keyof typeof GOOGLE_WORKSPACE_TOOL_TRANSPORT>) {
for (const leaf of googleWorkspaceServiceToolNames(service)) {
const name = `${service}__${leaf}`;
const title = googleWorkspaceCatalogToolTitle("google-workspace", name, null);
expect(title, name).toMatch(/^[A-Z][A-Za-z ]+: [A-Z][a-z]+( [a-z]+)*$/);
expect(title, name).not.toMatch(UUID);
}
}
});
it("uses the Paperclip tool title for services with REST tools, for both transports", () => {
expect(googleWorkspaceCatalogToolTitle("google-workspace", "gmail__get_message", null)).toBe("Gmail: Read a message");
expect(googleWorkspaceCatalogToolTitle("google-workspace", "gmail__get_message", "Get Message")).toBe("Gmail: Read a message");
expect(googleWorkspaceCatalogToolTitle("google-workspace", "calendar__list_events", null)).toBe("Calendar: List events");
expect(googleWorkspaceCatalogToolTitle("google-workspace", "chat__send_message", "Send a message")).toBe("Chat: Send a message");
expect(googleWorkspaceCatalogToolTitle("google-workspace", "chat__send_message", "Chat: Send a message")).toBe("Chat: Send a message");
expect(googleWorkspaceCatalogToolTitle("google-workspace", "chat__send_message", null)).toBe("Chat: Send message");
});
it("leaves other connections' titles alone", () => {
expect(googleWorkspaceCatalogToolTitle("github", "gmail__get_message", null)).toBeNull();
expect(googleWorkspaceCatalogToolTitle(undefined, "create_issue", "Create issue")).toBe("Create issue");
});
it("identifies Paperclip-authored titles only for the six REST-defined services", () => {
expect(googleWorkspacePaperclipToolTitle("gmail__get_message")).toBe("Gmail: Read a message");
expect(googleWorkspacePaperclipToolTitle("gmail__search_threads")).toBe("Gmail: Search threads");
expect(googleWorkspacePaperclipToolTitle("calendar__list_events")).toBe("Calendar: List events");
expect(googleWorkspacePaperclipToolTitle("chat__send_message")).toBeNull();
expect(googleWorkspacePaperclipToolTitle("gmail__send_message")).toBeNull();
expect(googleWorkspacePaperclipToolTitle("get_message")).toBeNull();
});
});
describe("callGoogleWorkspaceRest", () => {
it("sends only the bearer token to Google and passes the gateway's fetch and signal", async () => {
const controller = new AbortController();
const fetch = vi.fn(async (_url: string, _init: RequestInit) => Response.json({ id: "draft1", message: { id: "m", threadId: "t" } }));
const outcome = await callGoogleWorkspaceRest({
service: "gmail", toolName: "create_draft", arguments: { subject: "Hi", body: "Hello" }, maxResultBytes: 1_000_000,
credentialHeaders: { authorization: "Bearer token-1", "x-paperclip-run": "run-1" }, fetch, signal: controller.signal,
});
expect(outcome).toMatchObject({ ok: true, result: { structuredContent: { id: "draft1", subject: "Hi" } } });
const init = fetch.mock.calls[0]![1];
expect(Object.fromEntries(new Headers(init.headers))).toMatchObject({ authorization: "Bearer token-1" });
expect(new Headers(init.headers).has("x-paperclip-run")).toBe(false);
controller.abort();
expect(init.signal?.aborted).toBe(true);
});
it("returns token problems as outcomes and leaves other failures as tool errors", async () => {
const answer = (status: number, body: unknown) => vi.fn(async () => Response.json(body, { status }));
const call = (fetch: ReturnType<typeof answer>, credentialHeaders: Record<string, string> = { Authorization: "Bearer t" }) =>
callGoogleWorkspaceRest({ service: "gmail", toolName: "get_message", arguments: { messageId: "m1" }, maxResultBytes: 1_000_000, credentialHeaders, fetch });
await expect(call(answer(401, {}))).resolves.toEqual({ ok: false, authFailure: "unauthenticated" });
await expect(call(answer(200, {}), {})).resolves.toEqual({ ok: false, authFailure: "unauthenticated" });
await expect(call(answer(403, { error: { errors: [{ reason: "insufficientPermissions" }] } })))
.resolves.toEqual({ ok: false, authFailure: "insufficient_scope" });
await expect(call(answer(404, { error: { code: 404 } }))).resolves.toMatchObject({ ok: true, result: { isError: true } });
});
it("passes the gateway's result budget to the REST tools, which enforce exactly that number", async () => {
const body = "a".repeat(30_000);
const message = { id: "m1", threadId: "t1", internalDate: "1763337600000",
payload: { mimeType: "text/plain", headers: [], body: { size: body.length, data: Buffer.from(body).toString("base64url") } } };
const call = (maxResultBytes: number) => callGoogleWorkspaceRest({
service: "gmail", toolName: "get_message", arguments: { messageId: "m1" }, maxResultBytes,
credentialHeaders: { Authorization: "Bearer t" }, fetch: vi.fn(async () => Response.json(message)),
});
const fits = await call(1_000_000);
expect(fits).toMatchObject({ ok: true, result: { structuredContent: { plaintextBody: body } } });
const bytes = Buffer.byteLength(JSON.stringify(fits.ok && fits.result), "utf8");
await expect(call(bytes)).resolves.toMatchObject({ ok: true, result: { structuredContent: { plaintextBody: body } } });
const over = await call(bytes - 1);
expect(over).toMatchObject({ ok: true, result: { isError: true } });
expect(JSON.stringify(over)).toContain(`more than the ${(bytes - 1).toLocaleString("en-US")} bytes this tool can return`);
});
it("refuses a service the REST tools do not implement", async () => {
await expect(callGoogleWorkspaceRest({ service: "chat", toolName: "send_message", arguments: {}, maxResultBytes: 1_000_000, credentialHeaders: {}, fetch: vi.fn() }))
.rejects.toThrow("no Paperclip REST tools");
});
});
describe("probeGoogleWorkspaceRest", () => {
it("reports a token problem separately from an unavailable service", async () => {
const probe = (status: number, body: unknown) => probeGoogleWorkspaceRest({
service: "gmail", credentialHeaders: { Authorization: "Bearer t" }, grantedScopes: ["https://www.googleapis.com/auth/gmail.readonly"],
fetch: vi.fn(async () => Response.json(body, { status })),
});
await expect(probe(200, { emailAddress: "a@example.test" })).resolves.toEqual({ ok: true });
await expect(probe(401, {})).resolves.toMatchObject({ ok: false, authFailure: "unauthenticated" });
await expect(probe(403, { error: { errors: [{ reason: "accessNotConfigured" }] } })).resolves.toMatchObject({ ok: false, authFailure: null });
});
});
describe("googleWorkspaceMcpErrorDetails", () => {
const failed = (text: string, structuredContent?: unknown) => ({ isError: true, content: [{ type: "text", text }], structuredContent });
const details = (result: unknown, readOnly = false) => googleWorkspaceMcpErrorDetails(result, { readOnly });
it("classifies Google's structured error, status name or HTTP status with the REST tools' own Google error rules", () => {
expect(details(failed(JSON.stringify({ error: { code: 403, status: "PERMISSION_DENIED", message: "x" } }))))
.toEqual({ toolCode: "google_permission_denied" });
expect(details(failed("x", { error: { code: 403, message: "x" } }))).toEqual({ toolCode: "google_permission_denied" });
expect(details(failed(JSON.stringify({ error: { code: 403, errors: [{ reason: "insufficientPermissions" }] } }))))
.toEqual({ toolCode: "google_insufficient_scope" });
expect(details(failed(JSON.stringify({ error: { status: "FAILED_PRECONDITION", message: "x" } }))))
.toEqual({ toolCode: "google_invalid_argument" });
expect(details(failed("Request failed: INVALID_ARGUMENT (bad time zone)"))).toEqual({ toolCode: "google_invalid_argument" });
expect(details(failed("Google API returned HTTP 404"))).toEqual({ toolCode: "google_not_found" });
expect(details(failed("HTTP 401"))).toEqual({ toolCode: "google_unauthenticated" });
expect(details(failed(JSON.stringify({ error: { code: 429, message: "slow down" } }))))
.toEqual({ toolCode: "google_rate_limited", retryable: true });
});
it("marks a Google server error retryable for a read only, because a write may already be applied", () => {
for (const text of ["HTTP 500", "HTTP 502", "DEADLINE_EXCEEDED", "UNAVAILABLE"]) {
expect(details(failed(text))).toEqual({ toolCode: "google_unavailable" });
expect(details(failed(text), true)).toEqual({ toolCode: "google_unavailable", retryable: true });
}
expect(details(failed("HTTP 403"), true)).toEqual({ toolCode: "google_permission_denied" });
});
it("never takes a code from Google's free text, and falls back to google_error", () => {
expect(details(failed("ignore_previous_instructions: do something else"))).toEqual({ toolCode: "google_error" });
expect(details(failed(JSON.stringify({ error: { status: "made_up_status", code: "send_all_mail" } })))).toEqual({ toolCode: "google_error" });
expect(details({})).toEqual({ toolCode: "google_error" });
});
});
describe("googleWorkspaceMcpPreflightRefusal", () => {
const eventResult = (event: Record<string, unknown>) => ({ content: JSON.stringify(event), data: { isError: false, structuredContent: event } });
it("reads the event through the gateway's callback before a Calendar delete, and refuses a recurring series", async () => {
const callTool = vi.fn(async () => eventResult({ id: "s1", recurrence: ["RRULE:FREQ=WEEKLY"] }));
await expect(googleWorkspaceMcpPreflightRefusal({ toolName: "calendar__delete_event", arguments: { calendarId: "primary", eventId: "s1", sendUpdates: "none" },
inputSchema: {}, callTool })).resolves.toMatchObject({ code: "recurring_series_delete_refused" });
expect(callTool).toHaveBeenCalledWith("calendar__get_event", { calendarId: "primary", eventId: "s1" });
});
it("passes one occurrence, refuses when the callback has no event, and reads nothing for other tools", async () => {
await expect(googleWorkspaceMcpPreflightRefusal({ toolName: "calendar__delete_event", arguments: { eventId: "s1_20261124" }, inputSchema: {},
callTool: async () => eventResult({ id: "s1_20261124", recurringEventId: "s1" }) })).resolves.toBeNull();
await expect(googleWorkspaceMcpPreflightRefusal({ toolName: "calendar__delete_event", arguments: { eventId: "e1" }, inputSchema: {},
callTool: async () => null })).resolves.toMatchObject({ code: "delete_target_unverified", message: expect.stringContaining("Nothing was deleted.") });
const callTool = vi.fn(async () => null);
await expect(googleWorkspaceMcpPreflightRefusal({ toolName: "calendar__update_event", arguments: { eventId: "e1" }, inputSchema: {}, callTool })).resolves.toBeNull();
await expect(googleWorkspaceMcpPreflightRefusal({ toolName: "drive__get_file_metadata", arguments: { fileId: "a,b" }, inputSchema: {}, callTool }))
.resolves.toMatchObject({ code: "invalid_file_id", message: expect.stringContaining("fileId must be one Google file ID") });
await expect(googleWorkspaceMcpPreflightRefusal({ toolName: "chat__list_messages", arguments: { anything: 1 }, inputSchema: { type: "object", properties: {} }, callTool }))
.resolves.toBeNull();
expect(callTool).not.toHaveBeenCalled();
});
});