feat(slides): add write tools for Google Slides#235
feat(slides): add write tools for Google Slides#235stefanoamorelli wants to merge 18 commits intogemini-cli-extensions:mainfrom
Conversation
The read-only scope `presentations.readonly` prevents any write operations against the Google Slides API. Since we're about to add write tools (create, addSlide, deleteSlide, etc.), the scope needs to be upgraded to the full `presentations` scope which grants both read and write access.
The setup script still referenced `presentations.readonly` in the OAuth consent screen scopes list, which would cause a mismatch with the actual scope requested by the server. This aligns it with the full `presentations` scope.
…setup These two private helpers reduce boilerplate in the upcoming write methods, each of which needs to format success/error responses the same way. The existing read-only methods are left untouched to keep this change minimal and reviewable. On the test side, `create` and `batchUpdate` mocks are added to the Slides API mock object so the new method tests can use them.
Wraps `presentations.create` from the Google Slides API to allow creating a new empty presentation with a given title. Returns the presentation ID and a direct edit URL.
Summary of ChangesHello @stefanoamorelli, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a substantial expansion of Google Slides automation capabilities by integrating 15 new write tools. This enhancement allows users to programmatically create, modify, and populate Google Slides presentations, streamlining workflows that involve template manipulation, dynamic content generation, and presentation assembly. The changes include updating necessary API permissions and thoroughly testing the new functionalities to ensure reliability and ease of use. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces 15 new write tools for Google Slides, significantly expanding the extension's capabilities for presentation management. The implementation correctly leverages the Google Slides API's batchUpdate method and handles OAuth scope upgrades. I've identified a few opportunities to improve type safety in the tool schemas and a functional bug in how speaker notes are cleared before updating.
Wraps the `createSlide` batchUpdate request to add a new slide to an existing presentation. Supports optional insertion index, predefined layout (e.g. BLANK, TITLE_AND_BODY), or a specific layout ID from the presentation's masters.
Wraps the `deleteObject` batchUpdate request to remove a slide from a presentation by its object ID.
Wraps the `duplicateObject` batchUpdate request to clone a slide. The duplicate is placed immediately after the original and gets a new unique object ID returned in the response.
Wraps the `updateSlidesPosition` batchUpdate request to move one or more slides to a new position within the presentation.
Reads speaker notes for every slide in a presentation by traversing the `notesPage` structure. Each slide's notes text, object ID, and speaker notes shape ID are returned so they can be used with updateSpeakerNotes later.
Replaces the speaker notes for a specific slide. The method first reads the current notes page structure to find the speaker notes shape ID, then issues a deleteText + insertText batchUpdate pair. Passing an empty string clears the notes entirely.
Wraps the `replaceAllText` batchUpdate request to find-and-replace
text across the entire presentation. Supports case-sensitive and
case-insensitive matching. Particularly useful for template
variable substitution (e.g. replacing `{{name}}` placeholders).
Wraps the `insertText` batchUpdate request to insert text into a shape or table cell at a given index. Defaults to inserting at position 0 (beginning of the text content).
Wraps the `deleteText` batchUpdate request to remove text from a shape or table cell. Supports three range modes: FIXED_RANGE (start + end index), FROM_START_INDEX (from index to end), and ALL (clear everything).
Wraps the `createShape` batchUpdate request to add shapes like TEXT_BOX, RECTANGLE, ELLIPSE, etc. to a slide. Position and dimensions are specified in points (PT) using an affine transform.
Wraps the `createImage` batchUpdate request to insert an image from a publicly accessible URL onto a slide. Position and dimensions are specified in points (PT).
Wraps the `createTable` batchUpdate request to add a table with a given number of rows and columns to a slide. Position and dimensions are specified in points (PT).
Wraps the `updateTextStyle` batchUpdate request to change text formatting (bold, italic, font size, color, etc.) on a shape or table cell. The style parameter accepts a JSON string to work around the MCP SDK's lack of support for `z.record(z.any())` schemas, with a clear error message on invalid input.
Wraps the `updateShapeProperties` batchUpdate request to modify shape properties like background fill, outline, shadow, etc. Like updateTextStyle, the shapeProperties parameter accepts a JSON string to avoid the MCP SDK `z.record(z.any())` serialization issue.
69689c5 to
a1e55ba
Compare
Tip
Better reviewed commit-by-commit.
This adds 15 write tools for Google Slides, on top of the existing 5 read-only ones 1. Me and my team do use Google Slides templates heavily and being able to programmatically create presentations, replace placeholder text, add slides, insert images/tables, and update formatting would save us a lot of manual work.
All new tools map to existing Google Slides API v1
presentations.batchUpdaterequests 2. The only scope change needed is upgrading frompresentations.readonlytopresentations3, which is also reflected in the GCP setup script 4.NB:
updateTextStyleandupdateShapePropertiesaccept their style/properties as a JSON string instead ofz.record(z.any())because the MCP SDK schema serializer does not supportz.any()and causestools/listto fail silently. The JSON is parsed at runtime with a descriptive error on invalid input.Commits
80f4879upgrade OAuth scope to full presentations access0c7a6d1align GCP setup script scope with index.tsa1e91caadd formatError/formatResult helpers and test mock setupf9d42efadd slides.create77cc965add slides.addSlide3a56dd9add slides.deleteSlide639442cadd slides.duplicateSlide42361f6add slides.reorderSlides92f5eb1add slides.getSpeakerNotes656d145add slides.updateSpeakerNotesadaf091add slides.replaceAllText79d7d41add slides.insertText18d1018add slides.deleteText290830aadd slides.addShape9755bf9add slides.addImage86eb02aadd slides.addTable14cb5ddadd slides.updateTextStyle69689c5add slides.updateShapePropertiesCloses #234