@@ -92,11 +92,39 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
9292 }
9393 ) . then ( ( res ) => res . json ( ) )
9494
95- const slideIndex = params . slideIndex || 0
95+ const metadata = {
96+ presentationId,
97+ title : presentationData . title || 'Updated Presentation' ,
98+ mimeType : 'application/vnd.google-apps.presentation' ,
99+ url : `https://docs.google.com/presentation/d/${ presentationId } /edit` ,
100+ }
101+
102+ const slideIndex =
103+ typeof params . slideIndex === 'string'
104+ ? Number . parseInt ( params . slideIndex , 10 )
105+ : ( params . slideIndex ?? 0 )
96106 const slide = presentationData . slides ?. [ slideIndex ]
97107
108+ if ( Number . isNaN ( slideIndex ) || slideIndex < 0 ) {
109+ return {
110+ success : false ,
111+ error : 'Slide index must be a non-negative number' ,
112+ output : {
113+ updatedContent : false ,
114+ metadata,
115+ } ,
116+ }
117+ }
118+
98119 if ( ! slide ) {
99- throw new Error ( `Slide at index ${ slideIndex } not found` )
120+ return {
121+ success : false ,
122+ error : `Slide at index ${ slideIndex } not found` ,
123+ output : {
124+ updatedContent : false ,
125+ metadata,
126+ } ,
127+ }
100128 }
101129
102130 // Create requests to add content to the slide
@@ -153,15 +181,14 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
153181 if ( ! updateResponse . ok ) {
154182 const errorText = await updateResponse . text ( )
155183 logger . error ( 'Failed to update presentation:' , { errorText } )
156- throw new Error ( 'Failed to update presentation' )
157- }
158-
159- // Create presentation metadata
160- const metadata = {
161- presentationId,
162- title : presentationData . title || 'Updated Presentation' ,
163- mimeType : 'application/vnd.google-apps.presentation' ,
164- url : `https://docs.google.com/presentation/d/${ presentationId } /edit` ,
184+ return {
185+ success : false ,
186+ error : 'Failed to update presentation' ,
187+ output : {
188+ updatedContent : false ,
189+ metadata,
190+ } ,
191+ }
165192 }
166193
167194 return {
@@ -185,6 +212,24 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
185212 metadata : {
186213 type : 'json' ,
187214 description : 'Updated presentation metadata including ID, title, and URL' ,
215+ properties : {
216+ presentationId : {
217+ type : 'string' ,
218+ description : 'The presentation ID' ,
219+ } ,
220+ title : {
221+ type : 'string' ,
222+ description : 'The presentation title' ,
223+ } ,
224+ mimeType : {
225+ type : 'string' ,
226+ description : 'The mime type of the presentation' ,
227+ } ,
228+ url : {
229+ type : 'string' ,
230+ description : 'URL to open the presentation' ,
231+ } ,
232+ } ,
188233 } ,
189234 } ,
190235
0 commit comments