mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
fix(apps): show readable Google Workspace action names on Review and Permissions (#22630)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Connectors let agents use outside apps. The Google Workspace
connector gives agents Gmail, Calendar, Drive, Docs, Sheets and Slides
actions.
> - Each connection has a Review tab and a Permissions tab. People
approve actions and turn actions on or off there.
> - Google Workspace actions had no human title. These tabs showed the
internal tool name, for example `gmail__get_message` and
`calendar__list_events`.
> - Users must not see internal names. Google's app reviewers will also
look at these screens.
> - This pull request gives every Google Workspace action a readable
name, such as "Gmail: Read a message", for both tool transports.
> - The benefit is that people and reviewers see what each action does,
in plain words.
## Linked Issues or Issue Description
**What happened?**
On the Review tab and the Permissions tab of a Google Workspace
connection, action rows showed internal tool names. Examples:
`gmail__get_message` in the "Review new actions" list and the action
list, and "Calendar Create Event" in the "Waiting for your OK" list.
**Expected behavior**
Each row shows a readable action name, for example "Gmail: Read a
message" or "Calendar: List events". No row shows a `service__tool` name
or a raw ID.
**Steps to reproduce**
1. Connect Google Workspace.
2. Open Connectors, then the connection, then Permissions. Look at the
action list.
3. Open Review. Look at "Review new actions" and "Waiting for your OK".
**Paperclip version or commit**
master at 78e4f4f130.
## What Changed
- `server/src/google-workspace-rest-tools/`: each of the 36 Paperclip
REST tool definitions now has an MCP `title` (for example `get_message`
is "Read a message"). The change stays inside each tool's own file.
`allowlist.test.ts` now checks that every tool has a short title.
- `packages/shared`: new `googleWorkspaceToolTitle(name, title)`. For an
allowlisted Google tool it returns "<Service>: <action>". When no title
is known, it uses the action name in sentence case ("Gmail: Get
message").
- `server/src/services/google-workspace-rest-dispatch.ts`: new
`googleWorkspaceCatalogToolTitle`. For a Google Workspace connection it
uses the Paperclip REST title when one exists, then the upstream title.
It works the same for `google_mcp` and `paperclip_rest`.
`GOOGLE_WORKSPACE_TOOL_TRANSPORT` does not change.
- The server applies this title when it discovers the catalog, when it
reads the catalog, in the review queue list (`toolTitle`), and in the
gateway display name. The approval card text and preview use the display
name, so new requests show the readable name too. Rows saved before a
catalog refresh also get the readable name at read time.
- UI: the Permissions action list, the "Review new actions" list, the
agent access list, the action test dialog and the "Waiting for your OK"
list use one helper, `actionLabel`. It uses the readable Google name
when the server gives no title.
- No API field, route, permission check or company scope changes.
- `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed, because a
pinned shared file changed.
## Verification
- Red, then green:
`ui/src/pages/apps/app-detail/GoogleWorkspaceActionLabels.test.tsx`
renders the Review tab and the Permissions action list with Google rows
as the server sent them before this change (no title, real UUIDs in
every ID field). It checks that no `service__tool` name and no UUID is
visible.
- Before: the test failed. The Review tab showed `gmail__get_message`
and "Calendar Create Event". The Permissions list showed
`calendar__list_events` and `gmail__create_draft`.
- After: the test passes. The tabs show "Gmail: Get message", "Calendar:
Create event", "Calendar: List events" and "Gmail: Create draft" with
this UI-only fallback. With the server change, the names are the REST
titles, for example "Gmail: Read a message".
- `server/src/services/google-workspace-rest-dispatch.test.ts`: every
allowlisted tool of every service gets a "<Service>: <Action>" title
with no underscores and no UUID, for both transports. Titles from other
connections do not change.
- `packages/shared/src/google-workspace-connectors.test.ts`: tests for
`googleWorkspaceToolTitle`.
- `server/src/google-workspace-rest-tools/allowlist.test.ts` and
`boundary.test.ts` pass.
- Focused runs: UI `src/pages/apps/app-detail`,
`ReviewQueueCard.test.tsx`, `AppDetail.test.tsx` (141 tests pass).
Server Google Workspace tests, review queue test,
`tool-access-service.test.ts`, `tool-gateway-service.test.ts`,
`connection-management.integration.test.ts` (2,212 tests pass).
- `pnpm --filter @paperclipai/shared typecheck`, `pnpm --filter
@paperclipai/ui typecheck` and `pnpm --filter @paperclipai/server
typecheck` pass.
- `pnpm verify` exits 2 because the pinned input registry is a global CI
input. Required CI gives the broad coverage.
## Risks
- Low risk. The change only affects display titles of Google Workspace
actions. Tool names, policies, grants and calls do not change.
- The gateway display name of a Google tool changes from its internal
name to the readable name. Agents see this text as the tool title only.
The tool name that agents call does not change.
- Approval previews saved before this change keep their old text until
the request is resolved.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), in Claude Code with tool use
(shell, file edit, test runs).
## 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
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
624a78fd5d
commit
98fd412851
54 files changed
+298
-18
No files matched your search
@@ -72,6 +72,10 @@ so they can be deleted cleanly when that happens.
|
||||
- **One tool, one file.** Each tool in `gmail/`, `calendar/`, `drive/`, `docs/`, `slides/` and `sheets/` is a set of pure functions
|
||||
(arguments to REST request, REST response to MCP result) plus a short `run`
|
||||
that sequences them. The pure functions are unit tested without network.
|
||||
- **Every tool has a `title`.** It is a short action name in sentence case,
|
||||
such as "Read a message". The gateway shows it to people as
|
||||
"Gmail: Read a message" for both transports. `allowlist.test.ts` fails if a
|
||||
tool has no title.
|
||||
- **`server.ts` is thin MCP wiring:** `tools/list` and `tools/call`.
|
||||
- **The allowlist stays where it is.** `toolScopes` in
|
||||
`packages/shared/src/google-workspace-connectors.ts` is the single list of
|
||||
|
||||
@@ -47,6 +47,14 @@ describe("tool allowlist", () => {
|
||||
expect(everything).not.toMatch(/label:`? takes label IDs/i);
|
||||
});
|
||||
|
||||
it("gives every tool a short human title", () => {
|
||||
for (const service of GOOGLE_WORKSPACE_REST_SERVICES) {
|
||||
for (const tool of listGoogleWorkspaceRestTools(service)) {
|
||||
expect(tool.title, tool.name).toMatch(/^[A-Z][a-z]+( [a-z]+)*$/);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("implements no send tool", () => {
|
||||
const names = GOOGLE_WORKSPACE_REST_SERVICES.flatMap((service) => listGoogleWorkspaceRestTools(service).map((tool) => tool.name));
|
||||
expect(names.filter((name) => /send/i.test(name))).toEqual([]);
|
||||
|
||||
@@ -147,6 +147,7 @@ export function createEventResult(event: RestEvent): CallToolResult {
|
||||
export const createEvent = defineTool({
|
||||
definition: {
|
||||
name: "create_event",
|
||||
title: "Create an event",
|
||||
description: "Creates an event on a calendar and returns it. By default Google emails an invitation to every attendee (notificationLevel ALL); pass notificationLevel NONE to create it silently.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -52,6 +52,7 @@ export function deleteEventResult(deleted: RestEvent): CallToolResult {
|
||||
export const deleteEvent = defineTool({
|
||||
definition: {
|
||||
name: "delete_event",
|
||||
title: "Delete an event",
|
||||
description: "Deletes one event, or one occurrence of a recurring event, and returns it as it was, with status cancelled. It never deletes a whole recurring series: a series ID is refused, so pass one occurrence's ID (from list_events). By default Google emails a cancellation to every attendee (notificationLevel ALL); pass notificationLevel NONE to delete it silently.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -14,6 +14,7 @@ export function getEventResult(event: RestEvent): CallToolResult {
|
||||
export const getEvent = defineTool({
|
||||
definition: {
|
||||
name: "get_event",
|
||||
title: "Read an event",
|
||||
description: "Gets one event from a calendar by event ID.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -45,6 +45,7 @@ export function calendarProbeRequest(): GoogleRequest {
|
||||
export const listCalendars = defineTool({
|
||||
definition: {
|
||||
name: "list_calendars",
|
||||
title: "List calendars",
|
||||
description: "Lists the calendars the signed-in user owns or has subscribed to, as shown in Google Calendar's calendar list. Use it to turn a name such as \"my family calendar\" into a calendar ID. Other calendars shared with the user can still be read by their ID.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -161,6 +161,7 @@ async function readAllForDescending(input: ListEventsArgs, window: EventWindow,
|
||||
export const listEvents = defineTool({
|
||||
definition: {
|
||||
name: "list_events",
|
||||
title: "List events",
|
||||
description: "Lists events on one calendar that match all the given filters. Recurring events are returned as their individual occurrences. Set startTime or endTime only when the user asks about a specific time. For open-ended keyword or topic searches on the primary calendar, use search_events instead.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -56,6 +56,7 @@ export function respondToEventResult(event: RestEvent): CallToolResult {
|
||||
export const respondToEvent = defineTool({
|
||||
definition: {
|
||||
name: "respond_to_event",
|
||||
title: "Respond to an event",
|
||||
description: "Sets the signed-in user's response (accepted, tentative or declined) to an event they are invited to, with an optional comment, and returns the event. Passing a recurring series' ID responds for the whole series; passing one occurrence's ID (from list_events) responds for that occurrence only. The result shows which: a series has recurrence and no recurringEventId; one occurrence has recurringEventId. By default only attendees outside the organizer's domain are emailed (notificationLevel EXTERNAL_ONLY).",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -38,6 +38,7 @@ export function searchEventsResult(list: RestEventList): CallToolResult {
|
||||
export const searchEvents = defineTool({
|
||||
definition: {
|
||||
name: "search_events",
|
||||
title: "Search events",
|
||||
description: "Searches events on the signed-in user's primary calendar by keywords, across all dates. Matches title, description, location, attendees and organizer; every term must match. A recurring series is returned once, as the series, not as each occurrence; use list_events to see occurrences in a time range.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -257,6 +257,7 @@ const slotTime = {
|
||||
export const suggestTime = defineTool({
|
||||
definition: {
|
||||
name: "suggest_time",
|
||||
title: "Suggest a meeting time",
|
||||
description: "Finds periods in a time range when all the given people are free, from their calendars' busy times. Each suggestion is a whole free period at least durationMinutes long, earliest first. Free periods are not split into meeting-length slots.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -210,6 +210,7 @@ export function updateEventResult(event: RestEvent): CallToolResult {
|
||||
export const updateEvent = defineTool({
|
||||
definition: {
|
||||
name: "update_event",
|
||||
title: "Update an event",
|
||||
description: "Changes an event on a calendar and returns the updated event. Fields that are not set are left as they are. By default Google emails the change to every attendee (notificationLevel ALL); pass notificationLevel NONE to change it silently. Passing a recurring series' ID changes the whole series (every occurrence that has not been changed on its own); passing one occurrence's ID (from list_events) changes only that occurrence. The result shows which: a series has recurrence and no recurringEventId; one occurrence has recurringEventId.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -44,6 +44,7 @@ export function readDocResult(document: RestDocument, input: ReadDocArgs, view:
|
||||
export const readDoc = defineTool({
|
||||
definition: {
|
||||
name: "read_doc",
|
||||
title: "Read a document",
|
||||
description: [
|
||||
"Reads a Google Doc, every tab included, and returns its content.",
|
||||
"content.text is the whole document as Markdown-style text: headings start with #, list items with - or their number, tables use | cells |, links are [text](url), footnote references are [^1] with the footnote text after the body, headers and footers follow the body under [Header] and [Footer], and each tab starts with === Tab: title === when there is more than one.",
|
||||
|
||||
@@ -47,6 +47,7 @@ export function updateDocResult(response: RestBatchUpdateResponse): CallToolResu
|
||||
export const updateDoc = defineTool({
|
||||
definition: {
|
||||
name: "update_doc",
|
||||
title: "Edit a document",
|
||||
description: [
|
||||
"Edits an existing Google Doc with a list of Docs API batchUpdate requests (for example insertText, deleteContentRange, replaceAllText, updateTextStyle, updateParagraphStyle, createParagraphBullets, insertTable or insertInlineImage), and returns one reply per request.",
|
||||
"Requests are applied in the order given, all or none: if any request is invalid, nothing is changed.",
|
||||
|
||||
@@ -33,6 +33,7 @@ export function copyFileResult(file: RestFile): CallToolResult {
|
||||
export const copyFile = defineTool({
|
||||
definition: {
|
||||
name: "copy_file",
|
||||
title: "Copy a file",
|
||||
description: "Copies a Drive file into a new file and returns the copy. The original is not changed. Folders cannot be copied. Without title the copy gets Google's default name; without parentId Google places it next to the original when it can. Writes use Drive file access (drive.file), so Google may refuse a file or folder that this app did not create or open; the call then returns an error and nothing is copied.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -128,6 +128,7 @@ export function createFileResult(file: RestFile): CallToolResult {
|
||||
export const createFile = defineTool({
|
||||
definition: {
|
||||
name: "create_file",
|
||||
title: "Create a file",
|
||||
description: "Creates a new file in Google Drive and returns it. It never changes or replaces an existing file. Prefer textContent for text; use base64Content for other bytes. Content is at most 5 MB. contentMimeType is required with content. By default, content Google can convert becomes a Google file: text, Markdown, HTML, RTF and Word files become Google Docs; CSV, TSV and Excel files become Sheets; PowerPoint files become Slides. Set disableConversionToGoogleType to keep the uploaded type. Without content, contentMimeType must be application/vnd.google-apps.document, application/vnd.google-apps.spreadsheet, application/vnd.google-apps.presentation or application/vnd.google-apps.folder. With Drive file access (drive.file), parentId must be a folder this app created or was given.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -14,6 +14,7 @@ export function downloadFileContentResult(id: string, file: RestFile, contentTyp
|
||||
export const downloadFileContent = defineTool({
|
||||
definition: {
|
||||
name: "download_file_content",
|
||||
title: "Download a file",
|
||||
description: "Downloads a Drive file's content as base64. Google Docs, Sheets, Slides, Drawings and Apps Script files are exported: by default Docs and Slides as text/plain, Sheets as text/csv (first sheet only; pass exportMimeType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet for every sheet), Drawings as image/svg+xml, Apps Script as JSON. Other files are returned as stored. The whole result has a size limit; a file too large for it is refused with an error that gives the limit, never cut short. For a readable text version of a document, use read_file_content.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -26,6 +26,7 @@ export function getFileMetadataResult(file: RestFile, rich: boolean): CallToolRe
|
||||
export const getFileMetadata = defineTool({
|
||||
definition: {
|
||||
name: "get_file_metadata",
|
||||
title: "Read file details",
|
||||
description: "Gets a Drive file's metadata: title, type, size, parent folder, owner, times and link. Returns no content snippet; use read_file_content for the text. If the file is not found, find it with search_files.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -59,6 +59,7 @@ export async function readPermissions(id: string, http: GoogleHttp): Promise<Res
|
||||
export const getFilePermissions = defineTool({
|
||||
definition: {
|
||||
name: "get_file_permissions",
|
||||
title: "Read file sharing",
|
||||
description: "Lists who has access to a Drive file: each person, group, domain or link-sharing entry and its role. Google returns this only when the user may see the file's sharing.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -55,6 +55,7 @@ export function listRecentFilesResult(list: RestFileList): CallToolResult {
|
||||
export const listRecentFiles = defineTool({
|
||||
definition: {
|
||||
name: "list_recent_files",
|
||||
title: "List recent files",
|
||||
description: "Lists the user's Drive files, most recent first, leaving out trashed files. orderBy recency (default) sorts by the latest of the file's times; lastModified by the last change by anyone; lastModifiedByMe by the user's last change. Another value falls back to recency. Default page size 10, at most 100. Pass nextPageToken as pageToken for more. Returns no content snippets.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -121,6 +121,7 @@ const threadSchema = {
|
||||
export const readFileContent = defineTool({
|
||||
definition: {
|
||||
name: "read_file_content",
|
||||
title: "Read a file",
|
||||
description: "Returns a text version of a Drive file. Google Docs come back as Markdown, Slides as plain text, and Sheets as CSV of the first sheet only (the text says so). Text files (text/*, JSON, XML and similar) are returned as stored. Other files, such as PDFs, Office files and images, are not converted: the result has textFormattingNotSupported true and empty fileContent; use download_file_content for their bytes. The whole result has a size limit; a file too large for it is refused with an error that gives the limit, never cut short. With includeComments, the comment threads of a Google Doc, Sheet or Slides file are listed in unanchoredComments; they are not placed in the text. Get fileId from search_files or list_recent_files first.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -71,6 +71,7 @@ const QUERY_HELP = [
|
||||
export const searchFiles = defineTool({
|
||||
definition: {
|
||||
name: "search_files",
|
||||
title: "Search files",
|
||||
description: "Searches the user's Drive files with a structured query and returns one page of matching files (metadata only, no content snippets). Default page size 10, at most 100; pass nextPageToken as pageToken for more. Results may repeat across pages. When incompleteSearch is true, Google did not search everywhere and matching files may be missing. To read a file, pass its id to read_file_content.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -109,6 +109,7 @@ const recipients = (description: string) => ({ type: "array", items: { type: "st
|
||||
export const createDraft = defineTool({
|
||||
definition: {
|
||||
name: "create_draft",
|
||||
title: "Create a draft",
|
||||
description: "Creates a draft email in the signed-in user's Gmail and returns it. It does not send. To draft a reply, pass the original message's ID as replyToMessageId. Attachments are not supported yet.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -61,6 +61,7 @@ export function getDraftResult(draft: GmailRestDraftFull, input: GetDraftArgs, b
|
||||
export const getDraft = defineTool({
|
||||
definition: {
|
||||
name: "get_draft",
|
||||
title: "Read a draft",
|
||||
description: "Gets one draft email from the signed-in user's Gmail by draft ID. Draft IDs come from list_drafts.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -53,6 +53,7 @@ async function readExternalBodies(message: GmailRestMessage, input: GetMessageAr
|
||||
export const getMessage = defineTool({
|
||||
definition: {
|
||||
name: "get_message",
|
||||
title: "Read a message",
|
||||
description: "Gets one email message from the signed-in user's Gmail by message ID.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -35,6 +35,7 @@ export function getThreadResult(thread: GmailRestFullThread, input: GetThreadArg
|
||||
export const getThread = defineTool({
|
||||
definition: {
|
||||
name: "get_thread",
|
||||
title: "Read a thread",
|
||||
description: "Gets one email thread from the signed-in user's Gmail by thread ID, with its messages oldest first.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -52,6 +52,7 @@ async function readDrafts(ids: string[], view: DraftView | undefined, http: Goog
|
||||
export const listDrafts = defineTool({
|
||||
definition: {
|
||||
name: "list_drafts",
|
||||
title: "List drafts",
|
||||
description: "Lists the signed-in user's Gmail drafts one page at a time, optionally filtered by a Gmail search query. Returns recipients, subject and bodies by default.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -52,6 +52,7 @@ export function listLabelsResult(list: GmailLabelList, input: ListLabelsArgs): C
|
||||
export const listLabels = defineTool({
|
||||
definition: {
|
||||
name: "list_labels",
|
||||
title: "List labels",
|
||||
description: "Lists the user-defined labels in the signed-in user's Gmail with their IDs and names, sorted by name. Use the IDs with list_threads, and the names (spaces written as hyphens) with `label:` in search queries. System labels are not listed; their IDs are INBOX, SPAM, TRASH, UNREAD, STARRED, IMPORTANT, SENT, DRAFT and CHAT.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -49,6 +49,7 @@ export function listThreadsToolRequest(input: ListThreadsArgs): GoogleRequest {
|
||||
export const listThreads = defineTool({
|
||||
definition: {
|
||||
name: "list_threads",
|
||||
title: "List threads",
|
||||
description: "Lists the signed-in user's Gmail threads, newest first, one page at a time, optionally only threads that have every given label. Returns thread IDs with message summaries, not full bodies; use get_thread with a thread ID for full messages. To filter by words, senders or dates, use search_threads.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -69,6 +69,7 @@ async function readMessages(ids: string[], input: SearchMessagesArgs, http: Goog
|
||||
export const searchMessages = defineTool({
|
||||
definition: {
|
||||
name: "search_messages",
|
||||
title: "Search messages",
|
||||
description: "Lists the signed-in user's Gmail messages that match an optional Gmail search query, newest first, one page at a time. Returns message summaries by default; set messageFormat to FULL_CONTENT for bodies, or use get_message with a message ID.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -109,6 +109,7 @@ export async function readThreads(ids: string[], http: GoogleHttp): Promise<Arra
|
||||
export const searchThreads = defineTool({
|
||||
definition: {
|
||||
name: "search_threads",
|
||||
title: "Search threads",
|
||||
description: "Lists the signed-in user's Gmail threads that match an optional Gmail search query, one page at a time. Returns thread IDs with message summaries, not full bodies; use get_thread with a thread ID for full messages. A thread matches when any of its messages matches.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -86,6 +86,7 @@ export function getSpreadsheetResult(spreadsheet: RestSpreadsheet): CallToolResu
|
||||
export const getSpreadsheet = defineTool({
|
||||
definition: {
|
||||
name: "get_spreadsheet",
|
||||
title: "Read spreadsheet details",
|
||||
description: "Returns a spreadsheet as Google's Sheets API Spreadsheet resource: its title, locale, time zone, sheets (names, IDs, sizes, frozen rows), named ranges and other metadata. With includeGridData it also returns cell data for ranges (or every sheet): each cell has userEnteredValue (what was typed, including formulas), effectiveValue (the computed value; dates and times are serial numbers counted in days from December 30, 1899), formattedValue (the text shown) and its format; merged areas are listed under merges. Use fields to return only what you need. Returns at most 50,000 cells per call; a larger result is an error asking for narrower ranges or fewer fields, never a cut-off result. Comments are not available (commentsIncluded is refused).",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -42,6 +42,7 @@ export function getValuesResult(response: RestValueRange): CallToolResult {
|
||||
export const getValues = defineTool({
|
||||
definition: {
|
||||
name: "get_values",
|
||||
title: "Read cell values",
|
||||
description: "Returns the values in one range of a spreadsheet, row by row, exactly as Google Sheets displays them (formatted values): numbers, currency, percentages, dates and booleans come back as the formatted text shown in the cell (for example \"$1,200.50\", \"12%\", \"1/5/2026\", \"TRUE\"), and formula cells return their result, not the formula. Empty rows and columns at the end of the range are left out, so rows can have different lengths and an empty range has no values. In a merged area only the top-left cell holds the value. Reads at most 50,000 cells per call; a larger result is an error asking for a smaller range, never a cut-off result. For several ranges at once, formulas, or unformatted numbers and date serial numbers, use get_spreadsheet with ranges and includeGridData.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -60,6 +60,7 @@ export function insertDimensionResult(input: InsertDimensionArgs, response: Batc
|
||||
export const insertDimension = defineTool({
|
||||
definition: {
|
||||
name: "insert_dimension",
|
||||
title: "Insert rows or columns",
|
||||
description: "Inserts empty rows or columns into one sheet at a 0-based position, moving the existing rows down or columns right. It writes no cell values and deletes nothing. The result's status says which rows or columns were inserted. A failed insert is never retried automatically.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -9,6 +9,7 @@ export type UpdateFormulasArgs = z.infer<typeof args>;
|
||||
export const updateFormulas = defineTool({
|
||||
definition: {
|
||||
name: "update_formulas",
|
||||
title: "Update formulas",
|
||||
description: "Writes formulas into one range of a spreadsheet. Each item is entered as if typed into Google Sheets (Sheets valueInputOption USER_ENTERED): a string starting with = becomes a formula, such as \"=SUM(A1:A3)\" or \"=VLOOKUP(B2,Prices!A:B,2,FALSE)\"; other text may be turned into a number or date by the spreadsheet's locale. Use update_values to store text exactly as given. null leaves a cell unchanged; an empty string clears it. Writes at most 50,000 cells per call. The result's status says which range changed and how many cells. A failed write is never retried automatically.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -211,6 +211,7 @@ export function updateSpreadsheetResult(input: UpdateSpreadsheetArgs, response:
|
||||
export const updateSpreadsheet = defineTool({
|
||||
definition: {
|
||||
name: "update_spreadsheet",
|
||||
title: "Edit a spreadsheet",
|
||||
description: "Applies one or more Sheets API batchUpdate requests to a spreadsheet, in order and all together: if any request is invalid, none is applied. Each request is an object with one operation, such as updateCells, repeatCell, mergeCells, addSheet, updateSheetProperties, addChart, sortRange or findReplace. Some operations remove content: deleteSheet, deleteDimension, deleteRange, deleteDuplicates and deleteTable delete sheets, rows, columns or cells, and cutPaste, findReplace, sortRange and pasteData overwrite cells. It never deletes the spreadsheet itself, changes who it is shared with, or creates a spreadsheet. Comment and data source operations are refused, and so is writeControl. updateCells and appendCells may write at most 50,000 cells per call. The result's status lists each operation and the range it changed. A failed update is never retried automatically.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -9,6 +9,7 @@ export type UpdateValuesArgs = z.infer<typeof args>;
|
||||
export const updateValues = defineTool({
|
||||
definition: {
|
||||
name: "update_values",
|
||||
title: "Update cell values",
|
||||
description: "Writes values into one range of a spreadsheet as raw values (Sheets valueInputOption RAW): every string is stored exactly as given, so \"=SUM(A1:A3)\" stays text, and \"2026-01-05\", \"1,000\" or \"12%\" stay text rather than becoming a date or a number. Pass numbers and booleans as JSON numbers and booleans. To write formulas, use update_formulas. null leaves a cell unchanged; an empty string clears it. Writes at most 50,000 cells per call. The result's status says which range changed and how many cells. A failed write is never retried automatically.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
|
||||
@@ -44,6 +44,7 @@ export function readPresentationResult(presentation: RestPresentation, input: Re
|
||||
export const readPresentation = defineTool({
|
||||
definition: {
|
||||
name: "read_presentation",
|
||||
title: "Read a presentation",
|
||||
description: [
|
||||
"Reads a Google Slides presentation.",
|
||||
"Without fields, content.text is every slide in order as Markdown-style text: each slide starts with ## Slide N, title placeholders start with ###, bullets keep their glyph, tables use | cells |, links are [text](url), and each slide's speaker notes follow under Speaker notes:.",
|
||||
|
||||
@@ -36,6 +36,7 @@ export function updatePresentationResult(response: RestBatchUpdateResponse): Cal
|
||||
export const updatePresentation = defineTool({
|
||||
definition: {
|
||||
name: "update_presentation",
|
||||
title: "Edit a presentation",
|
||||
description: [
|
||||
"Edits an existing Google Slides presentation with a list of Slides API batchUpdate requests (for example insertText, deleteText, replaceAllText, createSlide, createShape, createTable, updateTextStyle, duplicateObject or deleteObject), and returns one reply per request.",
|
||||
"Requests are applied in the order given, all or none: if any request is invalid, nothing is changed.",
|
||||
|
||||
@@ -2,6 +2,7 @@ import { GOOGLE_WORKSPACE_TOOL_TRANSPORT, googleWorkspaceServiceToolNames } from
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
callGoogleWorkspaceRest,
|
||||
googleWorkspaceCatalogToolTitle,
|
||||
googleWorkspaceRestTransportGaps,
|
||||
probeGoogleWorkspaceRest,
|
||||
} from "./google-workspace-rest-dispatch.js";
|
||||
@@ -22,6 +23,35 @@ describe("Google Workspace REST transport eligibility", () => {
|
||||
});
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
|
||||
describe("callGoogleWorkspaceRest", () => {
|
||||
it("sends only the bearer token to Google and passes the gateway's fetch and signal", async () => {
|
||||
const controller = new AbortController();
|
||||
|
||||
@@ -2,6 +2,8 @@ import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
|
||||
import {
|
||||
GOOGLE_WORKSPACE_TOOL_TRANSPORT,
|
||||
googleWorkspaceServiceToolNames,
|
||||
googleWorkspaceToolTarget,
|
||||
googleWorkspaceToolTitle,
|
||||
type GoogleWorkspaceService,
|
||||
type GoogleWorkspaceToolTransport,
|
||||
} from "@paperclipai/shared";
|
||||
@@ -41,6 +43,19 @@ export function listGoogleWorkspaceRest(service: GoogleWorkspaceService): Tool[]
|
||||
return listGoogleWorkspaceRestTools(restService(service));
|
||||
}
|
||||
|
||||
export function googleWorkspaceCatalogToolTitle(
|
||||
sourceTemplateKey: unknown,
|
||||
name: string,
|
||||
title: string | null | undefined,
|
||||
): string | null {
|
||||
if (sourceTemplateKey !== "google-workspace") return title ?? null;
|
||||
const target = googleWorkspaceToolTarget(name);
|
||||
const restTitle = target && isGoogleWorkspaceRestService(target.service)
|
||||
? listGoogleWorkspaceRestTools(target.service).find((tool) => tool.name === target.leaf)?.title
|
||||
: undefined;
|
||||
return googleWorkspaceToolTitle(name, restTitle ?? title);
|
||||
}
|
||||
|
||||
export async function callGoogleWorkspaceRest(
|
||||
input: GoogleWorkspaceRestContext & { toolName: string; arguments: unknown; maxResultBytes: number },
|
||||
): Promise<GoogleWorkspaceRestCallOutcome> {
|
||||
|
||||
@@ -151,6 +151,7 @@ import { toolAccessPolicyService } from "./tool-access-policy.js";
|
||||
|
||||
import { googleChatToolDescription } from "./google-chat-tool-policy.js";
|
||||
import { gmailArchiveToolDescription } from "./gmail-archive-tool-policy.js";
|
||||
import { googleWorkspaceCatalogToolTitle } from "./google-workspace-rest-dispatch.js";
|
||||
|
||||
import { createToolRuntimeSupervisor } from "./tool-runtime-supervisor.js";
|
||||
|
||||
@@ -594,6 +595,7 @@ function toCatalogEntryForConnection(
|
||||
const rawCatalogEntry = toCatalogEntry(row);
|
||||
const catalogEntry = {
|
||||
...rawCatalogEntry,
|
||||
title: googleWorkspaceCatalogToolTitle(asRecord(connection.config).sourceTemplateKey, row.toolName, rawCatalogEntry.title),
|
||||
inputSchema: projectedConnectionToolInputSchema(
|
||||
connection,
|
||||
rawCatalogEntry.inputSchema ?? {},
|
||||
|
||||
@@ -5,6 +5,7 @@ import { toolApplications, toolActionRequests, toolCatalogEntries, toolConnectio
|
||||
import type { ToolActionRequestListItem, ToolActionRequestStatus } from "@paperclipai/shared";
|
||||
import { readSignedToolArgumentsPayload, TOOL_ACTION_REQUEST_SIGNING_GRACE_MS } from "../../tool-content-guards.js";
|
||||
import { toToolActionRequest } from "./projection.js";
|
||||
import { googleWorkspaceCatalogToolTitle } from "../../google-workspace-rest-dispatch.js";
|
||||
/** Pending requests stay hidden until signing completes; invalid signatures are cancelled. */
|
||||
export function createToolActionReviewQueue(db: Db) {
|
||||
return {
|
||||
@@ -185,7 +186,7 @@ listActionRequests: async (
|
||||
return {
|
||||
request: toToolActionRequest(request),
|
||||
toolName: invocation?.toolName ?? catalogEntry?.toolName ?? "",
|
||||
toolTitle: catalogEntry?.title ?? null,
|
||||
toolTitle: googleWorkspaceCatalogToolTitle(connection?.config?.sourceTemplateKey, catalogEntry?.toolName ?? invocation?.toolName ?? "", catalogEntry?.title),
|
||||
connectionId: connection?.id ?? invocation?.connectionId ?? null,
|
||||
connectionName: connection?.name ?? null,
|
||||
applicationName: application?.name ?? null,
|
||||
|
||||
@@ -9,7 +9,7 @@ import { oauthConfig } from "../oauth/metadata.js";
|
||||
import { projectedConnectionHeaders } from "../connection-methods.js";
|
||||
import { nativeProviderCatalogFor } from "../../native-provider-catalogs.js";
|
||||
import { restConnectorFor } from "../../connectors/rest-registry.js";
|
||||
import { listGoogleWorkspaceRest, probeGoogleWorkspaceRest } from "../../google-workspace-rest-dispatch.js";
|
||||
import { googleWorkspaceCatalogToolTitle, listGoogleWorkspaceRest, probeGoogleWorkspaceRest } from "../../google-workspace-rest-dispatch.js";
|
||||
import { GOOGLE_WORKSPACE_SERVICES, GOOGLE_WORKSPACE_TOOL_TRANSPORT, googleWorkspaceServiceGranted, googleWorkspaceToolName, googleWorkspaceGrantedScopes, isGoogleWorkspaceToolGranted, type GoogleWorkspaceService } from "@paperclipai/shared";
|
||||
import { isInsufficientConnectionScope, INSUFFICIENT_CONNECTION_SCOPE_MESSAGE } from "../../connection-permission-errors.js";
|
||||
import { mcpDiscoveryHttpFailure, withMcpConnectionFailure } from "../../mcp-connection-failure.js";
|
||||
@@ -172,7 +172,10 @@ export function createToolCatalogDiscovery(db: Db, { now, audit, secrets, creden
|
||||
const tools = GOOGLE_WORKSPACE_TOOL_TRANSPORT[service] === "paperclip_rest"
|
||||
? await googleWorkspaceRestTools(connection, service, headers, scopes, actor)
|
||||
: await remoteTools(connection, headers, actor, profile.serverUrl, [], listOptions);
|
||||
return tools.map((tool) => ({ ...tool, name: googleWorkspaceToolName(service, tool.name) }))
|
||||
return tools.map((tool) => {
|
||||
const name = googleWorkspaceToolName(service, tool.name);
|
||||
return { ...tool, name, title: googleWorkspaceCatalogToolTitle("google-workspace", name, tool.title) };
|
||||
})
|
||||
.filter((tool) => isGoogleWorkspaceToolGranted(tool.name, scopes));
|
||||
}));
|
||||
for (const [index, catalog] of catalogs.entries()) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import { connectionManagementService, type ConnectionManagementContext } from ".
|
||||
import { notifyDeliveryWork, DELIVERY_QUEUES } from "./delivery-work-notifications.js";
|
||||
import { measureToolDiscovery, measureRunPhase, recordConnectionCatalogCounts } from "./execution-preparation-timing.js";
|
||||
import { nativeProviderCatalogFor } from "./native-provider-catalogs.js";
|
||||
import { callGoogleWorkspaceRest, googleWorkspaceRestAuditEndpoint } from "./google-workspace-rest-dispatch.js";
|
||||
import { callGoogleWorkspaceRest, googleWorkspaceCatalogToolTitle, googleWorkspaceRestAuditEndpoint } from "./google-workspace-rest-dispatch.js";
|
||||
import { composeConnectionInstructions } from "./connection-instructions.js";
|
||||
import { googleWorkspaceToolTarget, googleWorkspaceGrantedScopes, isGoogleWorkspaceToolGranted } from "@paperclipai/shared";
|
||||
import { isInsufficientConnectionScope, INSUFFICIENT_CONNECTION_SCOPE_MESSAGE } from "./connection-permission-errors.js";
|
||||
@@ -2051,7 +2051,7 @@ export function createToolGatewayService(
|
||||
};
|
||||
return {
|
||||
name: gatewayToolName,
|
||||
displayName: catalogEntry.title ?? catalogEntry.toolName,
|
||||
displayName: googleWorkspaceCatalogToolTitle(connection.config.sourceTemplateKey, catalogEntry.toolName, catalogEntry.title) ?? catalogEntry.toolName,
|
||||
description:
|
||||
gmailArchiveToolDescription(
|
||||
connection,
|
||||
|
||||
Reference in new issue
Block a user