slides_generate
Generate presentation slides from text input using 2slides.com's API. Specify theme and language to create slides with job tracking for download.
Instructions
Generate slides with 2slides. Returns job info including jobId and downloadUrl when ready. Optional 'mode' can be 'sync' (default) or 'async'.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| themeId | Yes | ||
| userInput | Yes | ||
| responseLanguage | Yes | ||
| mode | No |
Implementation Reference
- src/server.ts:33-53 (handler)Handler function that destructures args, makes a POST request to the 2slides API to generate slides, handles the response, and returns JSON data or error.async (args: any, _extra: any) => { const { themeId, userInput, responseLanguage, mode = 'sync' } = args as z.infer<z.ZodObject<typeof GenerateArgs>>; const url = `${API_BASE_URL}/api/v1/slides/generate`; const res = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ themeId, userInput, responseLanguage, mode }), }); const data = await res.json(); if (!res.ok) { return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }], isError: true, }; } return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; }
- src/server.ts:21-27 (schema)Zod schema defining input parameters for the slides_generate tool: themeId, userInput, responseLanguage, and optional mode.const GenerateArgs = { themeId: z.string().min(1), userInput: z.string().min(1), responseLanguage: z.string().min(1), // Optional mode: 'sync' (default) | 'async' mode: z.enum(['sync', 'async']).optional(), };
- src/server.ts:29-54 (registration)Registration of the slides_generate tool using mcp.tool, including name, description, schema, and handler.mcp.tool( 'slides_generate', "Generate slides with 2slides. Returns job info including jobId and downloadUrl when ready. Optional 'mode' can be 'sync' (default) or 'async'.", GenerateArgs, async (args: any, _extra: any) => { const { themeId, userInput, responseLanguage, mode = 'sync' } = args as z.infer<z.ZodObject<typeof GenerateArgs>>; const url = `${API_BASE_URL}/api/v1/slides/generate`; const res = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ themeId, userInput, responseLanguage, mode }), }); const data = await res.json(); if (!res.ok) { return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }], isError: true, }; } return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } );