create_slide
Add a new slide to your Google Slides presentation by specifying the presentation ID and optional position for insertion.
Instructions
Create a new slide in a Google Slides presentation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| insertionIndex | No | Position where to insert the slide (optional, defaults to 0) | |
| presentationId | Yes | The ID of the Google Slides presentation |
Implementation Reference
- src/slides.ts:26-57 (handler)Core handler implementing the create_slide tool logic: creates a new blank slide via Google Slides API batchUpdate.async createSlide(presentationId: string, insertionIndex?: number): Promise<SlideInfo> { await this.auth.refreshTokenIfNeeded(); const slides = this.auth.getSlidesClient(); const requests = [{ createSlide: { objectId: `slide_${Date.now()}`, insertionIndex: insertionIndex || 0, slideLayoutReference: { predefinedLayout: 'BLANK' } } }]; try { const response = await slides.presentations.batchUpdate({ presentationId, requestBody: { requests } }); const createdSlide = response.data.replies[0].createSlide; return { slideId: createdSlide.objectId, title: 'New Slide' }; } catch (error) { console.error('Error creating slide:', error); throw new Error(`Failed to create slide: ${error}`); } }
- src/index.ts:244-261 (handler)MCP server handler for create_slide tool: delegates to slidesService.createSlide and formats response.private async handleCreateSlide(args: { presentationId: string; insertionIndex?: number; }): Promise<CallToolResult> { const slideInfo = await this.slidesService.createSlide( args.presentationId, args.insertionIndex ); return { content: [ { type: 'text', text: `Successfully created new slide with ID: ${slideInfo.slideId}`, }, ], }; }
- src/index.ts:58-75 (registration)Tool registration in ListToolsRequestSchema handler, defining name, description, and input schema.{ name: 'create_slide', description: 'Create a new slide in a Google Slides presentation', inputSchema: { type: 'object', properties: { presentationId: { type: 'string', description: 'The ID of the Google Slides presentation', }, insertionIndex: { type: 'number', description: 'Position where to insert the slide (optional, defaults to 0)', }, }, required: ['presentationId'], }, },
- src/slides.ts:3-6 (schema)Type definition for the return value of createSlide (SlideInfo).export interface SlideInfo { slideId: string; title?: string; }
- src/index.ts:176-180 (handler)Dispatch case in CallToolRequestSchema handler for routing create_slide calls.case 'create_slide': return await this.handleCreateSlide(args as { presentationId: string; insertionIndex?: number; });